[mutter/wip/carlosg/input-thread: 88/101] clutter: Drop ClutterInputDevice private tool maintenance API




commit cedaa4e65f1fff109b1a48fd70f76410671b9dc7
Author: Carlos Garnacho <carlosg gnome org>
Date:   Thu Nov 19 12:04:46 2020 +0100

    clutter: Drop ClutterInputDevice private tool maintenance API
    
    This is just used in the native backend (with the X11 going its own
    way). Just keep a HT of tools there, and drop this API.

 clutter/clutter/clutter-input-device-private.h | 12 --------
 clutter/clutter/clutter-input-device.c         | 40 --------------------------
 src/backends/native/meta-seat-impl.c           | 17 +++++++----
 src/backends/native/meta-seat-impl.h           |  1 +
 4 files changed, 13 insertions(+), 57 deletions(-)
---
diff --git a/clutter/clutter/clutter-input-device-private.h b/clutter/clutter/clutter-input-device-private.h
index cb8fd8621d..fc9f1742ed 100644
--- a/clutter/clutter/clutter-input-device-private.h
+++ b/clutter/clutter/clutter-input-device-private.h
@@ -92,8 +92,6 @@ struct _ClutterInputDevice
   char *product_id;
   char *node_path;
 
-  GPtrArray *tools;
-
   int n_rings;
   int n_strips;
   int n_mode_groups;
@@ -116,16 +114,6 @@ CLUTTER_EXPORT
 void _clutter_input_device_remove_event_sequence (ClutterInputDevice *device,
                                                   ClutterEvent       *event);
 
-CLUTTER_EXPORT
-void clutter_input_device_add_tool (ClutterInputDevice     *device,
-                                    ClutterInputDeviceTool *tool);
-
-CLUTTER_EXPORT
-ClutterInputDeviceTool *
-   clutter_input_device_lookup_tool (ClutterInputDevice         *device,
-                                     guint64                     serial,
-                                     ClutterInputDeviceToolType  type);
-
 CLUTTER_EXPORT
 gboolean clutter_input_device_keycode_to_evdev (ClutterInputDevice *device,
                                                 guint               hardware_keycode,
diff --git a/clutter/clutter/clutter-input-device.c b/clutter/clutter/clutter-input-device.c
index 47888c97d4..4631a454f1 100644
--- a/clutter/clutter/clutter-input-device.c
+++ b/clutter/clutter/clutter-input-device.c
@@ -1172,46 +1172,6 @@ clutter_input_device_get_product_id (ClutterInputDevice *device)
   return device->product_id;
 }
 
-void
-clutter_input_device_add_tool (ClutterInputDevice     *device,
-                               ClutterInputDeviceTool *tool)
-{
-  g_return_if_fail (CLUTTER_IS_INPUT_DEVICE (device));
-  g_return_if_fail (clutter_input_device_get_device_mode (device) != CLUTTER_INPUT_MODE_LOGICAL);
-  g_return_if_fail (CLUTTER_IS_INPUT_DEVICE_TOOL (tool));
-
-  if (!device->tools)
-    device->tools = g_ptr_array_new_with_free_func ((GDestroyNotify) g_object_unref);
-
-  g_ptr_array_add (device->tools, tool);
-}
-
-ClutterInputDeviceTool *
-clutter_input_device_lookup_tool (ClutterInputDevice         *device,
-                                  guint64                     serial,
-                                  ClutterInputDeviceToolType  type)
-{
-  ClutterInputDeviceTool *tool;
-  guint i;
-
-  g_return_val_if_fail (CLUTTER_IS_INPUT_DEVICE (device), NULL);
-  g_return_val_if_fail (clutter_input_device_get_device_mode (device) != CLUTTER_INPUT_MODE_LOGICAL, NULL);
-
-  if (!device->tools)
-    return NULL;
-
-  for (i = 0; i < device->tools->len; i++)
-    {
-      tool = g_ptr_array_index (device->tools, i);
-
-      if (serial == clutter_input_device_tool_get_serial (tool) &&
-          type == clutter_input_device_tool_get_tool_type (tool))
-        return tool;
-    }
-
-  return NULL;
-}
-
 gint
 clutter_input_device_get_n_rings (ClutterInputDevice *device)
 {
diff --git a/src/backends/native/meta-seat-impl.c b/src/backends/native/meta-seat-impl.c
index 71e4c2fb7d..a075056a73 100644
--- a/src/backends/native/meta-seat-impl.c
+++ b/src/backends/native/meta-seat-impl.c
@@ -1658,16 +1658,22 @@ input_device_update_tool (MetaSeatImpl                *seat_impl,
 
   if (libinput_tool)
     {
-      tool_serial = libinput_tablet_tool_get_serial (libinput_tool);
-      tool_type = translate_tool_type (libinput_tool);
-      tool = clutter_input_device_lookup_tool (input_device,
-                                               tool_serial, tool_type);
+      if (!seat_impl->tools)
+        {
+          seat_impl->tools =
+            g_hash_table_new_full (NULL, NULL, NULL,
+                                   (GDestroyNotify) g_object_unref);
+        }
+
+      tool = g_hash_table_lookup (seat_impl->tools, libinput_tool);
 
       if (!tool)
         {
+          tool_serial = libinput_tablet_tool_get_serial (libinput_tool);
+          tool_type = translate_tool_type (libinput_tool);
           tool = meta_input_device_tool_native_new (libinput_tool,
                                                     tool_serial, tool_type);
-          clutter_input_device_add_tool (input_device, tool);
+          g_hash_table_insert (seat_impl->tools, libinput_tool, tool);
         }
     }
 
@@ -2608,6 +2614,7 @@ meta_seat_impl_finalize (GObject *object)
       g_object_unref (device);
     }
   g_slist_free (seat_impl->devices);
+  g_clear_pointer (&seat_impl->tools, g_hash_table_unref);
 
   if (seat_impl->touch_states)
     g_hash_table_destroy (seat_impl->touch_states);
diff --git a/src/backends/native/meta-seat-impl.h b/src/backends/native/meta-seat-impl.h
index 8e8de727f1..3dddcd5056 100644
--- a/src/backends/native/meta-seat-impl.h
+++ b/src/backends/native/meta-seat-impl.h
@@ -62,6 +62,7 @@ struct _MetaSeatImpl
   GRWLock state_lock;
 
   GSList *devices;
+  GHashTable *tools;
 
   ClutterInputDevice *core_pointer;
   ClutterInputDevice *core_keyboard;


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