[mutter/wip/carlosg/there-can-be-only-one: 5/10] backends: Check for updates in the last used device after dispatching events




commit 9cf02aa54645417e485f7679d19b86f4b7654be9
Author: Carlos Garnacho <carlosg gnome org>
Date:   Thu Jan 13 14:02:26 2022 +0100

    backends: Check for updates in the last used device after dispatching events
    
    Instead of relying in the device being updated from different parts of our
    machinery for different backends, hook this up to our own event dispatching.
    This will allow dropping all other places where this is done.

 src/backends/meta-backend.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
---
diff --git a/src/backends/meta-backend.c b/src/backends/meta-backend.c
index 62a4835721..f09d5395d3 100644
--- a/src/backends/meta-backend.c
+++ b/src/backends/meta-backend.c
@@ -1019,6 +1019,22 @@ system_bus_gotten_cb (GObject      *object,
                                         NULL);
 }
 
+static void
+update_last_device_from_event (MetaBackend  *backend,
+                               ClutterEvent *event)
+{
+  ClutterInputDevice *source;
+
+  /* Handled elsewhere */
+  if (event->type == CLUTTER_DEVICE_ADDED ||
+      event->type == CLUTTER_DEVICE_REMOVED)
+    return;
+
+  source = clutter_event_get_source_device (event);
+  if (source)
+    meta_backend_update_last_device (backend, source);
+}
+
 /* Mutter is responsible for pulling events off the X queue, so Clutter
  * doesn't need (and shouldn't) run its normal event source which polls
  * the X fd, but we do have to deal with dispatching events that accumulate
@@ -1058,6 +1074,7 @@ clutter_source_dispatch (GSource     *source,
       event->any.stage =
         CLUTTER_STAGE (meta_backend_get_stage (backend_source->backend));
       clutter_do_event (event);
+      update_last_device_from_event (backend_source->backend, event);
       clutter_event_free (event);
     }
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]