diff options
Diffstat (limited to 'unix/tkUnixKey.c')
-rw-r--r-- | unix/tkUnixKey.c | 51 |
1 files changed, 20 insertions, 31 deletions
diff --git a/unix/tkUnixKey.c b/unix/tkUnixKey.c index baba11e..1a5cb7d 100644 --- a/unix/tkUnixKey.c +++ b/unix/tkUnixKey.c @@ -12,20 +12,10 @@ #include "tkInt.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) +#undef register /* Keyword "register" is used in XKBlib.h, so don't try tricky things here */ +#define XkbOpenDisplay XkbOpenDisplay_ /* Move out of the way, conflicting definitions */ +#include <X11/XKBlib.h> +#undef XkbOpenDisplay /* * Prototypes for local functions defined in this file: @@ -110,7 +100,7 @@ TkpGetString( XEvent *eventPtr, /* X keyboard event. */ Tcl_DString *dsPtr) /* Initialized, empty string to hold result. */ { - size_t len; + TkSizeT len; Tcl_DString buf; TkKeyEvent *kePtr = (TkKeyEvent *) eventPtr; @@ -138,8 +128,7 @@ TkpGetString( #ifdef TK_USE_INPUT_METHODS if ((winPtr->dispPtr->flags & TK_DISPLAY_USE_IM) - && (winPtr->inputContext != NULL) - && (eventPtr->type == KeyPress)) { + && (winPtr->inputContext != NULL)) { Status status; #if X_HAVE_UTF8_STRING @@ -194,8 +183,7 @@ TkpGetString( { /* * Fall back to convert a keyboard event to a UTF-8 string using - * XLookupString. This is used when input methods are turned off and - * for KeyRelease events. + * XLookupString. This is used when input methods are turned off. * * Note: XLookupString() normally returns a single ISO Latin 1 or * ASCII control character. @@ -208,7 +196,7 @@ TkpGetString( Tcl_DStringValue(&buf)[len] = '\0'; if (len == 1) { - len = Tcl_UniCharToUtf((unsigned char) Tcl_DStringValue(&buf)[0], + len = TkUniCharToUtf((unsigned char) Tcl_DStringValue(&buf)[0], Tcl_DStringValue(dsPtr)); Tcl_DStringSetLength(dsPtr, len); } else { @@ -229,7 +217,7 @@ TkpGetString( */ done: - kePtr->charValuePtr = ckalloc(len + 1); + kePtr->charValuePtr = (char *)ckalloc(len + 1); kePtr->charValueLen = len; memcpy(kePtr->charValuePtr, Tcl_DStringValue(dsPtr), len + 1); return Tcl_DStringValue(dsPtr); @@ -237,7 +225,7 @@ done: /* * When mapping from a keysym to a keycode, need information about the - * modifier state to be used so that when they call TkKeycodeToKeysym taking + * modifier state to be used so that when they call XbkKeycodeToKeysym taking * into account the xkey.state, they will get back the original keysym. */ @@ -279,9 +267,9 @@ TkpSetKeycodeAndState( mincode = 0; maxcode = -1; XDisplayKeycodes(dispPtr->display, &mincode, &maxcode); - if (keycode < mincode) { + if (keycode < (KeyCode)mincode) { keycode = mincode; - } else if (keycode > maxcode) { + } else if (keycode > (KeyCode)maxcode) { keycode = maxcode; } @@ -363,7 +351,7 @@ TkpGetKeySym( && (eventPtr->xkey.state & LockMask))) { index += 1; } - sym = TkKeycodeToKeysym(dispPtr, eventPtr->xkey.keycode, 0, + sym = XkbKeycodeToKeysym(dispPtr->display, eventPtr->xkey.keycode, 0, index); /* @@ -378,7 +366,7 @@ TkpGetKeySym( || ((sym >= XK_Agrave) && (sym <= XK_Odiaeresis)) || ((sym >= XK_Ooblique) && (sym <= XK_Thorn)))) { index &= ~1; - sym = TkKeycodeToKeysym(dispPtr, eventPtr->xkey.keycode, + sym = XkbKeycodeToKeysym(dispPtr->display, eventPtr->xkey.keycode, 0, index); } } @@ -389,7 +377,7 @@ TkpGetKeySym( */ if ((index & 1) && (sym == NoSymbol)) { - sym = TkKeycodeToKeysym(dispPtr, eventPtr->xkey.keycode, + sym = XkbKeycodeToKeysym(dispPtr->display, eventPtr->xkey.keycode, 0, index & ~1); } return sym; @@ -439,7 +427,7 @@ TkpInitKeymapInfo( if (*codePtr == 0) { continue; } - keysym = TkKeycodeToKeysym(dispPtr, *codePtr, 0, 0); + keysym = XkbKeycodeToKeysym(dispPtr->display, *codePtr, 0, 0); if (keysym == XK_Shift_Lock) { dispPtr->lockUsage = LU_SHIFT; break; @@ -465,7 +453,8 @@ TkpInitKeymapInfo( if (*codePtr == 0) { continue; } - keysym = TkKeycodeToKeysym(dispPtr, *codePtr, 0, 0); + keysym = XkbKeycodeToKeysym(dispPtr->display, *codePtr, 0, 0); + if (keysym == XK_Mode_switch) { dispPtr->modeModMask |= ShiftMask << (i/modMapPtr->max_keypermod); } @@ -486,7 +475,7 @@ TkpInitKeymapInfo( } dispPtr->numModKeyCodes = 0; arraySize = KEYCODE_ARRAY_SIZE; - dispPtr->modKeyCodes = ckalloc(KEYCODE_ARRAY_SIZE * sizeof(KeyCode)); + dispPtr->modKeyCodes = (KeyCode *)ckalloc(KEYCODE_ARRAY_SIZE * sizeof(KeyCode)); for (i = 0, codePtr = modMapPtr->modifiermap; i < max; i++, codePtr++) { if (*codePtr == 0) { continue; @@ -513,7 +502,7 @@ TkpInitKeymapInfo( */ arraySize *= 2; - newCodes = ckalloc(arraySize * sizeof(KeyCode)); + newCodes = (KeyCode *)ckalloc(arraySize * sizeof(KeyCode)); memcpy(newCodes, dispPtr->modKeyCodes, dispPtr->numModKeyCodes * sizeof(KeyCode)); ckfree(dispPtr->modKeyCodes); |