[mutter/gnome-3-36] backend: Update cursor visibility on device added



commit 7c7fd6c4934c2ef362dd1ec7055d16675f6a086f
Author: Olivier Fourdan <ofourdan redhat com>
Date:   Fri Oct 30 15:44:52 2020 +0100

    backend: Update cursor visibility on device added
    
    Not calling libinput dispatch in the backend constructor defeats the
    logic in post init as the device added events have not been processed
    yet.
    
    So instead of trying to guess the cursor initial visibility, simply
    update it along when devices get added.
    
    Additional benefit, we do not need to walk the all device list looking
    for touchscreens anymore, we just need to check the device being added
    since the current logic is to hide the cursor as soon as a touchscreen
    is found.
    
    https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1534
    (cherry picked from commit 9b881729821b360cc6e6f06f37fee0fe9b417a27)

 src/backends/meta-backend.c | 47 ++++++++++++++-------------------------------
 1 file changed, 14 insertions(+), 33 deletions(-)
---
diff --git a/src/backends/meta-backend.c b/src/backends/meta-backend.c
index 52b5b50e0d..06d388154d 100644
--- a/src/backends/meta-backend.c
+++ b/src/backends/meta-backend.c
@@ -365,16 +365,6 @@ meta_backend_monitor_device (MetaBackend        *backend,
   create_device_monitor (backend, device);
 }
 
-static void
-on_device_added (ClutterSeat        *seat,
-                 ClutterInputDevice *device,
-                 gpointer            user_data)
-{
-  MetaBackend *backend = META_BACKEND (user_data);
-
-  create_device_monitor (backend, device);
-}
-
 static inline gboolean
 device_is_slave_touchscreen (ClutterInputDevice *device)
 {
@@ -434,6 +424,20 @@ check_has_slave_touchscreen (ClutterSeat *seat)
   return found;
 }
 
+static void
+on_device_added (ClutterSeat        *seat,
+                 ClutterInputDevice *device,
+                 gpointer            user_data)
+{
+  MetaBackend *backend = META_BACKEND (user_data);
+  MetaBackendPrivate *priv = meta_backend_get_instance_private (backend);
+
+  create_device_monitor (backend, device);
+
+  if (device_is_slave_touchscreen (device))
+    meta_cursor_tracker_set_pointer_visible (priv->cursor_tracker, FALSE);
+}
+
 static void
 on_device_removed (ClutterSeat        *seat,
                    ClutterInputDevice *device,
@@ -497,27 +501,6 @@ create_device_monitors (MetaBackend *backend,
   g_list_free (devices);
 }
 
-static void
-set_initial_pointer_visibility (MetaBackend *backend,
-                                ClutterSeat *seat)
-{
-  MetaBackendPrivate *priv = meta_backend_get_instance_private (backend);
-  GList *l, *devices;
-  gboolean has_touchscreen = FALSE;
-
-  devices = clutter_seat_list_devices (seat);
-  for (l = devices; l; l = l->next)
-    {
-      ClutterInputDevice *device = l->data;
-
-      has_touchscreen |= device_is_slave_touchscreen (device);
-    }
-
-  g_list_free (devices);
-  meta_cursor_tracker_set_pointer_visible (priv->cursor_tracker,
-                                           !has_touchscreen);
-}
-
 static MetaInputSettings *
 meta_backend_create_input_settings (MetaBackend *backend)
 {
@@ -552,8 +535,6 @@ meta_backend_real_post_init (MetaBackend *backend)
                            G_CALLBACK (on_device_removed), backend,
                            G_CONNECT_AFTER);
 
-  set_initial_pointer_visibility (backend, seat);
-
   priv->input_settings = meta_backend_create_input_settings (backend);
 
   if (priv->input_settings)


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