[mutter/wip/carlosg/device-capabilities: 6/9] wayland: Set wayland seat capabilities based on input device capabilities




commit 7459535fa7fd018e66c8790730beeac66a69b35d
Author: Carlos Garnacho <carlosg gnome org>
Date:   Tue Mar 8 17:26:43 2022 +0100

    wayland: Set wayland seat capabilities based on input device capabilities
    
    Instead of looking at device types, which might be incomplete.
    
    Fixes: https://gitlab.gnome.org/GNOME/mutter/-/issues/2154

 src/wayland/meta-wayland-seat.c | 58 ++++++++++++++---------------------------
 1 file changed, 19 insertions(+), 39 deletions(-)
---
diff --git a/src/wayland/meta-wayland-seat.c b/src/wayland/meta-wayland-seat.c
index 63c6b34abd..f7a2aeddc1 100644
--- a/src/wayland/meta-wayland-seat.c
+++ b/src/wayland/meta-wayland-seat.c
@@ -114,7 +114,7 @@ lookup_device_capabilities (ClutterSeat *seat)
 
   for (l = devices; l; l = l->next)
     {
-      ClutterInputDeviceType device_type;
+      ClutterInputCapabilities device_capabilities;
 
       /* Only look for physical devices, logical devices have rather generic
        * keyboard/pointer device types, which is not truly representative of
@@ -123,26 +123,14 @@ lookup_device_capabilities (ClutterSeat *seat)
       if (clutter_input_device_get_device_mode (l->data) == CLUTTER_INPUT_MODE_LOGICAL)
         continue;
 
-      device_type = clutter_input_device_get_device_type (l->data);
+      device_capabilities = clutter_input_device_get_capabilities (l->data);
 
-      switch (device_type)
-        {
-        case CLUTTER_TOUCHPAD_DEVICE:
-        case CLUTTER_POINTER_DEVICE:
-          capabilities |= WL_SEAT_CAPABILITY_POINTER;
-          break;
-        case CLUTTER_KEYBOARD_DEVICE:
-          capabilities |= WL_SEAT_CAPABILITY_KEYBOARD;
-          break;
-        case CLUTTER_TOUCHSCREEN_DEVICE:
-          capabilities |= WL_SEAT_CAPABILITY_TOUCH;
-          break;
-        default:
-          g_debug ("Ignoring device '%s' with unhandled type %d",
-                   clutter_input_device_get_device_name (l->data),
-                   device_type);
-          break;
-        }
+      if (device_capabilities & CLUTTER_INPUT_CAPABILITY_POINTER)
+        capabilities |= WL_SEAT_CAPABILITY_POINTER;
+      if (device_capabilities & CLUTTER_INPUT_CAPABILITY_KEYBOARD)
+        capabilities |= WL_SEAT_CAPABILITY_KEYBOARD;
+      if (device_capabilities & CLUTTER_INPUT_CAPABILITY_TOUCH)
+        capabilities |= WL_SEAT_CAPABILITY_TOUCH;
     }
 
   g_list_free (devices);
@@ -297,11 +285,11 @@ static gboolean
 event_from_supported_hardware_device (MetaWaylandSeat    *seat,
                                       const ClutterEvent *event)
 {
-  ClutterInputDevice     *input_device;
-  ClutterInputMode        input_mode;
-  ClutterInputDeviceType  device_type;
-  gboolean                hardware_device = FALSE;
-  gboolean                supported_device = FALSE;
+  ClutterInputDevice *input_device;
+  ClutterInputMode input_mode;
+  ClutterInputCapabilities capabilities;
+  gboolean hardware_device = FALSE;
+  gboolean supported_device = FALSE;
 
   input_device = clutter_event_get_source_device (event);
 
@@ -315,21 +303,13 @@ event_from_supported_hardware_device (MetaWaylandSeat    *seat,
 
   hardware_device = TRUE;
 
-  device_type = clutter_input_device_get_device_type (input_device);
-
-  switch (device_type)
-    {
-    case CLUTTER_TOUCHPAD_DEVICE:
-    case CLUTTER_POINTER_DEVICE:
-    case CLUTTER_KEYBOARD_DEVICE:
-    case CLUTTER_TOUCHSCREEN_DEVICE:
-      supported_device = TRUE;
-      break;
+  capabilities = clutter_input_device_get_capabilities (input_device);
 
-    default:
-      supported_device = FALSE;
-      break;
-    }
+  if ((capabilities &
+       (CLUTTER_INPUT_CAPABILITY_POINTER |
+        CLUTTER_INPUT_CAPABILITY_KEYBOARD |
+        CLUTTER_INPUT_CAPABILITY_TOUCH)) != 0)
+    supported_device = TRUE;
 
 out:
   return hardware_device && supported_device;


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