summaryrefslogtreecommitdiffstats
path: root/unix/tkUnixKey.c
diff options
context:
space:
mode:
authorjenglish <jenglish@flightlab.com>2008-03-26 19:04:08 (GMT)
committerjenglish <jenglish@flightlab.com>2008-03-26 19:04:08 (GMT)
commit81b487a13cf938a65bb309aa132f60db67de7d27 (patch)
tree62c1e353dd0bee609504ad4e45ac0bf635db5585 /unix/tkUnixKey.c
parentd68b21a91c0842a39c72439b909169c6668b46a4 (diff)
downloadtk-81b487a13cf938a65bb309aa132f60db67de7d27.zip
tk-81b487a13cf938a65bb309aa132f60db67de7d27.tar.gz
tk-81b487a13cf938a65bb309aa132f60db67de7d27.tar.bz2
XIM reorganization and cleanup; see [Patch 1919791] for details.
Diffstat (limited to 'unix/tkUnixKey.c')
-rw-r--r--unix/tkUnixKey.c73
1 files changed, 35 insertions, 38 deletions
diff --git a/unix/tkUnixKey.c b/unix/tkUnixKey.c
index 7dc91da..4d422cf 100644
--- a/unix/tkUnixKey.c
+++ b/unix/tkUnixKey.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: tkUnixKey.c,v 1.12 2007/02/27 14:52:57 dkf Exp $
+ * RCS: @(#) $Id: tkUnixKey.c,v 1.13 2008/03/26 19:04:10 jenglish Exp $
*/
#include "tkInt.h"
@@ -24,16 +24,9 @@
* Tk_SetCaretPos --
*
* This enables correct placement of the XIM caret. This is called by
- * widgets to indicate their cursor placement, and the caret location is
- * used by TkpGetString to place the XIM caret. This is currently only
+ * widgets to indicate their cursor placement. This is currently only
* used for over-the-spot XIM.
*
- * Results:
- * None
- *
- * Side effects:
- * None
- *
*----------------------------------------------------------------------
*/
@@ -44,16 +37,42 @@ Tk_SetCaretPos(
int y,
int height)
{
- TkCaret *caretPtr = &(((TkWindow *) tkwin)->dispPtr->caret);
+ TkWindow *winPtr = (TkWindow *) tkwin;
+ TkDisplay *dispPtr = winPtr->dispPtr;
+
+ if ( dispPtr->caret.winPtr == winPtr
+ && dispPtr->caret.x == x
+ && dispPtr->caret.y == y
+ && dispPtr->caret.height == height)
+ {
+ return;
+ }
+
+ dispPtr->caret.winPtr = winPtr;
+ dispPtr->caret.x = x;
+ dispPtr->caret.y = y;
+ dispPtr->caret.height = height;
+#ifdef TK_USE_INPUT_METHODS
/*
- * Use height for best placement of the XIM over-the-spot box.
+ * Adjust the XIM caret position.
*/
+ if ( (dispPtr->flags & TK_DISPLAY_USE_IM)
+ && (dispPtr->inputStyle & XIMPreeditPosition)
+ && (winPtr->inputContext != NULL) )
+ {
+ XVaNestedList preedit_attr;
+ XPoint spot;
- caretPtr->winPtr = ((TkWindow *) tkwin);
- caretPtr->x = x;
- caretPtr->y = y;
- caretPtr->height = height;
+ spot.x = dispPtr->caret.x;
+ spot.y = dispPtr->caret.y + dispPtr->caret.height;
+ preedit_attr = XVaCreateNestedList(0, XNSpotLocation, &spot, NULL);
+ XSetICValues(winPtr->inputContext,
+ XNPreeditAttributes, preedit_attr,
+ NULL);
+ XFree(preedit_attr);
+ }
+#endif
}
/*
@@ -85,9 +104,6 @@ TkpGetString(
int len;
Tcl_DString buf;
Status status;
-#ifdef TK_USE_INPUT_METHODS
- TkDisplay *dispPtr = winPtr->dispPtr;
-#endif
/*
* Overallocate the dstring to the maximum stack amount.
@@ -97,13 +113,9 @@ TkpGetString(
Tcl_DStringSetLength(&buf, TCL_DSTRING_STATIC_SIZE-1);
#ifdef TK_USE_INPUT_METHODS
- if ((dispPtr->flags & TK_DISPLAY_USE_IM)
+ if ((winPtr->dispPtr->flags & TK_DISPLAY_USE_IM)
&& (winPtr->inputContext != NULL)
&& (eventPtr->type == KeyPress)) {
-#if TK_XIM_SPOT
- XVaNestedList preedit_attr;
- XPoint spot;
-#endif
len = XmbLookupString(winPtr->inputContext, &eventPtr->xkey,
Tcl_DStringValue(&buf), Tcl_DStringLength(&buf), NULL,
@@ -121,21 +133,6 @@ TkpGetString(
len = 0;
}
-#if TK_XIM_SPOT
- /*
- * Adjust the XIM caret position. We might want to check that this is
- * the right caret.winPtr as well.
- */
-
- if (dispPtr->flags & TK_DISPLAY_XIM_SPOT) {
- spot.x = dispPtr->caret.x;
- spot.y = dispPtr->caret.y + dispPtr->caret.height;
- preedit_attr = XVaCreateNestedList(0, XNSpotLocation, &spot, NULL);
- XSetICValues(winPtr->inputContext,
- XNPreeditAttributes, preedit_attr, NULL);
- XFree(preedit_attr);
- }
-#endif
} else {
len = XLookupString(&eventPtr->xkey, Tcl_DStringValue(&buf),
Tcl_DStringLength(&buf), NULL, NULL);