From f3250172a44821ed4325f544f06ba4308ab03b68 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Tue, 14 May 2019 23:48:58 +0200 Subject: [PATCH] gdk/x11: Make XInput2 a mandatory build time dependency for x11 XInput2 is more than a decade old already, and the input improvements there (and in every other backend really) make it untenable to have support for X11 core input events dragging things behind. --- config.h.meson | 3 -- gdk/x11/gdkdevicemanager-core-x11.c | 6 ---- gdk/x11/gdkdevicemanager-x11.c | 46 +++++++++++------------------ gdk/x11/gdkdrag-x11.c | 6 ---- gdk/x11/gdkprivate-x11.h | 4 --- gdk/x11/gdksurface-x11.c | 12 ++------ meson.build | 25 ++++++++-------- 7 files changed, 33 insertions(+), 69 deletions(-) diff --git a/config.h.meson b/config.h.meson index a549f58ecc..436e1a1501 100644 --- a/config.h.meson +++ b/config.h.meson @@ -241,9 +241,6 @@ #endif -/* Define to 1 if XInput 2.0 is available */ -#mesondefine XINPUT_2 - /* Define to 1 if XInput 2.2 is available */ #mesondefine XINPUT_2_2 diff --git a/gdk/x11/gdkdevicemanager-core-x11.c b/gdk/x11/gdkdevicemanager-core-x11.c index ee7e369584..fb740286b5 100644 --- a/gdk/x11/gdkdevicemanager-core-x11.c +++ b/gdk/x11/gdkdevicemanager-core-x11.c @@ -769,10 +769,8 @@ _gdk_device_manager_core_handle_focus (GdkSurface *surface, if (toplevel->has_pointer && !x11_screen->wmspec_check_window && mode != NotifyGrab && -#ifdef XINPUT_2 mode != XINotifyPassiveGrab && mode != XINotifyPassiveUngrab && -#endif /* XINPUT_2 */ mode != NotifyUngrab) toplevel->has_pointer_focus = (focus_in) ? FALSE : TRUE; G_GNUC_FALLTHROUGH; @@ -780,10 +778,8 @@ _gdk_device_manager_core_handle_focus (GdkSurface *surface, case NotifyNonlinear: case NotifyNonlinearVirtual: if (mode != NotifyGrab && -#ifdef XINPUT_2 mode != XINotifyPassiveGrab && mode != XINotifyPassiveUngrab && -#endif /* XINPUT_2 */ mode != NotifyUngrab) toplevel->has_focus_window = (focus_in) ? TRUE : FALSE; /* We pretend that the focus moves to the grab @@ -800,10 +796,8 @@ _gdk_device_manager_core_handle_focus (GdkSurface *surface, */ if (!x11_screen->wmspec_check_window && mode != NotifyGrab && -#ifdef XINPUT_2 mode != XINotifyPassiveGrab && mode != XINotifyPassiveUngrab && -#endif /* XINPUT_2 */ mode != NotifyUngrab) toplevel->has_pointer_focus = (focus_in) ? TRUE : FALSE; break; diff --git a/gdk/x11/gdkdevicemanager-x11.c b/gdk/x11/gdkdevicemanager-x11.c index ada4724e70..68cd0a06bf 100644 --- a/gdk/x11/gdkdevicemanager-x11.c +++ b/gdk/x11/gdkdevicemanager-x11.c @@ -19,9 +19,7 @@ #include "gdkx11devicemanager-core.h" #include "gdkdevicemanagerprivate-core.h" -#ifdef XINPUT_2 #include "gdkx11devicemanager-xi2.h" -#endif #include "gdkinternals.h" #include "gdkprivate-x11.h" #include "gdkdisplay-x11.h" @@ -39,7 +37,6 @@ _gdk_x11_device_manager_new (GdkDisplay *display) { if (!g_getenv ("GDK_CORE_DEVICE_EVENTS")) { -#ifdef XINPUT_2 int opcode, firstevent, firsterror; Display *xdisplay; @@ -70,7 +67,6 @@ _gdk_x11_device_manager_new (GdkDisplay *display) return GDK_X11_DEVICE_MANAGER_CORE (device_manager_xi2); } } -#endif /* XINPUT_2 */ } GDK_DISPLAY_NOTE (display, INPUT, g_message ("Creating core device manager")); @@ -98,23 +94,20 @@ gdk_x11_device_manager_lookup (GdkX11DeviceManagerCore *device_manager, g_return_val_if_fail (GDK_IS_X11_DEVICE_MANAGER_CORE (device_manager), NULL); -#ifdef XINPUT_2 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 -#endif /* XINPUT_2 */ - 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; - } + 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; + } return device; } @@ -140,18 +133,15 @@ gdk_x11_device_get_id (GdkDevice *device) g_return_val_if_fail (GDK_IS_DEVICE (device), 0); -#ifdef XINPUT_2 if (GDK_IS_X11_DEVICE_XI2 (device)) device_id = _gdk_x11_device_xi2_get_id (GDK_X11_DEVICE_XI2 (device)); - else -#endif /* XINPUT_2 */ - 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; - } + 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; } diff --git a/gdk/x11/gdkdrag-x11.c b/gdk/x11/gdkdrag-x11.c index 43779168ff..aacbbe6095 100644 --- a/gdk/x11/gdkdrag-x11.c +++ b/gdk/x11/gdkdrag-x11.c @@ -1940,11 +1940,9 @@ drag_grab (GdkDrag *drag) root = GDK_DISPLAY_XROOTWIN (display); seat = gdk_device_get_seat (gdk_drag_get_device (drag)); -#ifdef XINPUT_2 if (GDK_IS_X11_DEVICE_XI2 (device)) capabilities = GDK_SEAT_CAPABILITY_ALL_POINTING; else -#endif capabilities = GDK_SEAT_CAPABILITY_ALL; cursor = gdk_drag_get_cursor (drag, x11_drag->current_action); @@ -1966,7 +1964,6 @@ drag_grab (GdkDrag *drag) if (keycode == NoSymbol) continue; -#ifdef XINPUT_2 if (GDK_IS_X11_DEVICE_XI2 (device)) { gint deviceid = gdk_x11_device_get_id (gdk_seat_get_keyboard (seat)); @@ -1998,7 +1995,6 @@ drag_grab (GdkDrag *drag) &mods); } else -#endif { XGrabKey (GDK_DISPLAY_XDISPLAY (display), keycode, grab_keys[i].modifiers, @@ -2040,7 +2036,6 @@ drag_ungrab (GdkDrag *drag) if (keycode == NoSymbol) continue; -#ifdef XINPUT_2 if (GDK_IS_X11_DEVICE_XI2 (keyboard)) { XIGrabModifiers mods; @@ -2057,7 +2052,6 @@ drag_ungrab (GdkDrag *drag) &mods); } else -#endif /* XINPUT_2 */ { XUngrabKey (GDK_DISPLAY_XDISPLAY (display), keycode, grab_keys[i].modifiers, diff --git a/gdk/x11/gdkprivate-x11.h b/gdk/x11/gdkprivate-x11.h index 813fa81e1c..2700dcbe56 100644 --- a/gdk/x11/gdkprivate-x11.h +++ b/gdk/x11/gdkprivate-x11.h @@ -37,9 +37,7 @@ #include #include -#ifdef XINPUT_2 #include -#endif #include @@ -134,7 +132,6 @@ void _gdk_x11_device_check_extension_events (GdkDevice *device); GdkX11DeviceManagerCore *_gdk_x11_device_manager_new (GdkDisplay *display); -#ifdef XINPUT_2 guchar * _gdk_x11_device_xi2_translate_event_mask (GdkX11DeviceManagerXI2 *device_manager_xi2, GdkEventMask event_mask, gint *len); @@ -164,7 +161,6 @@ gdouble gdk_x11_device_xi2_get_last_axis_value (GdkX11DeviceXI2 *device, void gdk_x11_device_xi2_store_axes (GdkX11DeviceXI2 *device, gdouble *axes, gint n_axes); -#endif GdkAtom _gdk_x11_display_manager_atom_intern (GdkDisplayManager *manager, const gchar *atom_name, diff --git a/gdk/x11/gdksurface-x11.c b/gdk/x11/gdksurface-x11.c index 9dfeb06703..530b80ff26 100644 --- a/gdk/x11/gdksurface-x11.c +++ b/gdk/x11/gdksurface-x11.c @@ -3690,27 +3690,21 @@ handle_wmspec_button_release (GdkDisplay *display, GdkX11Display *display_x11 = GDK_X11_DISPLAY (display); GdkSurface *surface; -#if defined (HAVE_XGENERICEVENTS) && defined (XINPUT_2) XIEvent *xiev = (XIEvent *) xevent->xcookie.data; XIDeviceEvent *xidev = (XIDeviceEvent *) xiev; if (xevent->xany.type == GenericEvent) surface = gdk_x11_surface_lookup_for_display (display, xidev->event); else -#endif surface = gdk_x11_surface_lookup_for_display (display, xevent->xany.window); if (display_x11->wm_moveresize_button != 0 && surface != NULL) { if ((xevent->xany.type == ButtonRelease && - xevent->xbutton.button == display_x11->wm_moveresize_button) -#if defined (HAVE_XGENERICEVENTS) && defined (XINPUT_2) - || + xevent->xbutton.button == display_x11->wm_moveresize_button) || (xevent->xany.type == GenericEvent && xiev->evtype == XI_ButtonRelease && - xidev->detail == display_x11->wm_moveresize_button) -#endif - ) + xidev->detail == display_x11->wm_moveresize_button)) { display_x11->wm_moveresize_button = 0; wmspec_send_message (display, surface, 0, 0, _NET_WM_MOVERESIZE_CANCEL, 0); @@ -4102,7 +4096,6 @@ _gdk_x11_moveresize_handle_event (const XEvent *event) } break; -#if defined (HAVE_XGENERICEVENTS) && defined (XINPUT_2) case GenericEvent: { /* we just assume this is an XI2 event */ @@ -4138,7 +4131,6 @@ _gdk_x11_moveresize_handle_event (const XEvent *event) } } break; -#endif default: break; diff --git a/meson.build b/meson.build index bbc5aaee31..2189ee8b61 100644 --- a/meson.build +++ b/meson.build @@ -542,18 +542,19 @@ if x11_enabled cdata.set('HAVE_XGENERICEVENTS', 1) endif - if xi_dep.found() and cc.has_header('X11/extensions/XInput2.h', dependencies: xi_dep) - cdata.set('XINPUT_2', 1) - # Note that we also check that the XIScrollClassInfo struct is defined, - # because at least Ubuntu Oneiric seems to have XIAllowTouchEvents(), - # but not the XIScrollClassInfo struct - has_allow_touch_evens = cc.has_function('XIAllowTouchEvents', dependencies: xi_dep) - has_scroll_class_info = cc.has_member('XIScrollClassInfo', 'number', dependencies: xi_dep, - prefix: '''#include - #include ''') - if has_allow_touch_evens and has_scroll_class_info - cdata.set('XINPUT_2_2', 1) - endif + if not xi_dep.found() or not cc.has_header('X11/extensions/XInput2.h', dependencies: xi_dep) + error('X11 backend enabled, but XInput2 not found.') + endif + + # Note that we also check that the XIScrollClassInfo struct is defined, + # because at least Ubuntu Oneiric seems to have XIAllowTouchEvents(), + # but not the XIScrollClassInfo struct + has_allow_touch_evens = cc.has_function('XIAllowTouchEvents', dependencies: xi_dep) + has_scroll_class_info = cc.has_member('XIScrollClassInfo', 'number', dependencies: xi_dep, + prefix: '''#include + #include ''') + if has_allow_touch_evens and has_scroll_class_info + cdata.set('XINPUT_2_2', 1) endif enable_xinerama = get_option('xinerama')