summaryrefslogtreecommitdiffstats
path: root/generic
diff options
context:
space:
mode:
Diffstat (limited to 'generic')
-rw-r--r--generic/tkEvent.c55
-rw-r--r--generic/tkInt.h20
2 files changed, 60 insertions, 15 deletions
diff --git a/generic/tkEvent.c b/generic/tkEvent.c
index 366ba86..9ad96d1 100644
--- a/generic/tkEvent.c
+++ b/generic/tkEvent.c
@@ -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: tkEvent.c,v 1.8 2000/06/03 08:58:16 hobbs Exp $
+ * RCS: @(#) $Id: tkEvent.c,v 1.9 2002/04/05 08:41:07 hobbs Exp $
*/
#include "tkPort.h"
@@ -749,18 +749,51 @@ Tk_HandleEvent(eventPtr)
* Pass the event to the input method(s), if there are any, and
* discard the event if the input method(s) insist. Create the
* input context for the window if it hasn't already been done
- * (XFilterEvent needs this context).
+ * (XFilterEvent needs this context). XIM is only ever enabled on
+ * Unix, but this hasn't been factored out of the generic code yet.
*/
- if (winPtr->dispPtr->useInputMethods) {
- if (!(winPtr->flags & TK_CHECKED_IC)) {
- if (winPtr->dispPtr->inputMethod != NULL) {
- winPtr->inputContext = XCreateIC(
- winPtr->dispPtr->inputMethod, XNInputStyle,
- XIMPreeditNothing|XIMStatusNothing,
- XNClientWindow, winPtr->window,
- XNFocusWindow, winPtr->window, NULL);
- }
+ dispPtr = winPtr->dispPtr;
+ if ((dispPtr->useInputMethods)) {
+ if (!(winPtr->flags & (TK_CHECKED_IC|TK_ALREADY_DEAD))) {
winPtr->flags |= TK_CHECKED_IC;
+ if (dispPtr->inputMethod != NULL) {
+#if TK_XIM_SPOT
+ XVaNestedList preedit_attr;
+ XPoint spot = {0, 0};
+
+ if (dispPtr->inputXfs == NULL) {
+ /*
+ * We only need to create one XFontSet
+ */
+ char **missing_list;
+ int missing_count;
+ char *def_string;
+
+ dispPtr->inputXfs = XCreateFontSet(dispPtr->display,
+ "-*-*-*-R-Normal--14-130-75-75-*-*",
+ &missing_list, &missing_count, &def_string);
+ if (missing_count > 0) {
+ XFreeStringList(missing_list);
+ }
+ }
+
+ preedit_attr = XVaCreateNestedList(0, XNSpotLocation, &spot,
+ XNFontSet, dispPtr->inputXfs, NULL);
+ winPtr->inputContext = XCreateIC(dispPtr->inputMethod,
+ XNInputStyle, XIMPreeditPosition | XIMStatusNothing,
+ XNClientWindow, winPtr->window,
+ XNFocusWindow, winPtr->window,
+ XNPreeditAttributes, preedit_attr,
+ NULL);
+ XFree(preedit_attr);
+#else
+ winPtr->inputContext = XCreateIC(dispPtr->inputMethod,
+ XNInputStyle, XIMPreeditNothing | XIMStatusNothing,
+ XNClientWindow, winPtr->window,
+ XNFocusWindow, winPtr->window,
+ NULL);
+#endif
+ }
}
if (XFilterEvent(eventPtr, None)) {
goto done;
diff --git a/generic/tkInt.h b/generic/tkInt.h
index 30772bc..44c9f67 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.42 2002/02/22 02:41:16 hobbs Exp $
+ * RCS: $Id: tkInt.h,v 1.43 2002/04/05 08:41:07 hobbs Exp $
*/
#ifndef _TKINT
@@ -82,6 +82,16 @@ 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
+
+/*
* One of the following structures is maintained for each display
* containing a window managed by Tk. In part, the structure is
* used to store thread-specific data, since each thread will have
@@ -456,6 +466,9 @@ typedef struct TkDisplay {
#ifdef TK_USE_INPUT_METHODS
XIM inputMethod; /* Input method for this display */
+#if TK_XIM_SPOT
+ 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. */
@@ -481,6 +494,7 @@ typedef struct TkDisplay {
long deletionEpoch; /* Incremented by window deletions */
} TkDisplay;
+
/*
* One of the following structures exists for each error handler
* created by a call to Tk_CreateErrorHandler. The structure
@@ -517,8 +531,6 @@ typedef struct TkErrorHandler {
} TkErrorHandler;
-
-
/*
* One of the following structures exists for each event handler
* created by calling Tk_CreateEventHandler. This information
@@ -700,7 +712,7 @@ typedef struct TkWindow {
* declared for this window, or
* NULL if none. */
#ifdef TK_USE_INPUT_METHODS
- XIC inputContext; /* Input context (for input methods). */
+ XIC inputContext; /* XIM input context. */
#endif /* TK_USE_INPUT_METHODS */
/*