From 86fa8aff4aabf53c125691a44a464cacc25bcb28 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Fri, 25 Sep 2020 18:49:19 +0200 Subject: [PATCH] core: Do not update last device on CLUTTER_DEVICE_ADDED/REMOVED We only update the last device from actual input interaction here, avoid this pair of events. This is specially nasty with CLUTTER_DEVICE_REMOVED, since the device we're notifying upon will be disposed soon after emission. https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1460 --- src/core/events.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/core/events.c b/src/core/events.c index 83ebc68b5..438beda5c 100644 --- a/src/core/events.c +++ b/src/core/events.c @@ -205,7 +205,6 @@ meta_display_handle_event (MetaDisplay *display, G_GNUC_UNUSED gboolean bypass_wayland = FALSE; MetaGestureTracker *gesture_tracker; ClutterEventSequence *sequence; - ClutterInputDevice *source; sequence = clutter_event_get_event_sequence (event); @@ -271,10 +270,17 @@ meta_display_handle_event (MetaDisplay *display, } } - source = clutter_event_get_source_device (event); + if (event->type != CLUTTER_DEVICE_ADDED && + event->type != CLUTTER_DEVICE_REMOVED) + { + ClutterInputDevice *source; - if (source) - meta_backend_update_last_device (backend, source); + handle_idletime_for_event (event); + source = clutter_event_get_source_device (event); + + if (source) + meta_backend_update_last_device (backend, source); + } #ifdef HAVE_WAYLAND if (meta_is_wayland_compositor () && event->type == CLUTTER_MOTION) @@ -299,8 +305,6 @@ meta_display_handle_event (MetaDisplay *display, } #endif - handle_idletime_for_event (event); - window = get_window_for_event (display, event); display->current_time = event->any.time;