[mutter/wip/carlosg/input-thread: 78/95] backends: Do not use clutter_seat_list_devices() in MetaInputSettings




commit 464397670a65dbc6c0c2d823a1588f5cbceb08ea
Author: Carlos Garnacho <carlosg gnome org>
Date:   Tue Aug 11 18:10:28 2020 +0200

    backends: Do not use clutter_seat_list_devices() in MetaInputSettings
    
    Make it keep its own list of devices, it's not that far off.
    
    https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1403

 src/backends/meta-input-settings.c | 36 +++++++++++++++---------------------
 1 file changed, 15 insertions(+), 21 deletions(-)
---
diff --git a/src/backends/meta-input-settings.c b/src/backends/meta-input-settings.c
index 767797b4a3..c1d5c8e72a 100644
--- a/src/backends/meta-input-settings.c
+++ b/src/backends/meta-input-settings.c
@@ -77,6 +77,7 @@ struct _MetaInputSettingsPrivate
   GSettings *keyboard_a11y_settings;
   GSettings *mouse_a11y_settings;
 
+  GList *devices;
   GHashTable *mappable_devices;
 
   GHashTable *current_tools;
@@ -115,13 +116,12 @@ meta_input_settings_get_devices (MetaInputSettings      *settings,
                                  ClutterInputDeviceType  type)
 {
   MetaInputSettingsPrivate *priv;
-  GList *l, *devices;
+  GList *l;
   GSList *list = NULL;
 
   priv = meta_input_settings_get_instance_private (settings);
-  devices = clutter_seat_list_devices (priv->seat);
 
-  for (l = devices; l; l = l->next)
+  for (l = priv->devices; l; l = l->next)
     {
       ClutterInputDevice *device = l->data;
 
@@ -130,8 +130,6 @@ meta_input_settings_get_devices (MetaInputSettings      *settings,
         list = g_slist_prepend (list, device);
     }
 
-  g_list_free (devices);
-
   return list;
 }
 
@@ -362,10 +360,9 @@ update_pointer_accel_profile (MetaInputSettings  *input_settings,
     {
       MetaInputSettingsPrivate *priv =
         meta_input_settings_get_instance_private (input_settings);
-      GList *l, *devices;
+      GList *l;
 
-      devices = clutter_seat_list_devices (priv->seat);
-      for (l = devices; l; l = l->next)
+      for (l = priv->devices; l; l = l->next)
         {
           device = l->data;
 
@@ -376,8 +373,6 @@ update_pointer_accel_profile (MetaInputSettings  *input_settings,
           do_update_pointer_accel_profile (input_settings, settings,
                                            device, profile);
         }
-
-      g_list_free (devices);
     }
 }
 
@@ -853,19 +848,15 @@ update_trackball_scroll_button (MetaInputSettings  *input_settings,
     }
   else if (!device)
     {
-      GList *l, *devices;
+      GList *l;
 
-      devices = clutter_seat_list_devices (priv->seat);
-
-      for (l = devices; l; l = l->next)
+      for (l = priv->devices; l; l = l->next)
         {
           device = l->data;
 
           if (input_settings_class->is_trackball_device (input_settings, device))
             input_settings_class->set_scroll_button (input_settings, device, button);
         }
-
-      g_list_free (devices);
     }
 }
 
@@ -1583,9 +1574,13 @@ void
 meta_input_settings_add_device (MetaInputSettings  *input_settings,
                                 ClutterInputDevice *device)
 {
+  MetaInputSettingsPrivate *priv =
+    meta_input_settings_get_instance_private (input_settings);
+
   if (clutter_input_device_get_device_mode (device) == CLUTTER_INPUT_MODE_LOGICAL)
     return;
 
+  priv->devices = g_list_prepend (priv->devices, device);
   evaluate_two_finger_scrolling (input_settings, device);
 
   apply_device_settings (input_settings, device);
@@ -1605,6 +1600,8 @@ meta_input_settings_remove_device (MetaInputSettings  *input_settings,
   if (g_hash_table_remove (priv->two_finger_devices, device) &&
       g_hash_table_size (priv->two_finger_devices) == 0)
     apply_device_settings (input_settings, NULL);
+
+  priv->devices = g_list_remove (priv->devices, device);
 }
 
 static void
@@ -1670,12 +1667,11 @@ static void
 check_mappable_devices (MetaInputSettings *input_settings)
 {
   MetaInputSettingsPrivate *priv;
-  GList *l, *devices;
+  GList *l;
 
   priv = meta_input_settings_get_instance_private (input_settings);
-  devices = clutter_seat_list_devices (priv->seat);
 
-  for (l = devices; l; l = l->next)
+  for (l = priv->devices; l; l = l->next)
     {
       ClutterInputDevice *device = l->data;
 
@@ -1684,8 +1680,6 @@ check_mappable_devices (MetaInputSettings *input_settings)
 
       check_add_mappable_device (input_settings, device);
     }
-
-  g_list_free (devices);
 }
 
 static void


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