<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title></title>
</head>
<body>
<b>Modifyied files</b>: keyboard.c window.c desktop.c<br>
<b>CVS Version</b>: 20021225<br>
<br>
<b>Change Log:<br>
</b>Add dead key support using XmbLookupString on ToUnicode function,
if <b>xkb</b> is available otherwise It falls back<br>
to the old code.<br>
The first Window will be used to define the XIC used by the functions.<br>
<b><br>
<br>
Author</b>: Mauro Carvalho Chehab <a class="moz-txt-link-rfc2396E" href="mailto:mchehab@brturbo.com"><mchehab@brturbo.com></a> <br>
______________________________________________________________________________________________<br>
<br>
<br>
--- keyboard.c 8 Jan 2003 11:24:51 -0000 1.1<br>
+++ keyboard.c 8 Jan 2003 14:30:53 -0000<br>
@@ -1389,6 +1389,44 @@<br>
wine_tsx11_unlock();<br>
}<br>
<br>
+#ifdef HAVE_XKB<br>
+static XIM xim = (XIM) NULL;<br>
+static XIC xic = (XIC) NULL;<br>
+#endif<br>
+/*******************************************************************<br>
+ * KeyboardWindow (X11DRV.@)<br>
+ * Called from desktop.c and window.c after Window creating<br>
+ * This routine allows usage of XmbLookupString by ToUnicode.<br>
+ * Only the first opened window will be used. It means that<br>
+ * all windows will share the same locale.<br>
+ *<br>
+ */<br>
+void X11DRV_KeyboardWindow (Display *display, Window w)<br>
+{<br>
+#ifdef HAVE_XKB<br>
+ char *p;<br>
+<br>
+ if (xic) return; /* Only the first window will be used */<br>
+<br>
+ if ((p = XSetLocaleModifiers("")) != NULL && *p)<br>
+ xim = XOpenIM(display, NULL, NULL, NULL);<br>
+ if (!xim && (p = XSetLocaleModifiers("@im=none")) != NULL &&
*p)<br>
+ xim = XOpenIM(display, NULL, NULL, NULL);<br>
+ if (!xim) ERR_(key)( "Failed to open input method.\n");<br>
+ else {<br>
+ xic = XCreateIC(xim,<br>
+ XNInputStyle, XIMPreeditNothing | XIMStatusNothing,<br>
+ XNClientWindow, w,<br>
+ XNFocusWindow, w,<br>
+ NULL);<br>
+ if (!xic) {<br>
+ ERR_(key)( "Failed to create input context.\n");<br>
+ XCloseIM(xim);<br>
+ xim=NULL;<br>
+ }<br>
+ }<br>
+#endif<br>
+}<br>
<br>
/***********************************************************************<br>
* X11DRV_MappingNotify<br>
@@ -1741,6 +1779,7 @@<br>
* FIXME : should do the above (return 2 for non matching deadchar+char
combinations)<br>
*<br>
*/<br>
+<br>
INT X11DRV_ToUnicode(UINT virtKey, UINT scanCode, LPBYTE lpKeyState,<br>
LPWSTR bufW, int bufW_size, UINT flags)<br>
{<br>
@@ -1756,6 +1795,9 @@<br>
TRACE("Key UP, doing nothing\n" );<br>
return 0;<br>
}<br>
+ memset (&e,0,sizeof(e));<br>
+<br>
+ e.type = KeyPress;<br>
e.display = display;<br>
e.keycode = 0;<br>
e.state = 0;<br>
@@ -1814,7 +1856,15 @@<br>
}<br>
else TRACE("Found keycode %d (0x%2X)\n",e.keycode,e.keycode);<br>
<br>
- ret = XLookupString(&e, (LPVOID)lpChar, 2, &keysym, NULL);<br>
+#ifdef HAVE_XKB<br>
+ if (xic) {<br>
+ ret = XmbLookupString(xic,&e, (LPVOID)lpChar, sizeof(lpChar),
&keysym, NULL);<br>
+ } else {<br>
+ ret = XLookupString(&e, (LPVOID)lpChar, sizeof(lpChar), &keysym,
NULL);<br>
+ }<br>
+#else<br>
+ ret = XLookupString(&e, (LPVOID)lpChar, sizeof(lpChar), &keysym,
NULL);<br>
+#endif<br>
wine_tsx11_unlock();<br>
<br>
if (ret == 0)<br>
--- window.c 8 Jan 2003 11:24:51 -0000 1.1<br>
+++ window.c 8 Jan 2003 14:30:53 -0000<br>
@@ -43,6 +43,7 @@<br>
WINE_DEFAULT_DEBUG_CHANNEL(x11drv);<br>
<br>
extern Pixmap X11DRV_BITMAP_Pixmap( HBITMAP );<br>
+extern X11DRV_KeyboardWindow (Display *display, Window w);<br>
<br>
#define HAS_DLGFRAME(style,exStyle) \<br>
(((exStyle) & WS_EX_DLGMODALFRAME) || \<br>
@@ -199,6 +200,7 @@<br>
CWEventMask | CWBitGravity | CWBackingStore
| CWColormap, &attr );<br>
XSaveContext( display, data->icon_window, winContext, (char *)win->hwndSelf
);<br>
wine_tsx11_unlock();<br>
+ if (data->client_window) X11DRV_KeyboardWindow (display, data->whole_window);<br>
<br>
TRACE( "created %lx\n", data->icon_window );<br>
SetPropA( win->hwndSelf, icon_window_atom, (HANDLE)data->icon_window
);<br>
@@ -686,6 +688,7 @@<br>
wine_tsx11_unlock();<br>
return 0;<br>
}<br>
+ X11DRV_KeyboardWindow (display, data->whole_window);<br>
<br>
/* non-maximized child must be at bottom of Z order */<br>
if ((win->dwStyle & (WS_CHILD|WS_MAXIMIZE)) == WS_CHILD)<br>
@@ -732,6 +735,7 @@<br>
CWEventMask | CWBitGravity | CWBackingStore,
&attr );<br>
if (data->client_window && is_client_window_mapped( win ))<br>
XMapWindow( display, data->client_window );<br>
+ if (data->client_window) X11DRV_KeyboardWindow (display, data->whole_window);<br>
wine_tsx11_unlock();<br>
return data->client_window;<br>
}<br>
--- desktop.c 8 Jan 2003 11:24:51 -0000 1.1<br>
+++ desktop.c 8 Jan 2003 14:30:53 -0000<br>
@@ -30,6 +30,7 @@<br>
<br>
WINE_DEFAULT_DEBUG_CHANNEL(x11drv);<br>
<br>
+extern X11DRV_KeyboardWindow (Display *display, Window w);<br>
<br>
/* desktop window procedure */<br>
static LRESULT WINAPI desktop_winproc( HWND hwnd, UINT message, WPARAM wParam,
LPARAM lParam )<br>
@@ -141,6 +142,8 @@<br>
win = XCreateWindow( display, DefaultRootWindow(display),<br>
x, y, width, height, 0, screen_depth, InputOutput,
visual,<br>
CWBackPixel | CWEventMask | CWCursor | CWColormap,
&win_attr );<br>
+<br>
+ if (win) X11DRV_KeyboardWindow (display, win);<br>
<br>
/* Set window manager properties */<br>
size_hints = XAllocSizeHints();<br>
<br>
</body>
</html>