diff options
author | dgp <dgp@users.sourceforge.net> | 2013-04-01 17:12:10 (GMT) |
---|---|---|
committer | dgp <dgp@users.sourceforge.net> | 2013-04-01 17:12:10 (GMT) |
commit | 1a5fb3e36f32ee0ace50bb1f179af9091170f5a3 (patch) | |
tree | ecb30d7095d0f07e259d36913140447b6303e4a7 /unix/tkUnixEvent.c | |
parent | a3be66c88fd7d5f2e2e9a475635bf0c5b407335b (diff) | |
parent | 5a6fcb313c27b3145619f37e5d83b93586805a2e (diff) | |
download | tk-1a5fb3e36f32ee0ace50bb1f179af9091170f5a3.zip tk-1a5fb3e36f32ee0ace50bb1f179af9091170f5a3.tar.gz tk-1a5fb3e36f32ee0ace50bb1f179af9091170f5a3.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.c | 34 |
1 files changed, 33 insertions, 1 deletions
diff --git a/unix/tkUnixEvent.c b/unix/tkUnixEvent.c index 59fba29..64a76f6 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 @@ -116,7 +124,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 +155,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 |