From 406eb5a70238050ba7015af89d5495a48ad31107 Mon Sep 17 00:00:00 2001 From: hobbs Date: Fri, 5 Apr 2002 08:41:24 +0000 Subject: * unix/tkUnixEvent.c: * generic/tkWindow.c: moved OpenIM over to tkUnixEvent.c. Removed setting inputContext to null in Tk_MakeWindowExist as it was redundant. --- generic/tkWindow.c | 73 ++-------------------------------------- unix/tkUnixEvent.c | 98 ++++++++++++++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 98 insertions(+), 73 deletions(-) diff --git a/generic/tkWindow.c b/generic/tkWindow.c index 7975b54..4384c45 100644 --- a/generic/tkWindow.c +++ b/generic/tkWindow.c @@ -12,7 +12,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkWindow.c,v 1.43 2002/02/27 01:26:51 hobbs Exp $ + * RCS: @(#) $Id: tkWindow.c,v 1.44 2002/04/05 08:41:24 hobbs Exp $ */ #include "tkPort.h" @@ -212,7 +212,6 @@ static int Initialize _ANSI_ARGS_((Tcl_Interp *interp)); static int NameWindow _ANSI_ARGS_((Tcl_Interp *interp, TkWindow *winPtr, TkWindow *parentPtr, char *name)); -static void OpenIM _ANSI_ARGS_((TkDisplay *dispPtr)); static void UnlinkWindow _ANSI_ARGS_((TkWindow *winPtr)); /* @@ -470,7 +469,6 @@ GetScreen(interp, screenName, screenPtr) strncpy(dispPtr->name, screenName, length); dispPtr->name[length] = '\0'; dispPtr->useInputMethods = 0; - OpenIM(dispPtr); TkInitXId(dispPtr); dispPtr->deletionEpoch = 0L; @@ -1617,9 +1615,6 @@ Tk_MakeWindowExist(tkwin) Tcl_SetHashValue(hPtr, winPtr); winPtr->dirtyAtts = 0; winPtr->dirtyChanges = 0; -#ifdef TK_USE_INPUT_METHODS - winPtr->inputContext = NULL; -#endif /* TK_USE_INPUT_METHODS */ if (!(winPtr->flags & TK_TOP_LEVEL)) { /* @@ -1666,7 +1661,7 @@ Tk_MakeWindowExist(tkwin) */ if ((winPtr->flags & TK_NEED_CONFIG_NOTIFY) - && !(winPtr->flags & TK_ALREADY_DEAD)){ + && !(winPtr->flags & TK_ALREADY_DEAD)) { winPtr->flags &= ~TK_NEED_CONFIG_NOTIFY; TkDoConfigureNotify(winPtr); } @@ -2554,70 +2549,6 @@ Tk_StrictMotif(tkwin) return ((TkWindow *) tkwin)->mainPtr->strictMotif; } -/* - *-------------------------------------------------------------- - * - * OpenIM -- - * - * Tries to open an X input method, associated with the - * given display. Right now we can only deal with a bare-bones - * input style: no preedit, and no status. - * - * Results: - * Stores the input method in dispPtr->inputMethod; if there isn't - * a suitable input method, then NULL is stored in dispPtr->inputMethod. - * - * Side effects: - * An input method gets opened. - * - *-------------------------------------------------------------- - */ - -static void -OpenIM(dispPtr) - TkDisplay *dispPtr; /* Tk's structure for the display. */ -{ -#ifndef TK_USE_INPUT_METHODS - return; -#else - unsigned short i; - XIMStyles *stylePtr; - char *modifier_list; - - if ((modifier_list = XSetLocaleModifiers("")) == NULL) { - goto error; - } - - dispPtr->inputMethod = XOpenIM(dispPtr->display, NULL, NULL, NULL); - if (dispPtr->inputMethod == NULL) { - return; - } - - if ((XGetIMValues(dispPtr->inputMethod, XNQueryInputStyle, &stylePtr, - NULL) != NULL) || (stylePtr == NULL)) { - goto error; - } - for (i = 0; i < stylePtr->count_styles; i++) { - if (stylePtr->supported_styles[i] - == (XIMPreeditNothing|XIMStatusNothing)) { - XFree(stylePtr); - return; - } - } - XFree(stylePtr); - - error: - - /* - * Should close the input method, but this causes core dumps on some - * systems (e.g. Solaris 2.3 as of 1/6/95). - * XCloseIM(dispPtr->inputMethod); - */ - dispPtr->inputMethod = NULL; - return; -#endif /* TK_USE_INPUT_METHODS */ -} - /* *---------------------------------------------------------------------- * diff --git a/unix/tkUnixEvent.c b/unix/tkUnixEvent.c index d2682a7..d0f1476 100644 --- a/unix/tkUnixEvent.c +++ b/unix/tkUnixEvent.c @@ -9,7 +9,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkUnixEvent.c,v 1.4 2002/01/25 21:09:37 dgp Exp $ + * RCS: @(#) $Id: tkUnixEvent.c,v 1.5 2002/04/05 08:41:24 hobbs Exp $ */ #include "tkInt.h" @@ -39,6 +39,9 @@ static void DisplayFileProc _ANSI_ARGS_((ClientData clientData, static void DisplaySetupProc _ANSI_ARGS_((ClientData clientData, int flags)); static void TransferXEventsToTcl _ANSI_ARGS_((Display *display)); +#ifdef TK_USE_INPUT_METHODS +static void OpenIM _ANSI_ARGS_((TkDisplay *dispPtr)); +#endif /* @@ -128,6 +131,11 @@ TkpOpenDisplay(display_name) } dispPtr = (TkDisplay *) ckalloc(sizeof(TkDisplay)); dispPtr->display = display; +#ifdef TK_USE_INPUT_METHODS + dispPtr->inputMethod = NULL; + dispPtr->inputXfs = NULL; + OpenIM(dispPtr); +#endif Tcl_CreateFileHandler(ConnectionNumber(display), TCL_READABLE, DisplayFileProc, (ClientData) dispPtr); return dispPtr; @@ -158,10 +166,27 @@ TkpCloseDisplay(displayPtr) if (dispPtr->display != 0) { Tcl_DeleteFileHandler(ConnectionNumber(dispPtr->display)); +#ifdef TK_USE_INPUT_METHODS +#if TK_XIM_SPOT + if (dispPtr->inputXfs) { + XFreeFontSet(dispPtr->display, dispPtr->inputXfs); + } +#endif + if (dispPtr->inputMethod) { + /* + * This causes core dumps on some systems (e.g. Solaris 2.3 as of + * 1/6/95), but is OK with X11R6 + */ +#if ! defined (SOLARIS2) || defined (HAVE_X11R6) + XCloseIM(dispPtr->inputMethod); +#endif + } +#endif + (void) XSync(dispPtr->display, False); (void) XCloseDisplay(dispPtr->display); } - + ckfree((char *) dispPtr); } @@ -516,5 +541,74 @@ TkpSync(display) * Transfer events from the X event queue to the Tk event queue. */ TransferXEventsToTcl(display); +} +#ifdef TK_USE_INPUT_METHODS + +/* + *-------------------------------------------------------------- + * + * OpenIM -- + * + * Tries to open an X input method, associated with the + * given display. Right now we can only deal with a bare-bones + * input style: no preedit, and no status. + * + * Results: + * Stores the input method in dispPtr->inputMethod; if there isn't + * a suitable input method, then NULL is stored in dispPtr->inputMethod. + * + * Side effects: + * An input method gets opened. + * + *-------------------------------------------------------------- + */ +static void +OpenIM(dispPtr) + TkDisplay *dispPtr; /* Tk's structure for the display. */ +{ + unsigned short i; + XIMStyles *stylePtr; + char *modifier_list; + + if ((modifier_list = XSetLocaleModifiers("")) == NULL) { + goto error; + } + + dispPtr->inputMethod = XOpenIM(dispPtr->display, NULL, NULL, NULL); + if (dispPtr->inputMethod == NULL) { + return; + } + + if ((XGetIMValues(dispPtr->inputMethod, XNQueryInputStyle, &stylePtr, + NULL) != NULL) || (stylePtr == NULL)) { + goto error; + } + for (i = 0; i < stylePtr->count_styles; i++) { + if (stylePtr->supported_styles[i] +#if TK_XIM_SPOT + == (XIMPreeditPosition | XIMStatusNothing) +#else + == (XIMPreeditNothing | XIMStatusNothing) +#endif + ) { + XFree(stylePtr); + return; + } + } + XFree(stylePtr); + + error: + + if (dispPtr->inputMethod) { + /* + * This causes core dumps on some systems (e.g. Solaris 2.3 as of + * 1/6/95), but is OK with X11R6 + */ +#if ! defined (SOLARIS2) || defined (HAVE_X11R6) + XCloseIM(dispPtr->inputMethod); +#endif + dispPtr->inputMethod = NULL; + } } +#endif /* TK_USE_INPUT_METHODS */ -- cgit v0.12