diff options
author | Carlos Garnacho <carlosg@gnome.org> | 2019-05-15 00:04:13 +0200 |
---|---|---|
committer | Carlos Garnacho <carlosg@gnome.org> | 2019-05-15 01:05:20 +0200 |
commit | 33642e22554b861134c1eb43ebfd719f34d09a1a (patch) | |
tree | 1b67ee6cab24a2b7ea276c09e07cded7ccd8046d /gdk/x11 | |
parent | c4446d36deafa431d53bfa4240e701cac2febaca (diff) | |
download | gtk+-33642e22554b861134c1eb43ebfd719f34d09a1a.tar.gz |
gdk/x11: Make XInput2 a mandatory runtime dependency for x11
Besides requiring it at build time, require that the server the client
is running against exposes the XInput2 protocol. We no longer fallback
on a device manager for core events.
Diffstat (limited to 'gdk/x11')
-rw-r--r-- | gdk/x11/gdkdevicemanager-x11.c | 42 | ||||
-rw-r--r-- | gdk/x11/gdkdrag-x11.c | 105 |
2 files changed, 45 insertions, 102 deletions
diff --git a/gdk/x11/gdkdevicemanager-x11.c b/gdk/x11/gdkdevicemanager-x11.c index 9a5312be23..dd62f27d08 100644 --- a/gdk/x11/gdkdevicemanager-x11.c +++ b/gdk/x11/gdkdevicemanager-x11.c @@ -63,11 +63,7 @@ _gdk_x11_device_manager_new (GdkDisplay *display) } } - GDK_DISPLAY_NOTE (display, INPUT, g_message ("Creating core device manager")); - - return g_object_new (GDK_TYPE_X11_DEVICE_MANAGER_CORE, - "display", display, - NULL); + g_error ("XInput2 support not found on display"); } /** @@ -84,26 +80,10 @@ GdkDevice * gdk_x11_device_manager_lookup (GdkX11DeviceManagerCore *device_manager, gint device_id) { - GdkDevice *device = NULL; - - g_return_val_if_fail (GDK_IS_X11_DEVICE_MANAGER_CORE (device_manager), NULL); - - if (GDK_IS_X11_DEVICE_MANAGER_XI2 (device_manager)) - device = _gdk_x11_device_manager_xi2_lookup (GDK_X11_DEVICE_MANAGER_XI2 (device_manager), - device_id); - else if (GDK_IS_X11_DEVICE_MANAGER_CORE (device_manager)) - { - /* It is a core/xi1 device manager, we only map - * IDs 2 and 3, matching XI2's Virtual Core Pointer - * and Keyboard. - */ - if (device_id == VIRTUAL_CORE_POINTER_ID) - device = GDK_X11_DEVICE_MANAGER_CORE (device_manager)->core_pointer; - else if (device_id == VIRTUAL_CORE_KEYBOARD_ID) - device = GDK_X11_DEVICE_MANAGER_CORE (device_manager)->core_keyboard; - } + g_return_val_if_fail (GDK_IS_X11_DEVICE_MANAGER_XI2 (device_manager), NULL); - return device; + return _gdk_x11_device_manager_xi2_lookup (GDK_X11_DEVICE_MANAGER_XI2 (device_manager), + device_id); } /** @@ -117,19 +97,7 @@ gdk_x11_device_manager_lookup (GdkX11DeviceManagerCore *device_manager, gint gdk_x11_device_get_id (GdkDevice *device) { - gint device_id = 0; - g_return_val_if_fail (GDK_IS_DEVICE (device), 0); - if (GDK_IS_X11_DEVICE_XI2 (device)) - device_id = _gdk_x11_device_xi2_get_id (GDK_X11_DEVICE_XI2 (device)); - else if (GDK_IS_X11_DEVICE_CORE (device)) - { - if (gdk_device_get_source (device) == GDK_SOURCE_KEYBOARD) - device_id = VIRTUAL_CORE_KEYBOARD_ID; - else - device_id = VIRTUAL_CORE_POINTER_ID; - } - - return device_id; + return _gdk_x11_device_xi2_get_id (GDK_X11_DEVICE_XI2 (device)); } diff --git a/gdk/x11/gdkdrag-x11.c b/gdk/x11/gdkdrag-x11.c index aacbbe6095..5196b552ba 100644 --- a/gdk/x11/gdkdrag-x11.c +++ b/gdk/x11/gdkdrag-x11.c @@ -1925,7 +1925,6 @@ static gboolean drag_grab (GdkDrag *drag) { GdkX11Drag *x11_drag = GDK_X11_DRAG (drag); - GdkDevice *device = gdk_drag_get_device (drag); GdkSeatCapabilities capabilities; GdkDisplay *display; Window root; @@ -1940,10 +1939,7 @@ drag_grab (GdkDrag *drag) root = GDK_DISPLAY_XROOTWIN (display); seat = gdk_device_get_seat (gdk_drag_get_device (drag)); - if (GDK_IS_X11_DEVICE_XI2 (device)) - capabilities = GDK_SEAT_CAPABILITY_ALL_POINTING; - else - capabilities = GDK_SEAT_CAPABILITY_ALL; + capabilities = GDK_SEAT_CAPABILITY_ALL_POINTING; cursor = gdk_drag_get_cursor (drag, x11_drag->current_action); g_set_object (&x11_drag->cursor, cursor); @@ -1959,50 +1955,38 @@ drag_grab (GdkDrag *drag) for (i = 0; i < G_N_ELEMENTS (grab_keys); ++i) { + gint deviceid = gdk_x11_device_get_id (gdk_seat_get_keyboard (seat)); + unsigned char mask[XIMaskLen(XI_LASTEVENT)]; + XIGrabModifiers mods; + XIEventMask evmask; + gint num_mods; + keycode = XKeysymToKeycode (GDK_DISPLAY_XDISPLAY (display), grab_keys[i].keysym); if (keycode == NoSymbol) continue; - if (GDK_IS_X11_DEVICE_XI2 (device)) - { - gint deviceid = gdk_x11_device_get_id (gdk_seat_get_keyboard (seat)); - unsigned char mask[XIMaskLen(XI_LASTEVENT)]; - XIGrabModifiers mods; - XIEventMask evmask; - gint num_mods; - - memset (mask, 0, sizeof (mask)); - XISetMask (mask, XI_KeyPress); - XISetMask (mask, XI_KeyRelease); - - evmask.deviceid = deviceid; - evmask.mask_len = sizeof (mask); - evmask.mask = mask; - - num_mods = 1; - mods.modifiers = grab_keys[i].modifiers; - - XIGrabKeycode (GDK_DISPLAY_XDISPLAY (display), - deviceid, - keycode, - root, - GrabModeAsync, - GrabModeAsync, - False, - &evmask, - num_mods, - &mods); - } - else - { - XGrabKey (GDK_DISPLAY_XDISPLAY (display), - keycode, grab_keys[i].modifiers, - root, - FALSE, - GrabModeAsync, - GrabModeAsync); - } + memset (mask, 0, sizeof (mask)); + XISetMask (mask, XI_KeyPress); + XISetMask (mask, XI_KeyRelease); + + evmask.deviceid = deviceid; + evmask.mask_len = sizeof (mask); + evmask.mask = mask; + + num_mods = 1; + mods.modifiers = grab_keys[i].modifiers; + + XIGrabKeycode (GDK_DISPLAY_XDISPLAY (display), + deviceid, + keycode, + root, + GrabModeAsync, + GrabModeAsync, + False, + &evmask, + num_mods, + &mods); } gdk_x11_display_error_trap_pop_ignored (display); @@ -2031,32 +2015,23 @@ drag_ungrab (GdkDrag *drag) for (i = 0; i < G_N_ELEMENTS (grab_keys); ++i) { + XIGrabModifiers mods; + gint num_mods; + keycode = XKeysymToKeycode (GDK_DISPLAY_XDISPLAY (display), grab_keys[i].keysym); if (keycode == NoSymbol) continue; - if (GDK_IS_X11_DEVICE_XI2 (keyboard)) - { - XIGrabModifiers mods; - gint num_mods; - - num_mods = 1; - mods.modifiers = grab_keys[i].modifiers; - - XIUngrabKeycode (GDK_DISPLAY_XDISPLAY (display), - gdk_x11_device_get_id (keyboard), - keycode, - root, - num_mods, - &mods); - } - else - { - XUngrabKey (GDK_DISPLAY_XDISPLAY (display), - keycode, grab_keys[i].modifiers, - root); - } + num_mods = 1; + mods.modifiers = grab_keys[i].modifiers; + + XIUngrabKeycode (GDK_DISPLAY_XDISPLAY (display), + gdk_x11_device_get_id (keyboard), + keycode, + root, + num_mods, + &mods); } } |