Rikki,
Please try to apply the following patch against the new CVS version (on /dlls/x11drv directory). This patch will allow keyboard.c to use your locale setting by the usage of xkb extension on X11R6. Please notice that this requires that you *don't have* xkbdisable on your XF86Config file (or XF86Config-4).
-------- Original Message -------- Subject: dead keys treatment using XmbLookupString Date: Wed, 08 Jan 2003 12:48:06 -0200 From: Mauro Carvalho Chehab mchehab@brturbo.com To: wine-patches@winehq.com
*Modifyied files*: keyboard.c window.c desktop.c *CVS Version*: 20021225
*Change Log: *Add dead key support using XmbLookupString on ToUnicode function, if *xkb* is available otherwise It falls back to the old code. The first Window will be used to define the XIC used by the functions. *
Author*: Mauro Carvalho Chehab mchehab@brturbo.com ______________________________________________________________________________________________
--- keyboard.c 8 Jan 2003 11:24:51 -0000 1.1 +++ keyboard.c 8 Jan 2003 14:30:53 -0000 @@ -1389,6 +1389,44 @@ wine_tsx11_unlock(); }
+#ifdef HAVE_XKB +static XIM xim = (XIM) NULL; +static XIC xic = (XIC) NULL; +#endif +/******************************************************************* + * KeyboardWindow (X11DRV.@) + * Called from desktop.c and window.c after Window creating + * This routine allows usage of XmbLookupString by ToUnicode. + * Only the first opened window will be used. It means that + * all windows will share the same locale. + * + */ +void X11DRV_KeyboardWindow (Display *display, Window w) +{ +#ifdef HAVE_XKB + char *p; + + if (xic) return; /* Only the first window will be used */ + + if ((p = XSetLocaleModifiers("")) != NULL && *p) + xim = XOpenIM(display, NULL, NULL, NULL); + if (!xim && (p = XSetLocaleModifiers("@im=none")) != NULL && *p) + xim = XOpenIM(display, NULL, NULL, NULL); + if (!xim) ERR_(key)( "Failed to open input method.\n"); + else { + xic = XCreateIC(xim, + XNInputStyle, XIMPreeditNothing | XIMStatusNothing, + XNClientWindow, w, + XNFocusWindow, w, + NULL); + if (!xic) { + ERR_(key)( "Failed to create input context.\n"); + XCloseIM(xim); + xim=NULL; + } + } +#endif +}
/*********************************************************************** * X11DRV_MappingNotify @@ -1741,6 +1779,7 @@ * FIXME : should do the above (return 2 for non matching deadchar+char combinations) * */ + INT X11DRV_ToUnicode(UINT virtKey, UINT scanCode, LPBYTE lpKeyState, LPWSTR bufW, int bufW_size, UINT flags) { @@ -1756,6 +1795,9 @@ TRACE("Key UP, doing nothing\n" ); return 0; } + memset (&e,0,sizeof(e)); + + e.type = KeyPress; e.display = display; e.keycode = 0; e.state = 0; @@ -1814,7 +1856,15 @@ } else TRACE("Found keycode %d (0x%2X)\n",e.keycode,e.keycode);
- ret = XLookupString(&e, (LPVOID)lpChar, 2, &keysym, NULL); +#ifdef HAVE_XKB + if (xic) { + ret = XmbLookupString(xic,&e, (LPVOID)lpChar, sizeof(lpChar), &keysym, NULL); + } else { + ret = XLookupString(&e, (LPVOID)lpChar, sizeof(lpChar), &keysym, NULL); + } +#else + ret = XLookupString(&e, (LPVOID)lpChar, sizeof(lpChar), &keysym, NULL); +#endif wine_tsx11_unlock();
if (ret == 0) --- window.c 8 Jan 2003 11:24:51 -0000 1.1 +++ window.c 8 Jan 2003 14:30:53 -0000 @@ -43,6 +43,7 @@ WINE_DEFAULT_DEBUG_CHANNEL(x11drv);
extern Pixmap X11DRV_BITMAP_Pixmap( HBITMAP ); +extern X11DRV_KeyboardWindow (Display *display, Window w);
#define HAS_DLGFRAME(style,exStyle) \ (((exStyle) & WS_EX_DLGMODALFRAME) || \ @@ -199,6 +200,7 @@ CWEventMask | CWBitGravity | CWBackingStore | CWColormap, &attr ); XSaveContext( display, data->icon_window, winContext, (char *)win->hwndSelf ); wine_tsx11_unlock(); + if (data->client_window) X11DRV_KeyboardWindow (display, data->whole_window);
TRACE( "created %lx\n", data->icon_window ); SetPropA( win->hwndSelf, icon_window_atom, (HANDLE)data->icon_window ); @@ -686,6 +688,7 @@ wine_tsx11_unlock(); return 0; } + X11DRV_KeyboardWindow (display, data->whole_window);
/* non-maximized child must be at bottom of Z order */ if ((win->dwStyle & (WS_CHILD|WS_MAXIMIZE)) == WS_CHILD) @@ -732,6 +735,7 @@ CWEventMask | CWBitGravity | CWBackingStore, &attr ); if (data->client_window && is_client_window_mapped( win )) XMapWindow( display, data->client_window ); + if (data->client_window) X11DRV_KeyboardWindow (display, data->whole_window); wine_tsx11_unlock(); return data->client_window; } --- desktop.c 8 Jan 2003 11:24:51 -0000 1.1 +++ desktop.c 8 Jan 2003 14:30:53 -0000 @@ -30,6 +30,7 @@
WINE_DEFAULT_DEBUG_CHANNEL(x11drv);
+extern X11DRV_KeyboardWindow (Display *display, Window w);
/* desktop window procedure */ static LRESULT WINAPI desktop_winproc( HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam ) @@ -141,6 +142,8 @@ win = XCreateWindow( display, DefaultRootWindow(display), x, y, width, height, 0, screen_depth, InputOutput, visual, CWBackPixel | CWEventMask | CWCursor | CWColormap, &win_attr ); + + if (win) X11DRV_KeyboardWindow (display, win);
/* Set window manager properties */ size_hints = XAllocSizeHints();