summaryrefslogtreecommitdiffstats
path: root/unix/tkUnixEvent.c
diff options
context:
space:
mode:
authordgp <dgp@users.sourceforge.net>2013-04-01 17:50:50 (GMT)
committerdgp <dgp@users.sourceforge.net>2013-04-01 17:50:50 (GMT)
commitf9b627e0687822d6b46b2ba34626258a8145094b (patch)
tree4ac3819dc8b1575dc7d7d6a8f7cc6a299b8aa8b5 /unix/tkUnixEvent.c
parentc7f2e4b4449c07a0ac71b26e5da802d7fe5aaa89 (diff)
parentd5b7206362a9e60c41e3de7e60ead1034c8d50f5 (diff)
downloadtk-f9b627e0687822d6b46b2ba34626258a8145094b.zip
tk-f9b627e0687822d6b46b2ba34626258a8145094b.tar.gz
tk-f9b627e0687822d6b46b2ba34626258a8145094b.tar.bz2
3607830 Runtime checks that Xkb is available in the X server before trying to
use. Adapted from patch from Brian Griffin.
Diffstat (limited to 'unix/tkUnixEvent.c')
-rw-r--r--unix/tkUnixEvent.c33
1 files changed, 32 insertions, 1 deletions
diff --git a/unix/tkUnixEvent.c b/unix/tkUnixEvent.c
index c540157..473a7b8 100644
--- a/unix/tkUnixEvent.c
+++ b/unix/tkUnixEvent.c
@@ -12,6 +12,14 @@
#include "tkUnixInt.h"
#include <signal.h>
+#ifdef HAVE_XKBKEYCODETOKEYSYM
+# include <X11/XKBlib.h>
+/* Work around stupid un-const-ified Xkb headers. Grrrrr.... */
+# define XkbOpenDisplay(D,V,E,M,m,R) \
+ (XkbOpenDisplay)((char *)(D),(V),(E),(M),(m),(R))
+#else
+# define XkbOpenDisplay(D,V,E,M,m,R) (NULL)
+#endif
/*
* The following static indicates whether this module has been initialized in
@@ -117,6 +125,12 @@ TkpOpenDisplay(
{
TkDisplay *dispPtr;
Display *display;
+ int event = 0;
+ int error = 0;
+ int major = 1;
+ int minor = 0;
+ int reason = 0;
+ unsigned int use_xkb = 0;
#ifdef TCL_THREADS
static int xinited = 0;
TCL_DECLARE_MUTEX(xinitMutex);
@@ -134,13 +148,30 @@ TkpOpenDisplay(
}
#endif
- display = XOpenDisplay(displayNameStr);
+ /*
+ ** Bug [3607830]: Before using Xkb, it must be initialized and confirmed
+ ** that the serve supports it. The XkbOpenDisplay call
+ ** will perform this check and return NULL if the extension
+ ** is not supported.
+ */
+ display = XkbOpenDisplay(displayNameStr, &event, &error, &major, &minor, &reason);
+
+ if (display == NULL) {
+ /*fprintf(stderr,"event=%d error=%d major=%d minor=%d reason=%d\nDisabling xkb\n",
+ event, error, major, minor, reason);*/
+ display = XOpenDisplay(displayNameStr);
+ } else {
+ use_xkb = TK_DISPLAY_USE_XKB;
+ /*fprintf(stderr, "Using xkb %d.%d\n", major, minor);*/
+ }
+
if (display == NULL) {
return NULL;
}
dispPtr = ckalloc(sizeof(TkDisplay));
memset(dispPtr, 0, sizeof(TkDisplay));
dispPtr->display = display;
+ dispPtr->flags |= use_xkb;
#ifdef TK_USE_INPUT_METHODS
OpenIM(dispPtr);
#endif