Subject: | XK_Alt_L should fall back to XK_Meta_L |
Hello,
Xvfb lacks XK_Alt_L keycode, so pressing ALT-something (e.g.
SendKeys($win, '%(h)a') for Help->About) simply does not work --
XKeysymToKeycode(display, XK_Meta_L) returns 0.
(Xvfb is a virtual X server that comes with XFree86 and XOrg; it can run
on machines with no display hardware and no physical input devices, thus
being a good choice for automated GUI testing.)
The following patch implements fallback to XK_Meta_L:
--- X11-GUITest-0.20/GUITest.xs- 2004-01-16 23:41:42 +0000
+++ X11-GUITest-0.20/GUITest.xs 2005-07-13 01:35:14 +0000
@@ -213,6 +213,15 @@
return( GetKeySym(key, sym) );
}
+/* Xvfb lacks XK_Alt_L; fall back to XK_Meta_L */
+#define XKeysymToKeycode(display, sym) \
+({ Display *d = (display); KeySym s = (sym); \
+ KeyCode kc = (XKeysymToKeycode)(d, s); \
+ if (kc == 0 && s == XK_Alt_L) \
+ kc = (XKeysymToKeycode)(d, XK_Meta_L); \
+ kc; \
+})
+
/* Function: PressKeyImp
* Description: Presses the key for the specified keysym. Lower-level
* implementation.
End of patch
It simply wraps XKeysymToKeycode() function into a macro.
(This syntax is GCC extension; it works fine for me now, though.)
--
Alexey Tourbin
ALT Linux Team