13
13
#include "tkUnixInt.h"
14
14
#include <signal.h>
15
#ifdef HAVE_XKBKEYCODETOKEYSYM
16
# include <X11/XKBlib.h>
18
# define XkbOpenDisplay(D,V,E,M,m,R) (V),(E),(M),(m),(R),(NULL)
17
22
* The following static indicates whether this module has been initialized in
116
121
const char *displayNameStr)
118
123
TkDisplay *dispPtr;
119
Display *display = XOpenDisplay(displayNameStr);
130
unsigned int use_xkb = 0;
131
/* Disabled, until we have a better test. See [Bug 3613668] */
132
#if 0 && defined(XKEYCODETOKEYSYM_IS_DEPRECATED) && defined(TCL_THREADS)
133
static int xinited = 0;
134
static Tcl_Mutex xinitMutex = NULL;
137
Tcl_MutexLock(&xinitMutex);
139
/* Necessary for threaded apps, of no consequence otherwise */
140
/* need only be called once, but must be called before *any* */
141
/* Xlib call is made. If xinitMutex is still NULL after the */
142
/* Tcl_MutexLock call, Tcl was compiled without threads so */
143
/* we cannot use XInitThreads() either. */
144
if (xinitMutex != NULL){
149
Tcl_MutexUnlock(&xinitMutex);
154
** Bug [3607830]: Before using Xkb, it must be initialized and confirmed
155
** that the serve supports it. The XkbOpenDisplay call
156
** will perform this check and return NULL if the extension
159
** Work around un-const-ified Xkb headers using (char *) cast.
161
display = XkbOpenDisplay((char *)displayNameStr, &event, &error, &major,
164
if (display == NULL) {
165
/*fprintf(stderr,"event=%d error=%d major=%d minor=%d reason=%d\nDisabling xkb\n",
166
event, error, major, minor, reason);*/
167
display = XOpenDisplay(displayNameStr);
169
use_xkb = TK_DISPLAY_USE_XKB;
170
/*fprintf(stderr, "Using xkb %d.%d\n", major, minor);*/
121
173
if (display == NULL) {
124
176
dispPtr = ckalloc(sizeof(TkDisplay));
125
177
memset(dispPtr, 0, sizeof(TkDisplay));
126
178
dispPtr->display = display;
179
dispPtr->flags |= use_xkb;
127
180
#ifdef TK_USE_INPUT_METHODS