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/tkEvent.c | |
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/tkEvent.c')
-rw-r--r-- | generic/tkEvent.c | 128 |
1 files changed, 47 insertions, 81 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; |