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.
This commit is contained in:
Carlos Garnacho 2019-05-14 23:48:58 +02:00
parent 599806ca82
commit f3250172a4
7 changed files with 33 additions and 69 deletions

View File

@ -241,9 +241,6 @@
#endif #endif
/* Define to 1 if XInput 2.0 is available */
#mesondefine XINPUT_2
/* Define to 1 if XInput 2.2 is available */ /* Define to 1 if XInput 2.2 is available */
#mesondefine XINPUT_2_2 #mesondefine XINPUT_2_2

View File

@ -769,10 +769,8 @@ _gdk_device_manager_core_handle_focus (GdkSurface *surface,
if (toplevel->has_pointer && if (toplevel->has_pointer &&
!x11_screen->wmspec_check_window && !x11_screen->wmspec_check_window &&
mode != NotifyGrab && mode != NotifyGrab &&
#ifdef XINPUT_2
mode != XINotifyPassiveGrab && mode != XINotifyPassiveGrab &&
mode != XINotifyPassiveUngrab && mode != XINotifyPassiveUngrab &&
#endif /* XINPUT_2 */
mode != NotifyUngrab) mode != NotifyUngrab)
toplevel->has_pointer_focus = (focus_in) ? FALSE : TRUE; toplevel->has_pointer_focus = (focus_in) ? FALSE : TRUE;
G_GNUC_FALLTHROUGH; G_GNUC_FALLTHROUGH;
@ -780,10 +778,8 @@ _gdk_device_manager_core_handle_focus (GdkSurface *surface,
case NotifyNonlinear: case NotifyNonlinear:
case NotifyNonlinearVirtual: case NotifyNonlinearVirtual:
if (mode != NotifyGrab && if (mode != NotifyGrab &&
#ifdef XINPUT_2
mode != XINotifyPassiveGrab && mode != XINotifyPassiveGrab &&
mode != XINotifyPassiveUngrab && mode != XINotifyPassiveUngrab &&
#endif /* XINPUT_2 */
mode != NotifyUngrab) mode != NotifyUngrab)
toplevel->has_focus_window = (focus_in) ? TRUE : FALSE; toplevel->has_focus_window = (focus_in) ? TRUE : FALSE;
/* We pretend that the focus moves to the grab /* 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 && if (!x11_screen->wmspec_check_window &&
mode != NotifyGrab && mode != NotifyGrab &&
#ifdef XINPUT_2
mode != XINotifyPassiveGrab && mode != XINotifyPassiveGrab &&
mode != XINotifyPassiveUngrab && mode != XINotifyPassiveUngrab &&
#endif /* XINPUT_2 */
mode != NotifyUngrab) mode != NotifyUngrab)
toplevel->has_pointer_focus = (focus_in) ? TRUE : FALSE; toplevel->has_pointer_focus = (focus_in) ? TRUE : FALSE;
break; break;

View File

