On Tue, May 29, 2012 at 04:59:17PM +0100, Thomas Adam wrote:
> Hi,
> 
> Recent version of Xorg have deprecated XKeycodeToKeysym() in favour of
> XkbKeycodeToKeysym() as per:
> 
> https://bugs.freedesktop.org/show_bug.cgi?id=25732
> 
> The attach patch converts the original calls to XKeycodeToKeysym() over, but
> only where X11/XKBlib.h is present.
> 
> Please test this.  I'll give it a week or so before I commit it, as I
> consider this a fundamental change.
> 
> Any questions, do please ask.

Here's V2, fixing a slight mistake in terms of leader-key, which masked
synthetic events from being filtered correctly for key-events.

-- Thomas Adam
? allCommands.html
? commands
? fvwm-2.6.5.tar.bz2
? fvwm-2.6.5.tar.gz
? fvwm-log
? groupedCommands.html
? images
? index.html
? modules.html
? style.css
? fvwm/fvwm.man.html
? modules/FvwmTabs.html
? modules/images
? modules/todo.html
Index: configure.ac
===================================================================
RCS file: /home/cvs/fvwm/fvwm/configure.ac,v
retrieving revision 1.66.2.12
diff -u -r1.66.2.12 configure.ac
--- configure.ac	20 Apr 2012 11:14:00 -0000	1.66.2.12
+++ configure.ac	30 May 2012 08:14:59 -0000
@@ -537,7 +537,11 @@
                [$X_LIBS $X_PRE_LIBS -lX11 $X_EXTRA_LIBS])
 fi
 
-# ********* xinerama
+# Silently look for X11/XKBlib.h
+AH_TEMPLATE([HAVE_X11_XKBLIB_H],[Define if Xkb extension is used.])
+AC_CHECK_HEADER(X11/XKBlib.h, AC_DEFINE(HAVE_X11_XKBLIB_H))
+
+# ********* xineramA
 problem_xinerama=""
 
 AC_ARG_ENABLE(xinerama,
@@ -1657,6 +1661,14 @@
 #define fvwm_lstat(x,y) -1
 #endif
 
+#ifdef HAVE_X11_XKBLIB_H
+#include <X11/XKBlib.h>
+#define fvwm_KeycodeToKeysym(d, k, g, l) \
+	(XkbKeycodeToKeysym((d), (k), (g), (l)))
+#else
+#define fvwm_KeycodeToKeysym(d, k, i, x) (XKeycodeToKeysym((d), (k), (i)))
+#endif
+
 ])
 
 # mainly for fvwm-config
