summaryrefslogtreecommitdiffstats
path: root/unix/tkUnixEvent.c
diff options
context:
space:
mode:
authordgp <dgp@users.sourceforge.net>2013-04-01 16:27:46 (GMT)
committerdgp <dgp@users.sourceforge.net>2013-04-01 16:27:46 (GMT)
commite19cf65c7641a093a5c7cf8325c5466e431d7c69 (patch)
treed12c1e95bed377052206be8cb843b79169a061e5 /unix/tkUnixEvent.c
parent48578cf487ec03f503d5b57a50be25e52e3b1a90 (diff)
downloadtk-e19cf65c7641a093a5c7cf8325c5466e431d7c69.zip
tk-e19cf65c7641a093a5c7cf8325c5466e431d7c69.tar.gz
tk-e19cf65c7641a093a5c7cf8325c5466e431d7c69.tar.bz2
Runtime check for Xkb support in X server.
Contributed patch from Brian Griffin.
Diffstat (limited to 'unix/tkUnixEvent.c')
-rw-r--r--unix/tkUnixEvent.c27
1 files changed, 26 insertions, 1 deletions
diff --git a/unix/tkUnixEvent.c b/unix/tkUnixEvent.c
index 59fba29..5e5374a 100644
--- a/unix/tkUnixEvent.c
+++ b/unix/tkUnixEvent.c
@@ -12,6 +12,7 @@
#include "tkUnixInt.h"
#include <signal.h>
+#include <X11/XKBlib.h>
/*
* The following static indicates whether this module has been initialized in
@@ -116,7 +117,30 @@ TkpOpenDisplay(
CONST char *displayNameStr)
{
TkDisplay *dispPtr;
- Display *display = XOpenDisplay(displayNameStr);
+ Display *display;
+ int event = 0;
+ int error = 0;
+ int major = 1;
+ int minor = 0;
+ int reason = 0;
+ unsigned int use_xkb = 0;
+
+ /*
+ ** 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;
@@ -124,6 +148,7 @@ TkpOpenDisplay(
dispPtr = (TkDisplay *) ckalloc(sizeof(TkDisplay));
memset(dispPtr, 0, sizeof(TkDisplay));
dispPtr->display = display;
+ dispPtr->flags |= use_xkb;
#ifdef TK_USE_INPUT_METHODS
OpenIM(dispPtr);
#endif