[mutter/wip/carlosg/device-capabilities: 24/32] backends/native: Make function to determine ClutterInputDeviceType private




commit 842295838ff0aa30e6d4e35d3548d1824294f014
Author: Carlos Garnacho <carlosg gnome org>
Date:   Tue Mar 8 16:58:41 2022 +0100

    backends/native: Make function to determine ClutterInputDeviceType private
    
    We do not need to open code the ClutterInputDeviceType fetching from a
    libinput_device, since we already created a native ClutterInputDevice that
    has the right type.
    
    Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2331>

 src/backends/native/meta-input-device-native.c | 46 +++++++++++++-------------
 src/backends/native/meta-seat-impl.c           |  2 +-
 2 files changed, 24 insertions(+), 24 deletions(-)
---
diff --git a/src/backends/native/meta-input-device-native.c b/src/backends/native/meta-input-device-native.c
index 6ee6f4961f..fbd067b29a 100644
--- a/src/backends/native/meta-input-device-native.c
+++ b/src/backends/native/meta-input-device-native.c
@@ -1328,6 +1328,28 @@ update_pad_features (MetaInputDeviceNative *device_native)
     }
 }
 
+static ClutterInputDeviceType
+determine_device_type (struct libinput_device *ldev)
+{
+  /* This setting is specific to touchpads and alike, only in these
+   * devices there is this additional layer of touch event interpretation.
+   */
+  if (libinput_device_config_tap_get_finger_count (ldev) > 0)
+    return CLUTTER_TOUCHPAD_DEVICE;
+  else if (libinput_device_has_capability (ldev, LIBINPUT_DEVICE_CAP_TABLET_TOOL))
+    return CLUTTER_TABLET_DEVICE;
+  else if (libinput_device_has_capability (ldev, LIBINPUT_DEVICE_CAP_TABLET_PAD))
+    return CLUTTER_PAD_DEVICE;
+  else if (libinput_device_has_capability (ldev, LIBINPUT_DEVICE_CAP_POINTER))
+    return CLUTTER_POINTER_DEVICE;
+  else if (libinput_device_has_capability (ldev, LIBINPUT_DEVICE_CAP_TOUCH))
+    return CLUTTER_TOUCHSCREEN_DEVICE;
+  else if (libinput_device_has_capability (ldev, LIBINPUT_DEVICE_CAP_KEYBOARD))
+    return CLUTTER_KEYBOARD_DEVICE;
+  else
+    return CLUTTER_EXTENSION_DEVICE;
+}
+
 /*
  * meta_input_device_native_new:
  * @manager: the device manager
@@ -1348,7 +1370,7 @@ meta_input_device_native_new_in_impl (MetaSeatImpl           *seat_impl,
   char *node_path;
   double width, height;
 
-  type = meta_input_device_native_determine_type_in_impl (libinput_device);
+  type = determine_device_type (libinput_device);
   vendor = g_strdup_printf ("%.4x", libinput_device_get_id_vendor (libinput_device));
   product = g_strdup_printf ("%.4x", libinput_device_get_id_product (libinput_device));
   node_path = g_strdup_printf ("/dev/input/%s", libinput_device_get_sysname (libinput_device));
@@ -1456,28 +1478,6 @@ meta_input_device_native_update_leds_in_impl (MetaInputDeviceNative *device,
   libinput_device_led_update (device->libinput_device, leds);
 }
 
-ClutterInputDeviceType
-meta_input_device_native_determine_type_in_impl (struct libinput_device *ldev)
-{
-  /* This setting is specific to touchpads and alike, only in these
-   * devices there is this additional layer of touch event interpretation.
-   */
-  if (libinput_device_config_tap_get_finger_count (ldev) > 0)
-    return CLUTTER_TOUCHPAD_DEVICE;
-  else if (libinput_device_has_capability (ldev, LIBINPUT_DEVICE_CAP_TABLET_TOOL))
-    return CLUTTER_TABLET_DEVICE;
-  else if (libinput_device_has_capability (ldev, LIBINPUT_DEVICE_CAP_TABLET_PAD))
-    return CLUTTER_PAD_DEVICE;
-  else if (libinput_device_has_capability (ldev, LIBINPUT_DEVICE_CAP_POINTER))
-    return CLUTTER_POINTER_DEVICE;
-  else if (libinput_device_has_capability (ldev, LIBINPUT_DEVICE_CAP_TOUCH))
-    return CLUTTER_TOUCHSCREEN_DEVICE;
-  else if (libinput_device_has_capability (ldev, LIBINPUT_DEVICE_CAP_KEYBOARD))
-    return CLUTTER_KEYBOARD_DEVICE;
-  else
-    return CLUTTER_EXTENSION_DEVICE;
-}
-
 /**
  * meta_input_device_native_get_libinput_device:
  * @device: a #ClutterInputDevice
diff --git a/src/backends/native/meta-seat-impl.c b/src/backends/native/meta-seat-impl.c
index 8b3115265b..624b2fe6f1 100644
--- a/src/backends/native/meta-seat-impl.c
+++ b/src/backends/native/meta-seat-impl.c
@@ -1658,7 +1658,7 @@ evdev_add_device (MetaSeatImpl           *seat_impl,
 
   /* Clutter assumes that device types are exclusive in the
    * ClutterInputDevice API */
-  type = meta_input_device_native_determine_type_in_impl (libinput_device);
+  type = clutter_input_device_get_device_type (device);
 
   is_touchscreen = type == CLUTTER_TOUCHSCREEN_DEVICE;
   is_tablet_switch =


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