summaryrefslogtreecommitdiffstats
path: root/unix/tkUnixKey.c
diff options
context:
space:
mode:
Diffstat (limited to 'unix/tkUnixKey.c')
-rw-r--r--unix/tkUnixKey.c58
1 files changed, 35 insertions, 23 deletions
diff --git a/unix/tkUnixKey.c b/unix/tkUnixKey.c
index b7fc97f..40cc779 100644
--- a/unix/tkUnixKey.c
+++ b/unix/tkUnixKey.c
@@ -11,7 +11,21 @@
*/
#include "tkInt.h"
-#include <X11/XKBlib.h>
+
+/*
+** Bug [3607830]: Before using Xkb, it must be initialized. TkpOpenDisplay
+** does this and sets the USE_XKB flag if xkb is supported.
+** (should this be function ptr?)
+*/
+#ifdef HAVE_XKBKEYCODETOKEYSYM
+# include <X11/XKBlib.h>
+#else
+# define XkbKeycodeToKeysym(D,K,G,L) XKeycodeToKeysym(D,K,L)
+#endif
+#define TkKeycodeToKeysym(D,K,G,L) \
+ ((D)->flags & TK_DISPLAY_USE_XKB) ? \
+ XkbKeycodeToKeysym((D)->display,K,G,L) : \
+ XKeycodeToKeysym((D)->display,K,L)
/*
* Prototypes for local functions defined in this file:
@@ -212,7 +226,7 @@ TkpGetString(
/*
* When mapping from a keysym to a keycode, need information about the
- * modifier state to be used so that when they call XkbKeycodeToKeysym taking
+ * modifier state to be used so that when they call TkKeycodeToKeysym taking
* into account the xkey.state, they will get back the original keysym.
*/
@@ -222,27 +236,23 @@ TkpSetKeycodeAndState(
KeySym keySym,
XEvent *eventPtr)
{
- Display *display;
+ TkDisplay *dispPtr = ((TkWindow *) tkwin)->dispPtr;
int state;
KeyCode keycode;
- display = Tk_Display(tkwin);
-
if (keySym == NoSymbol) {
keycode = 0;
} else {
- keycode = XKeysymToKeycode(display, keySym);
+ keycode = XKeysymToKeycode(dispPtr->display, keySym);
}
+ eventPtr->xkey.keycode = keycode;
if (keycode != 0) {
for (state = 0; state < 4; state++) {
- if (XkbKeycodeToKeysym(display, keycode, 0, state) == keySym) {
+ if (XLookupKeysym(&eventPtr->xkey, state) == keySym) {
if (state & 1) {
eventPtr->xkey.state |= ShiftMask;
}
if (state & 2) {
- TkDisplay *dispPtr;
-
- dispPtr = ((TkWindow *) tkwin)->dispPtr;
eventPtr->xkey.state |= dispPtr->modeModMask;
}
break;
@@ -280,6 +290,15 @@ TkpGetKeySym(
int index;
TkKeyEvent* kePtr = (TkKeyEvent*) eventPtr;
+ /*
+ * Refresh the mapping information if it's stale. This must happen before
+ * we do any input method processing. [Bug 3599312]
+ */
+
+ if (dispPtr->bindInfoStale) {
+ TkpInitKeymapInfo(dispPtr);
+ }
+
#ifdef TK_USE_INPUT_METHODS
/*
* If input methods are active, we may already have determined a keysym.
@@ -292,6 +311,7 @@ TkpGetKeySym(
Tcl_DString ds;
TkWindow *winPtr = (TkWindow *)
Tk_IdToWindow(eventPtr->xany.display, eventPtr->xany.window);
+
Tcl_DStringInit(&ds);
(void) TkpGetString(winPtr, eventPtr, &ds);
Tcl_DStringFree(&ds);
@@ -303,14 +323,6 @@ TkpGetKeySym(
#endif
/*
- * Refresh the mapping information if it's stale
- */
-
- if (dispPtr->bindInfoStale) {
- TkpInitKeymapInfo(dispPtr);
- }
-
- /*
* Figure out which of the four slots in the keymap vector to use for this
* key. Refer to Xlib documentation for more info on how this computation
* works.
@@ -325,7 +337,7 @@ TkpGetKeySym(
&& (eventPtr->xkey.state & LockMask))) {
index += 1;
}
- sym = XkbKeycodeToKeysym(dispPtr->display, eventPtr->xkey.keycode, 0,
+ sym = TkKeycodeToKeysym(dispPtr, eventPtr->xkey.keycode, 0,
index);
/*
@@ -340,7 +352,7 @@ TkpGetKeySym(
|| ((sym >= XK_Agrave) && (sym <= XK_Odiaeresis))
|| ((sym >= XK_Ooblique) && (sym <= XK_Thorn)))) {
index &= ~1;
- sym = XkbKeycodeToKeysym(dispPtr->display, eventPtr->xkey.keycode,
+ sym = TkKeycodeToKeysym(dispPtr, eventPtr->xkey.keycode,
0, index);
}
}
@@ -351,7 +363,7 @@ TkpGetKeySym(
*/
if ((index & 1) && (sym == NoSymbol)) {
- sym = XkbKeycodeToKeysym(dispPtr->display, eventPtr->xkey.keycode,
+ sym = TkKeycodeToKeysym(dispPtr, eventPtr->xkey.keycode,
0, index & ~1);
}
return sym;
@@ -401,7 +413,7 @@ TkpInitKeymapInfo(
if (*codePtr == 0) {
continue;
}
- keysym = XkbKeycodeToKeysym(dispPtr->display, *codePtr, 0, 0);
+ keysym = TkKeycodeToKeysym(dispPtr, *codePtr, 0, 0);
if (keysym == XK_Shift_Lock) {
dispPtr->lockUsage = LU_SHIFT;
break;
@@ -427,7 +439,7 @@ TkpInitKeymapInfo(
if (*codePtr == 0) {
continue;
}
- keysym = XkbKeycodeToKeysym(dispPtr->display, *codePtr, 0, 0);
+ keysym = TkKeycodeToKeysym(dispPtr, *codePtr, 0, 0);
if (keysym == XK_Mode_switch) {
dispPtr->modeModMask |= ShiftMask << (i/modMapPtr->max_keypermod);
}