Index: fvwm/builtins.c
===================================================================
RCS file: /home/cvs/fvwm/fvwm/fvwm/builtins.c,v
retrieving revision 1.440.2.2
diff -u -r1.440.2.2 builtins.c
--- fvwm/builtins.c	26 Dec 2011 00:54:07 -0000	1.440.2.2
+++ fvwm/builtins.c	30 May 2012 08:14:59 -0000
@@ -3853,7 +3853,7 @@
 
 	for (m = 0; m <= 8; ++m)
 	{
-		KeySym ks = XKeycodeToKeysym(dpy, *keycode, m);
+		KeySym ks = fvwm_KeycodeToKeysym(dpy, *keycode, m, 0);
 		if (ks == keysym)
 		{
 			switch (m)
Index: fvwm/events.c
===================================================================
RCS file: /home/cvs/fvwm/fvwm/fvwm/events.c,v
retrieving revision 1.569.2.3
diff -u -r1.569.2.3 events.c
--- fvwm/events.c	17 Mar 2012 23:52:53 -0000	1.569.2.3
+++ fvwm/events.c	30 May 2012 08:14:59 -0000
@@ -2508,7 +2508,7 @@
 	/* Here's a real hack - some systems have two keys with the
 	 * same keysym and different keycodes. This converts all
 	 * the cases to one keycode. */
-	kc = XKeysymToKeycode(dpy, XKeycodeToKeysym(dpy, te->xkey.keycode, 0));
+	kc = XKeysymToKeycode(dpy, fvwm_KeycodeToKeysym(dpy, te->xkey.keycode, 0, 0));
 
 	/* Check if there is something bound to the key */
 
Index: libs/Bindings.c
===================================================================
RCS file: /home/cvs/fvwm/fvwm/libs/Bindings.c,v
retrieving revision 1.69
diff -u -r1.69 Bindings.c
--- libs/Bindings.c	7 Aug 2007 20:17:43 -0000	1.69
+++ libs/Bindings.c	30 May 2012 08:14:59 -0000
@@ -181,7 +181,7 @@
 		{
 			if (BIND_IS_MOUSE_BINDING(type) ||
 			    STROKE_CODE(BIND_IS_STROKE_BINDING(type) ||)
-			    (tkeysym = XKeycodeToKeysym(dpy, i, m)) == keysym)
+			    (tkeysym = fvwm_KeycodeToKeysym(dpy, i, m, 0)) == keysym)
 			{
 				unsigned int add_modifiers = 0;
 				unsigned int bind_mask = 1;
Index: modules/FvwmIconBox/FvwmIconBox.c
===================================================================
RCS file: /home/cvs/fvwm/fvwm/modules/FvwmIconBox/FvwmIconBox.c,v
retrieving revision 1.104.4.1
diff -u -r1.104.4.1 FvwmIconBox.c
--- modules/FvwmIconBox/FvwmIconBox.c	6 Aug 2011 22:47:27 -0000	1.104.4.1
+++ modules/FvwmIconBox/FvwmIconBox.c	30 May 2012 08:14:59 -0000
@@ -2445,7 +2445,7 @@
 
   XDisplayKeycodes(dpy, &kmin, &kmax);
   for (i=kmin; i<=kmax; i++)
-    if (XKeycodeToKeysym(dpy, i, 0) == keysym)
+    if (fvwm_KeycodeToKeysym(dpy, i, 0, 0) == keysym)
       {
 	k = (struct keyfunc *)safemalloc(sizeof(struct keyfunc));
 	memset(k, 0, sizeof(struct keyfunc));
@@ -3421,7 +3421,7 @@
 
   tmp = KeyActions;
   event.xkey.keycode =
-    XKeysymToKeycode(dpy,XKeycodeToKeysym(dpy,event.xkey.keycode,0));
+    XKeysymToKeycode(dpy,fvwm_KeycodeToKeysym(dpy,event.xkey.keycode,0,0));
   while (tmp != NULL){
     if (tmp->keycode == event.xkey.keycode){
       MySendFvwmPipe(fd, tmp->action, item->id);
Index: modules/FvwmIconMan/readconfig.c
===================================================================
RCS file: /home/cvs/fvwm/fvwm/modules/FvwmIconMan/readconfig.c,v
retrieving revision 1.67.4.1
diff -u -r1.67.4.1 readconfig.c
--- modules/FvwmIconMan/readconfig.c	6 Aug 2011 22:47:27 -0000	1.67.4.1
+++ modules/FvwmIconMan/readconfig.c	30 May 2012 08:14:59 -0000
@@ -753,7 +753,7 @@
 
   XDisplayKeycodes(theDisplay, &min, &max);
   for (i=min; i<=max; i++) {
-    if (XKeycodeToKeysym(theDisplay, i, 0) == keysym) {
+    if (fvwm_KeycodeToKeysym(theDisplay, i, 0, 0) == keysym) {
       if (!func) {
 	func = parse_function_list(action);
 	if (!func) {
Index: modules/FvwmIconMan/x.c
===================================================================
RCS file: /home/cvs/fvwm/fvwm/modules/FvwmIconMan/x.c,v
retrieving revision 1.82
diff -u -r1.82 x.c
--- modules/FvwmIconMan/x.c	28 Jan 2007 15:29:26 -0000	1.82
+++ modules/FvwmIconMan/x.c	30 May 2012 08:14:59 -0000
@@ -245,8 +245,8 @@
        * the cases to one keycode. */
       theEvent.xkey.keycode =
 	XKeysymToKeycode (theDisplay,
-			  XKeycodeToKeysym(theDisplay,
-					   theEvent.xkey.keycode,0));
+			  fvwm_KeycodeToKeysym(theDisplay,
+					   theEvent.xkey.keycode,0,0));
       modifier = (theEvent.xkey.state & MODS_USED);
       ConsoleDebug (X11, "\tKeyPress: %d\n", theEvent.xkey.keycode);
 
Index: modules/FvwmScript/FvwmScript.c
===================================================================
RCS file: /home/cvs/fvwm/fvwm/modules/FvwmScript/FvwmScript.c,v
retrieving revision 1.77.4.1
diff -u -r1.77.4.1 FvwmScript.c
--- modules/FvwmScript/FvwmScript.c	6 Aug 2011 22:47:27 -0000	1.77.4.1
+++ modules/FvwmScript/FvwmScript.c	30 May 2012 08:14:59 -0000
@@ -973,7 +973,7 @@
       find = False;
       XLookupString(&event.xkey, (char *)buf, sizeof(buf), &ks, NULL);
       event.xkey.keycode =
-	XKeysymToKeycode(dpy,XKeycodeToKeysym(dpy,event.xkey.keycode,0));
+	XKeysymToKeycode(dpy,fvwm_KeycodeToKeysym(dpy,event.xkey.keycode,0,0));
 
       /* check for bindings defined by the Key instruction */
 	  tmp.res_class = tmp.res_name = "root";
@@ -1452,7 +1452,7 @@
   /* Compute the Shift-Tab keysym */
   {
     KeyCode tab = XKeysymToKeycode(dpy, XK_Tab);
-    shift_tab_ks = XKeycodeToKeysym(dpy, tab, ShiftMask);
+    shift_tab_ks = fvwm_KeycodeToKeysym(dpy, tab, ShiftMask, 0);
   }
 
   /* Construction des boutons et de la fenetre */

Reply via email to