[mutter/wip/carlosg/device-capabilities: 4/8] clutter: Add compatibility code to get input capabilities from device type




commit f184fa2c92f5145a6d45593add0202e2413632d1
Author: Carlos Garnacho <carlosg gnome org>
Date:   Tue Mar 8 17:12:42 2022 +0100

    clutter: Add compatibility code to get input capabilities from device type
    
    We not just have X11 devices, but also virtual devices on both backends.
    So far have those specify a ClutterInputDeviceType, but transform that into
    capabilities on the getter side.

 clutter/clutter/clutter-input-device.c | 30 +++++++++++++++++++++++++++++-
 1 file changed, 29 insertions(+), 1 deletion(-)
---
diff --git a/clutter/clutter/clutter-input-device.c b/clutter/clutter/clutter-input-device.c
index a7b39076d3..12cdf4f28a 100644
--- a/clutter/clutter/clutter-input-device.c
+++ b/clutter/clutter/clutter-input-device.c
@@ -213,7 +213,7 @@ clutter_input_device_get_property (GObject    *gobject,
       break;
 
     case PROP_CAPABILITIES:
-      g_value_set_flags (value, priv->capabilities);
+      g_value_set_flags (value, clutter_input_device_get_capabilities (self));
       break;
 
     case PROP_SEAT:
@@ -492,6 +492,34 @@ clutter_input_device_get_capabilities (ClutterInputDevice *device)
 
   g_return_val_if_fail (CLUTTER_IS_INPUT_DEVICE (device), 0);
 
+  if (priv->capabilities == 0)
+    {
+      switch (priv->device_type)
+        {
+        case CLUTTER_POINTER_DEVICE:
+          return CLUTTER_INPUT_CAPABILITY_POINTER;
+        case CLUTTER_KEYBOARD_DEVICE:
+          return CLUTTER_INPUT_CAPABILITY_KEYBOARD;
+        case CLUTTER_TOUCHPAD_DEVICE:
+          return CLUTTER_INPUT_CAPABILITY_POINTER |
+            CLUTTER_INPUT_CAPABILITY_TOUCHPAD;
+        case CLUTTER_TOUCHSCREEN_DEVICE:
+          return CLUTTER_INPUT_CAPABILITY_TOUCH;
+        case CLUTTER_TABLET_DEVICE:
+        case CLUTTER_PEN_DEVICE:
+        case CLUTTER_ERASER_DEVICE:
+        case CLUTTER_CURSOR_DEVICE:
+          return CLUTTER_INPUT_CAPABILITY_TABLET_TOOL;
+        case CLUTTER_PAD_DEVICE:
+          return CLUTTER_INPUT_CAPABILITY_TABLET_PAD;
+        case CLUTTER_EXTENSION_DEVICE:
+        case CLUTTER_JOYSTICK_DEVICE:
+          return 0;
+        case CLUTTER_N_DEVICE_TYPES:
+          g_assert_not_reached ();
+        }
+    }
+
   return priv->capabilities;
 }
 


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