@ -19,9 +19,7 @@
#include "gdkx11devicemanager-core.h" #include "gdkx11devicemanager-core.h"
#include "gdkdevicemanagerprivate-core.h" #include "gdkdevicemanagerprivate-core.h"
#ifdef XINPUT_2
#include "gdkx11devicemanager-xi2.h" #include "gdkx11devicemanager-xi2.h"
#endif
#include "gdkinternals.h" #include "gdkinternals.h"
#include "gdkprivate-x11.h" #include "gdkprivate-x11.h"
#include "gdkdisplay-x11.h" #include "gdkdisplay-x11.h"
@ -39,7 +37,6 @@ _gdk_x11_device_manager_new (GdkDisplay *display)
{ {
if (!g_getenv ("GDK_CORE_DEVICE_EVENTS")) if (!g_getenv ("GDK_CORE_DEVICE_EVENTS"))
{ {
#ifdef XINPUT_2
int opcode, firstevent, firsterror; int opcode, firstevent, firsterror;
Display *xdisplay; Display *xdisplay;
@ -70,7 +67,6 @@ _gdk_x11_device_manager_new (GdkDisplay *display)
return GDK_X11_DEVICE_MANAGER_CORE (device_manager_xi2); return GDK_X11_DEVICE_MANAGER_CORE (device_manager_xi2);
} }
} }
#endif /* XINPUT_2 */
} }
GDK_DISPLAY_NOTE (display, INPUT, g_message ("Creating core device manager")); GDK_DISPLAY_NOTE (display, INPUT, g_message ("Creating core device manager"));
@ -98,13 +94,10 @@ gdk_x11_device_manager_lookup (GdkX11DeviceManagerCore *device_manager,
g_return_val_if_fail (GDK_IS_X11_DEVICE_MANAGER_CORE (device_manager), NULL); 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)) if (GDK_IS_X11_DEVICE_MANAGER_XI2 (device_manager))
device = _gdk_x11_device_manager_xi2_lookup (GDK_X11_DEVICE_MANAGER_XI2 (device_manager), device = _gdk_x11_device_manager_xi2_lookup (GDK_X11_DEVICE_MANAGER_XI2 (device_manager),
device_id); device_id);
else else if (GDK_IS_X11_DEVICE_MANAGER_CORE (device_manager))
#endif /* XINPUT_2 */
if (GDK_IS_X11_DEVICE_MANAGER_CORE (device_manager))
{ {
/* It is a core/xi1 device manager, we only map /* It is a core/xi1 device manager, we only map
* IDs 2 and 3, matching XI2's Virtual Core Pointer * IDs 2 and 3, matching XI2's Virtual Core Pointer
@ -140,12 +133,9 @@ gdk_x11_device_get_id (GdkDevice *device)
g_return_val_if_fail (GDK_IS_DEVICE (device), 0); g_return_val_if_fail (GDK_IS_DEVICE (device), 0);
#ifdef XINPUT_2
if (GDK_IS_X11_DEVICE_XI2 (device)) if (GDK_IS_X11_DEVICE_XI2 (device))
device_id = _gdk_x11_device_xi2_get_id (GDK_X11_DEVICE_XI2 (device)); device_id = _gdk_x11_device_xi2_get_id (GDK_X11_DEVICE_XI2 (device));
else else if (GDK_IS_X11_DEVICE_CORE (device))
#endif /* XINPUT_2 */
if (GDK_IS_X11_DEVICE_CORE (device))
{ {
if (gdk_device_get_source (device) == GDK_SOURCE_KEYBOARD) if (gdk_device_get_source (device) == GDK_SOURCE_KEYBOARD)
device_id = VIRTUAL_CORE_KEYBOARD_ID; device_id = VIRTUAL_CORE_KEYBOARD_ID;

View File

@ -1940,11 +1940,9 @@ drag_grab (GdkDrag *drag)
root = GDK_DISPLAY_XROOTWIN (display); root = GDK_DISPLAY_XROOTWIN (display);
seat = gdk_device_get_seat (gdk_drag_get_device (drag)); seat = gdk_device_get_seat (gdk_drag_get_device (drag));
#ifdef XINPUT_2
if (GDK_IS_X11_DEVICE_XI2 (device)) if (GDK_IS_X11_DEVICE_XI2 (device))
capabilities = GDK_SEAT_CAPABILITY_ALL_POINTING; capabilities = GDK_SEAT_CAPABILITY_ALL_POINTING;
else else
#endif
capabilities = GDK_SEAT_CAPABILITY_ALL; capabilities = GDK_SEAT_CAPABILITY_ALL;
cursor = gdk_drag_get_cursor (drag, x11_drag->current_action); cursor = gdk_drag_get_cursor (drag, x11_drag->current_action);
@ -1966,7 +1964,6 @@ drag_grab (GdkDrag *drag)
if (keycode == NoSymbol) if (keycode == NoSymbol)
continue; continue;
#ifdef XINPUT_2
if (GDK_IS_X11_DEVICE_XI2 (device)) if (GDK_IS_X11_DEVICE_XI2 (device))
{ {
gint deviceid = gdk_x11_device_get_id (gdk_seat_get_keyboard (seat)); gint deviceid = gdk_x11_device_get_id (gdk_seat_get_keyboard (seat));
@ -1998,7 +1995,6 @@ drag_grab (GdkDrag *drag)
&mods); &mods);
} }
else else
#endif
{ {
XGrabKey (GDK_DISPLAY_XDISPLAY (display), XGrabKey (GDK_DISPLAY_XDISPLAY (display),
keycode, grab_keys[i].modifiers, keycode, grab_keys[i].modifiers,
@ -2040,7 +2036,6 @@ drag_ungrab (GdkDrag *drag)
if (keycode == NoSymbol) if (keycode == NoSymbol)
continue; continue;
#ifdef XINPUT_2
if (GDK_IS_X11_DEVICE_XI2 (keyboard)) if (GDK_IS_X11_DEVICE_XI2 (keyboard))
{ {
XIGrabModifiers mods; XIGrabModifiers mods;
@ -2057,7 +2052,6 @@ drag_ungrab (GdkDrag *drag)
&mods); &mods);
} }
else else
#endif /* XINPUT_2 */
{ {
XUngrabKey (GDK_DISPLAY_XDISPLAY (display), XUngrabKey (GDK_DISPLAY_XDISPLAY (display),
keycode, grab_keys[i].modifiers, keycode, grab_keys[i].modifiers,

View File

@ -37,9 +37,7 @@
#include <X11/Xlib.h> #include <X11/Xlib.h>
#include <X11/Xutil.h> #include <X11/Xutil.h>
#ifdef XINPUT_2
#include <X11/extensions/XInput2.h> #include <X11/extensions/XInput2.h>
#endif
#include <cairo-xlib.h> #include <cairo-xlib.h>
@ -134,7 +132,6 @@ void _gdk_x11_device_check_extension_events (GdkDevice *device);
GdkX11DeviceManagerCore *_gdk_x11_device_manager_new (GdkDisplay *display); GdkX11DeviceManagerCore *_gdk_x11_device_manager_new (GdkDisplay *display);
#ifdef XINPUT_2
guchar * _gdk_x11_device_xi2_translate_event_mask (GdkX11DeviceManagerXI2 *device_manager_xi2, guchar * _gdk_x11_device_xi2_translate_event_mask (GdkX11DeviceManagerXI2 *device_manager_xi2,
GdkEventMask event_mask, GdkEventMask event_mask,
gint *len); 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, void gdk_x11_device_xi2_store_axes (GdkX11DeviceXI2 *device,
gdouble *axes, gdouble *axes,
gint n_axes); gint n_axes);
#endif
GdkAtom _gdk_x11_display_manager_atom_intern (GdkDisplayManager *manager, GdkAtom _gdk_x11_display_manager_atom_intern (GdkDisplayManager *manager,
const gchar *atom_name, const gchar *atom_name,

View File

@ -3690,27 +3690,21 @@ handle_wmspec_button_release (GdkDisplay *display,
GdkX11Display *display_x11 = GDK_X11_DISPLAY (display); GdkX11Display *display_x11 = GDK_X11_DISPLAY (display);
GdkSurface *surface; GdkSurface *surface;
#if defined (HAVE_XGENERICEVENTS) && defined (XINPUT_2)
XIEvent *xiev = (XIEvent *) xevent->xcookie.data; XIEvent *xiev = (XIEvent *) xevent->xcookie.data;
XIDeviceEvent *xidev = (XIDeviceEvent *) xiev; XIDeviceEvent *xidev = (XIDeviceEvent *) xiev;
if (xevent->xany.type == GenericEvent) if (xevent->xany.type == GenericEvent)
surface = gdk_x11_surface_lookup_for_display (display, xidev->event); surface = gdk_x11_surface_lookup_for_display (display, xidev->event);
else else
#endif
surface = gdk_x11_surface_lookup_for_display (display, xevent->xany.window); surface = gdk_x11_surface_lookup_for_display (display, xevent->xany.window);
if (display_x11->wm_moveresize_button != 0 && surface != NULL) if (display_x11->wm_moveresize_button != 0 && surface != NULL)
{ {
if ((xevent->xany.type == ButtonRelease && if ((xevent->xany.type == ButtonRelease &&
xevent->xbutton.button == display_x11->wm_moveresize_button) xevent->xbutton.button == display_x11->wm_moveresize_button) ||
#if defined (HAVE_XGENERICEVENTS) && defined (XINPUT_2)
||
(xevent->xany.type == GenericEvent && (xevent->xany.type == GenericEvent &&
xiev->evtype == XI_ButtonRelease && xiev->evtype == XI_ButtonRelease &&
xidev->detail == display_x11->wm_moveresize_button) xidev->detail == display_x11->wm_moveresize_button))
#endif
)
{ {
display_x11->wm_moveresize_button = 0; display_x11->wm_moveresize_button = 0;
wmspec_send_message (display, surface, 0, 0, _NET_WM_MOVERESIZE_CANCEL, 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; break;
#if defined (HAVE_XGENERICEVENTS) && defined (XINPUT_2)
case GenericEvent: case GenericEvent:
{ {
/* we just assume this is an XI2 event */ /* we just assume this is an XI2 event */
@ -4138,7 +4131,6 @@ _gdk_x11_moveresize_handle_event (const XEvent *event)
} }
} }
break; break;
#endif
default: default:
break; break;

View File

@ -542,8 +542,10 @@ if x11_enabled
cdata.set('HAVE_XGENERICEVENTS', 1) cdata.set('HAVE_XGENERICEVENTS', 1)
endif endif
if xi_dep.found() and cc.has_header('X11/extensions/XInput2.h', dependencies: xi_dep) if not xi_dep.found() or not cc.has_header('X11/extensions/XInput2.h', dependencies: xi_dep)
cdata.set('XINPUT_2', 1) error('X11 backend enabled, but XInput2 not found.')
endif
# Note that we also check that the XIScrollClassInfo struct is defined, # Note that we also check that the XIScrollClassInfo struct is defined,
# because at least Ubuntu Oneiric seems to have XIAllowTouchEvents(), # because at least Ubuntu Oneiric seems to have XIAllowTouchEvents(),
# but not the XIScrollClassInfo struct # but not the XIScrollClassInfo struct
@ -554,7 +556,6 @@ if x11_enabled
if has_allow_touch_evens and has_scroll_class_info if has_allow_touch_evens and has_scroll_class_info
cdata.set('XINPUT_2_2', 1) cdata.set('XINPUT_2_2', 1)
endif endif
endif
enable_xinerama = get_option('xinerama') enable_xinerama = get_option('xinerama')
if enable_xinerama != 'no' if enable_xinerama != 'no'