From 5780c100028649daebebc14d14953e1a1f3424ca Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Mon, 13 Nov 2023 12:25:56 +0100 Subject: [PATCH] clutter: Check source device mode to figure out logical device in events We look in various ways for the logical device on pointing events, in order to assign tablet events their own device, detached from the ClutterSeat pointer. While this pans out on the native backend, it does not quite match with X11 behavior where these events do drive the Virtual Core Pointer, this results in a variety of buglets deriving from this mismatch. Use the ClutterInputMode instead, to figure out whether the device is physical and attached to the VCP (The default on X11), or the device is floating thus should emit events on its own (The new stock behavior on native backend since the previous commit), and behave accordingly to what was specified by backend code. Closes: https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/7144 Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/3114 Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/3122 Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/3156 Part-of: --- clutter/clutter/clutter-event.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/clutter/clutter/clutter-event.c b/clutter/clutter/clutter-event.c index 286c6fb3b..7d1d81873 100644 --- a/clutter/clutter/clutter-event.c +++ b/clutter/clutter/clutter-event.c @@ -1902,7 +1902,8 @@ clutter_event_button_new (ClutterEventType type, g_set_object (&event->button.source_device, source_device); - if (tool) + if (clutter_input_device_get_device_mode (source_device) == + CLUTTER_INPUT_MODE_FLOATING) { g_set_object (&event->button.device, source_device); } @@ -1952,7 +1953,8 @@ clutter_event_motion_new (ClutterEventFlags flags, g_set_object (&event->motion.source_device, source_device); - if (tool) + if (clutter_input_device_get_device_mode (source_device) == + CLUTTER_INPUT_MODE_FLOATING) { g_set_object (&event->motion.device, source_device); } @@ -1999,7 +2001,8 @@ clutter_event_scroll_smooth_new (ClutterEventFlags flags, g_set_object (&event->scroll.source_device, source_device); - if (tool) + if (clutter_input_device_get_device_mode (source_device) == + CLUTTER_INPUT_MODE_FLOATING) { g_set_object (&event->scroll.device, source_device); } @@ -2040,7 +2043,8 @@ clutter_event_scroll_discrete_new (ClutterEventFlags flags, g_set_object (&event->scroll.source_device, source_device); - if (tool) + if (clutter_input_device_get_device_mode (source_device) == + CLUTTER_INPUT_MODE_FLOATING) { g_set_object (&event->scroll.device, source_device); } @@ -2072,8 +2076,8 @@ clutter_event_crossing_new (ClutterEventType type, type == CLUTTER_LEAVE, NULL); g_return_val_if_fail (CLUTTER_IS_INPUT_DEVICE (source_device), NULL); - if (!!(clutter_input_device_get_capabilities (source_device) & - CLUTTER_INPUT_CAPABILITY_TABLET_TOOL)) + if (clutter_input_device_get_device_mode (source_device) == + CLUTTER_INPUT_MODE_FLOATING) { device = source_device; }