GTK3 and XINPUT_2
- From: "Joe Woodward" <jw terrafix co uk>
- To: gtk-list gnome org
- Subject: GTK3 and XINPUT_2
- Date: Thu, 03 May 2012 11:48:28 +0100
I'm running an embedded platform with GTK3 3.2.0 on a modern Xorg (1.12.0).
I have xvkbd (a virtual keyboard for X) and use xcalc to test it, and key presses on
xvkbd are seen on xcalc (as expected).
If I build GTK3 with "--disable-xinput" then key presses on the xvkbd are seen in any
GTK3 application.
However, if I build GTK3 without "--disable-xinput" (i.e. using XINPUT_2) key presses
on xvkbd are no longer seen in any GTK3 application.
The touchscreen works with and without "--disable-xinput" specified, and if I plug in a
USB keyboard then key-presses are seen in GTK3, so the XINPUT is working to some
extent.
So my question are:
- how do I go about debugging this?
- how should I implement a virtual keyboard for use with GTK3 and XINPUT_2 (I'm
assuming the X-calls performed by xvkbd are no longer sufficient)?
- what am I missing?!
Really, I'd like to move to 3.4 but I can't do that until I get an on-screen keyboard
working :)
Cheers,
Joe
For reference (with no USB keyboard plugged in):
# xinput list
? Virtual core pointer id=2 [master pointer (3)]
? ? Virtual core XTEST pointer id=4 [slave pointer (2)]
? ? Touchscreen id=6 [slave pointer (2)]
? Virtual core keyboard id=3 [master keyboard (2)]
? Virtual core XTEST keyboard id=5 [slave keyboard (3)]
? <default keyboard> id=7 [slave keyboard (3)]
And the following is a function I use to send key presses to an application's root
window (that works with "--disable-xinput", but fails without it):
/* Cribbed slightly from the sources for xvkbd (an X virtual keyboard).
*/
static void _SendAsXEvent (KeySym keySym, gint shift)
{
GdkWindow *gdkWindow;
Display *target_dpy;
Window cur_focus;
gint revert_to;
XKeyEvent event;
gint keycode, shiftKeycode;
/* Get the root window, and from this get the root X-display.
*/
gdkWindow = gdk_get_default_root_window ();
target_dpy = GDK_WINDOW_XDISPLAY (gdkWindow);
/* Get the input focus.
*/
XGetInputFocus (target_dpy, &cur_focus, &revert_to);
/* Set up the event.
*/
keycode = XKeysymToKeycode(target_dpy, keySym);
shiftKeycode = XKeysymToKeycode(target_dpy, XK_Shift_L);
event.display = target_dpy;
event.window = cur_focus;
event.root = RootWindow(event.display, DefaultScreen(event.display));
event.subwindow = None;
event.time = CurrentTime;
event.x = 1;
event.y = 1;
event.x_root = 1;
event.y_root = 1;
event.same_screen = TRUE;
event.state = 0;
/* Check if we should send a shift.
*/
if (shift) {
event.type = KeyPress;
event.keycode = shiftKeycode;
XSendEvent (event.display, event.window, TRUE, KeyPressMask, (XEvent *)&event);
event.state |= ShiftMask;
}
/* Send the press.
*/
event.type = KeyPress;
event.keycode = keycode;
XSendEvent (event.display, event.window, TRUE, KeyPressMask, (XEvent *)&event);
/* Send the release.
*/
event.type = KeyRelease;
event.keycode = keycode;
XSendEvent (event.display, event.window, TRUE, KeyPressMask, (XEvent *)&event);
/* Check if we should release the shift.
*/
if (shift) {
event.type = KeyRelease;
event.keycode = shiftKeycode;
XSendEvent (event.display, event.window, TRUE, KeyPressMask, (XEvent *)&event);
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]