diff options
author | jenglish <jenglish@flightlab.com> | 2008-03-26 19:04:08 (GMT) |
---|---|---|
committer | jenglish <jenglish@flightlab.com> | 2008-03-26 19:04:08 (GMT) |
commit | 81b487a13cf938a65bb309aa132f60db67de7d27 (patch) | |
tree | 62c1e353dd0bee609504ad4e45ac0bf635db5585 /generic | |
parent | d68b21a91c0842a39c72439b909169c6668b46a4 (diff) | |
download | tk-81b487a13cf938a65bb309aa132f60db67de7d27.zip tk-81b487a13cf938a65bb309aa132f60db67de7d27.tar.gz tk-81b487a13cf938a65bb309aa132f60db67de7d27.tar.bz2 |
XIM reorganization and cleanup; see [Patch 1919791] for details.
Diffstat (limited to 'generic')
-rw-r--r-- | generic/tkEvent.c | 128 | ||||
-rw-r--r-- | generic/tkInt.h | 18 |
2 files changed, 49 insertions, 97 deletions
diff --git a/generic/tkEvent.c b/generic/tkEvent.c index fda8ac9..ffc8484 100644 --- a/generic/tkEvent.c +++ b/generic/tkEvent.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: tkEvent.c,v 1.34 2006/11/24 18:04:14 jenglish Exp $ + * RCS: @(#) $Id: tkEvent.c,v 1.35 2008/03/26 19:04:09 jenglish Exp $ */ #include "tkInt.h" @@ -210,9 +210,7 @@ static void UpdateButtonEventState(XEvent *eventPtr); static int WindowEventProc(Tcl_Event *evPtr, int flags); #ifdef TK_USE_INPUT_METHODS static int InvokeInputMethods(TkWindow *winPtr, XEvent *eventPtr); -#if TK_XIM_SPOT -static void CreateXIMSpotMethods(TkWindow *winPtr); -#endif /* TK_XIM_SPOT */ +static void CreateXIC(TkWindow *winPtr); #endif /* TK_USE_INPUT_METHODS */ /* @@ -319,69 +317,52 @@ InvokeMouseHandlers( /* *---------------------------------------------------------------------- * - * CreateXIMSpotMethods -- + * CreateXIC -- * - * Create the X input methods for our winPtr. XIM is only ever enabled on - * Unix. - * - * Results: - * None. - * - * Side effects: - * An input context is created or we Tcl_Panic. + * Create the X input context for our winPtr. + * XIM is only ever enabled on Unix. * *---------------------------------------------------------------------- */ -#if defined(TK_USE_INPUT_METHODS) && TK_XIM_SPOT +#if defined(TK_USE_INPUT_METHODS) static void -CreateXIMSpotMethods( +CreateXIC( TkWindow *winPtr) { TkDisplay *dispPtr = winPtr->dispPtr; + long im_event_mask = 0L; + const char *preedit_attname = NULL; + XVaNestedList preedit_attlist = NULL; - if (dispPtr->flags & TK_DISPLAY_XIM_SPOT) { - XVaNestedList preedit_attr; + if (dispPtr->inputStyle & XIMPreeditPosition) { XPoint spot = {0, 0}; - if (dispPtr->inputXfs == NULL) { - /* - * We only need to create one XFontSet - */ + preedit_attname = XNPreeditAttributes; + preedit_attlist = XVaCreateNestedList(0, + XNSpotLocation, &spot, + XNFontSet, dispPtr->inputXfs, + NULL); + } - char **missing_list; - int missing_count; - char *def_string; + winPtr->inputContext = XCreateIC(dispPtr->inputMethod, + XNInputStyle, dispPtr->inputStyle, + XNClientWindow, winPtr->window, + XNFocusWindow, winPtr->window, + preedit_attname, preedit_attlist, + NULL); - dispPtr->inputXfs = XCreateFontSet(dispPtr->display, - "-*-*-*-R-Normal--14-130-75-75-*-*", - &missing_list, &missing_count, &def_string); - if (missing_count > 0) { - XFreeStringList(missing_list); - } - } + if (preedit_attlist) { + XFree(preedit_attlist); + } - preedit_attr = XVaCreateNestedList(0, XNSpotLocation, - &spot, XNFontSet, dispPtr->inputXfs, NULL); - if (winPtr->inputContext != NULL) { - Tcl_Panic("inputContext not NULL"); - } - winPtr->inputContext = XCreateIC(dispPtr->inputMethod, - XNInputStyle, XIMPreeditPosition|XIMStatusNothing, - XNClientWindow, winPtr->window, - XNFocusWindow, winPtr->window, - XNPreeditAttributes, preedit_attr, - NULL); - XFree(preedit_attr); - } else { - if (winPtr->inputContext != NULL) { - Tcl_Panic("inputContext not NULL"); - } - winPtr->inputContext = XCreateIC(dispPtr->inputMethod, - XNInputStyle, XIMPreeditNothing|XIMStatusNothing, - XNClientWindow, winPtr->window, - XNFocusWindow, winPtr->window, - NULL); + /* + * Adjust the window's event mask if the IM requires it. + */ + XGetICValues(winPtr->inputContext, XNFilterEvents, &im_event_mask, NULL); + if ((winPtr->atts.event_mask & im_event_mask) != im_event_mask) { + winPtr->atts.event_mask |= im_event_mask; + XSelectInput(winPtr->display, winPtr->window, winPtr->atts.event_mask); } } #endif @@ -397,8 +378,7 @@ CreateXIMSpotMethods( * context). * * When the event is a FocusIn event, set the input context focus to the - * receiving window. This is needed for certain versions of Solaris, but - * we are still not sure whether it is being done in the right way. + * receiving window. * * Results: * 1 when we are done with the event. @@ -419,38 +399,24 @@ InvokeInputMethods( TkDisplay *dispPtr = winPtr->dispPtr; if ((dispPtr->flags & TK_DISPLAY_USE_IM)) { - long im_event_mask = 0L; if (!(winPtr->flags & (TK_CHECKED_IC|TK_ALREADY_DEAD))) { winPtr->flags |= TK_CHECKED_IC; if (dispPtr->inputMethod != NULL) { -#if TK_XIM_SPOT - CreateXIMSpotMethods(winPtr); -#else - if (winPtr->inputContext != NULL) { - Tcl_Panic("inputContext not NULL"); - } - winPtr->inputContext = XCreateIC(dispPtr->inputMethod, - XNInputStyle, XIMPreeditNothing|XIMStatusNothing, - XNClientWindow, winPtr->window, - XNFocusWindow, winPtr->window, - NULL); -#endif - } - } - if (winPtr->inputContext != NULL && - (eventPtr->xany.type == FocusIn)) { - XGetICValues(winPtr->inputContext, - XNFilterEvents, &im_event_mask, NULL); - if (im_event_mask != 0L) { - XSelectInput(winPtr->display, winPtr->window, - winPtr->atts.event_mask | im_event_mask); - XSetICFocus(winPtr->inputContext); + CreateXIC(winPtr); } } - if (eventPtr->type == KeyPress || eventPtr->type == KeyRelease) { - if (XFilterEvent(eventPtr, None)) { - return 1; - } + switch (eventPtr->type) { + case FocusIn: + if (winPtr->inputContext != NULL) { + XSetICFocus(winPtr->inputContext); + } + break; + case KeyPress: + case KeyRelease: + if (XFilterEvent(eventPtr, None)) { + return 1; + } + break; } } return 0; diff --git a/generic/tkInt.h b/generic/tkInt.h index 2186089..7ae4bee 100644 --- a/generic/tkInt.h +++ b/generic/tkInt.h @@ -11,7 +11,7 @@ * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: $Id: tkInt.h,v 1.81 2007/12/13 15:24:14 dgp Exp $ + * RCS: $Id: tkInt.h,v 1.82 2008/03/26 19:04:09 jenglish Exp $ */ #ifndef _TKINT @@ -145,16 +145,6 @@ typedef struct TkCursor { } TkCursor; /* - * This defines whether we should try to use XIM over-the-spot style input. - * Allow users to override it. It is a much more elegant use of XIM, but uses - * a bit more memory. - */ - -#ifndef TK_XIM_SPOT -#define TK_XIM_SPOT 1 -#endif - -/* * The following structure is kept one-per-TkDisplay to maintain information * about the caret (cursor location) on this display. This is used to dictate * global focus location (Windows Accessibility guidelines) and to position @@ -530,9 +520,8 @@ typedef struct TkDisplay { #ifdef TK_USE_INPUT_METHODS XIM inputMethod; /* Input method for this display. */ -#if TK_XIM_SPOT + XIMStyle inputStyle; /* Input style selected for this display. */ XFontSet inputXfs; /* XFontSet cached for over-the-spot XIM. */ -#endif #endif /* TK_USE_INPUT_METHODS */ Tcl_HashTable winTable; /* Maps from X window ids to TkWindow ptrs. */ @@ -572,8 +561,6 @@ typedef struct TkDisplay { * Indicates that we should collapse motion events on this display * TK_DISPLAY_USE_IM: (default on, set via tk.tcl) * Whether to use input methods for this display - * TK_DISPLAY_XIM_SPOT: (default off) - * Indicates that we should use over-the-spot XIM on this display * TK_DISPLAY_WM_TRACING: (default off) * Whether we should do wm tracing on this display. * TK_DISPLAY_IN_WARP: (default off) @@ -582,7 +569,6 @@ typedef struct TkDisplay { #define TK_DISPLAY_COLLAPSE_MOTION_EVENTS (1 << 0) #define TK_DISPLAY_USE_IM (1 << 1) -#define TK_DISPLAY_XIM_SPOT (1 << 2) #define TK_DISPLAY_WM_TRACING (1 << 3) #define TK_DISPLAY_IN_WARP (1 << 4) |