Properly initialize keyboard auto-repeat for all X connections.

This commit is contained in:
Alexandre Julliard 2003-03-23 20:07:55 +00:00
parent 4fd679b0eb
commit 8d361bd41c
3 changed files with 25 additions and 17 deletions

View File

@ -58,9 +58,6 @@ WORD keyc2vkey[256], keyc2scan[256];
static LPBYTE pKeyStateTable; static LPBYTE pKeyStateTable;
static int NumLockMask, AltGrMask; /* mask in the XKeyEvent state */ static int NumLockMask, AltGrMask; /* mask in the XKeyEvent state */
static int kcControl, kcAlt, kcShift, kcNumLock, kcCapsLock; /* keycodes */ static int kcControl, kcAlt, kcShift, kcNumLock, kcCapsLock; /* keycodes */
#ifdef HAVE_XKB
static int is_xkb, xkb_opcode, xkb_event, xkb_error;
#endif
static char KEYBOARD_MapDeadKeysym(KeySym keysym); static char KEYBOARD_MapDeadKeysym(KeySym keysym);
@ -1124,7 +1121,7 @@ X11DRV_KEYBOARD_DetectLayout (void)
if ((keysym < 0x8000) && (keysym != ' ')) if ((keysym < 0x8000) && (keysym != ' '))
{ {
#ifdef HAVE_XKB #ifdef HAVE_XKB
if (!is_xkb || !XkbTranslateKeySym(display, &keysym, 0, &ckey[i], 1, NULL)) if (!use_xkb || !XkbTranslateKeySym(display, &keysym, 0, &ckey[i], 1, NULL))
#endif #endif
{ {
TRACE("XKB could not translate keysym %ld\n", keysym); TRACE("XKB could not translate keysym %ld\n", keysym);
@ -1200,9 +1197,6 @@ X11DRV_KEYBOARD_DetectLayout (void)
*/ */
void X11DRV_InitKeyboard( BYTE *key_state_table ) void X11DRV_InitKeyboard( BYTE *key_state_table )
{ {
#ifdef HAVE_XKB
int xkb_major = XkbMajorVersion, xkb_minor = XkbMinorVersion;
#endif
Display *display = thread_display(); Display *display = thread_display();
KeySym *ksp; KeySym *ksp;
XModifierKeymap *mmp; XModifierKeymap *mmp;
@ -1217,15 +1211,6 @@ void X11DRV_InitKeyboard( BYTE *key_state_table )
pKeyStateTable = key_state_table; pKeyStateTable = key_state_table;
wine_tsx11_lock(); wine_tsx11_lock();
#ifdef HAVE_XKB
is_xkb = XkbQueryExtension(display,
&xkb_opcode, &xkb_event, &xkb_error,
&xkb_major, &xkb_minor);
if (is_xkb) {
/* we have XKB, approximate Windows behaviour */
XkbSetDetectableAutoRepeat(display, True, NULL);
}
#endif
XDisplayKeycodes(display, &min_keycode, &max_keycode); XDisplayKeycodes(display, &min_keycode, &max_keycode);
ksp = XGetKeyboardMapping(display, min_keycode, ksp = XGetKeyboardMapping(display, min_keycode,
max_keycode + 1 - min_keycode, &keysyms_per_keycode); max_keycode + 1 - min_keycode, &keysyms_per_keycode);
@ -1291,7 +1276,7 @@ void X11DRV_InitKeyboard( BYTE *key_state_table )
if ((keysym<0x8000) && (keysym!=' ')) if ((keysym<0x8000) && (keysym!=' '))
{ {
#ifdef HAVE_XKB #ifdef HAVE_XKB
if (!is_xkb || !XkbTranslateKeySym(display, &keysym, 0, &ckey[i], 1, NULL)) if (!use_xkb || !XkbTranslateKeySym(display, &keysym, 0, &ckey[i], 1, NULL))
#endif #endif
{ {
/* FIXME: query what keysym is used as Mode_switch, fill XKeyEvent /* FIXME: query what keysym is used as Mode_switch, fill XKeyEvent

View File

@ -33,6 +33,9 @@
#endif #endif
#include <X11/cursorfont.h> #include <X11/cursorfont.h>
#include "ts_xlib.h" #include "ts_xlib.h"
#ifdef HAVE_XKB
#include <X11/XKBlib.h>
#endif
#include "winbase.h" #include "winbase.h"
#include "wine/winbase16.h" #include "wine/winbase16.h"
@ -59,6 +62,7 @@ unsigned int screen_depth;
Window root_window; Window root_window;
DWORD desktop_tid = 0; DWORD desktop_tid = 0;
int dxgrab, usedga, usexvidmode; int dxgrab, usedga, usexvidmode;
int use_xkb = 1;
int use_take_focus = 1; int use_take_focus = 1;
int managed_mode = 1; int managed_mode = 1;
int client_side_with_core = 1; int client_side_with_core = 1;
@ -318,6 +322,20 @@ static void process_attach(void)
} }
else screen_depth = DefaultDepthOfScreen( screen ); else screen_depth = DefaultDepthOfScreen( screen );
/* check for Xkb extension */
#ifdef HAVE_XKB
if (use_xkb)
{
int xkb_opcode, xkb_event, xkb_error;
int xkb_major = XkbMajorVersion, xkb_minor = XkbMinorVersion;
use_xkb = XkbQueryExtension(display, &xkb_opcode, &xkb_event, &xkb_error,
&xkb_major, &xkb_minor);
if (use_xkb) /* we have XKB, approximate Windows behaviour */
XkbSetDetectableAutoRepeat(display, True, NULL);
}
#endif
/* Initialize OpenGL */ /* Initialize OpenGL */
X11DRV_OpenGL_Init(display); X11DRV_OpenGL_Init(display);
@ -427,6 +445,10 @@ struct x11drv_thread_data *x11drv_init_thread_data(void)
if (!(data->xim = XOpenIM( data->display, NULL, NULL, NULL ))) if (!(data->xim = XOpenIM( data->display, NULL, NULL, NULL )))
WARN("Can't open input method\n"); WARN("Can't open input method\n");
#ifdef HAVE_XKB
if (use_xkb) XkbSetDetectableAutoRepeat( data->display, True, NULL );
#endif
if (synchronous) XSynchronize( data->display, True ); if (synchronous) XSynchronize( data->display, True );
wine_tsx11_unlock(); wine_tsx11_unlock();
if (wine_server_fd_to_handle( ConnectionNumber(data->display), GENERIC_READ | SYNCHRONIZE, if (wine_server_fd_to_handle( ConnectionNumber(data->display), GENERIC_READ | SYNCHRONIZE,

View File

@ -358,6 +358,7 @@ extern unsigned int screen_width;
extern unsigned int screen_height; extern unsigned int screen_height;
extern unsigned int screen_depth; extern unsigned int screen_depth;
extern unsigned int text_caps; extern unsigned int text_caps;
extern int use_xkb;
extern int use_take_focus; extern int use_take_focus;
extern int managed_mode; extern int managed_mode;