mutter/2331.patch

1459 lines
57 KiB
Diff
Raw Normal View History

From 6141cc6684d158b6ef55903be0e99c68f9afc953 Mon Sep 17 00:00:00 2001
From: Carlos Garnacho <carlosg@gnome.org>
Date: Tue, 8 Mar 2022 16:58:41 +0100
2022-03-09 16:48:49 +00:00
Subject: [PATCH 01/10] 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.
---
.../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 =
--
GitLab
From 350286d27ec698944b0412540f1c5a3a1e37d369 Mon Sep 17 00:00:00 2001
From: Carlos Garnacho <carlosg@gnome.org>
Date: Tue, 8 Mar 2022 17:03:31 +0100
2022-03-09 16:48:49 +00:00
Subject: [PATCH 02/10] clutter: Add ClutterInputCapabilities flagset
This will be a truer representation of input devices in the native
backend, since a single device can have multiple capabilities.
---
clutter/clutter/clutter-enums.h | 21 +++++++++++++++++++++
1 file changed, 21 insertions(+)
diff --git a/clutter/clutter/clutter-enums.h b/clutter/clutter/clutter-enums.h
index 9ee55fb5c4..5d8a38ea59 100644
--- a/clutter/clutter/clutter-enums.h
+++ b/clutter/clutter/clutter-enums.h
@@ -935,6 +935,27 @@ typedef enum /*< prefix=CLUTTER_FLOW >*/
CLUTTER_FLOW_VERTICAL
} ClutterFlowOrientation;
+/**
+ * ClutterInputDeviceCapabilities:
+ * @CLUTTER_INPUT_CAPABILITY_POINTER: Pointer capability
+ * @CLUTTER_INPUT_CAPABILITY_KEYBOARD: Keyboard capability
+ * @CLUTTER_INPUT_CAPABILITY_TOUCHPAD: Touchpad gesture and scroll capability
+ * @CLUTTER_INPUT_CAPABILITY_TOUCH: Touch capability
+ * @CLUTTER_INPUT_CAPABILITY_TABLET_TOOL: Tablet tool capability
+ * @CLUTTER_INPUT_CAPABILITY_TABLET_PAD: Tablet pad capability
+ *
+ * Describes the capabilities of an input device.
+ **/
+typedef enum /*< prefix=CLUTTER_INPUT_CAPABILITY >*/
+{
+ CLUTTER_INPUT_CAPABILITY_POINTER = 1 << 0,
+ CLUTTER_INPUT_CAPABILITY_KEYBOARD = 1 << 1,
+ CLUTTER_INPUT_CAPABILITY_TOUCHPAD = 1 << 2,
+ CLUTTER_INPUT_CAPABILITY_TOUCH = 1 << 3,
+ CLUTTER_INPUT_CAPABILITY_TABLET_TOOL = 1 << 4,
+ CLUTTER_INPUT_CAPABILITY_TABLET_PAD = 1 << 5,
+} ClutterInputCapabilities;
+
/**
* ClutterInputDeviceType:
* @CLUTTER_POINTER_DEVICE: A pointer device
--
GitLab
From f7f2a154c349de3dcf4ba650b74753e76c534532 Mon Sep 17 00:00:00 2001
From: Carlos Garnacho <carlosg@gnome.org>
Date: Tue, 8 Mar 2022 17:04:40 +0100
2022-03-09 16:48:49 +00:00
Subject: [PATCH 03/10] clutter: Add ClutterInputDevice::capabilities property
This is construct-only, and assigned by the backend.
---
clutter/clutter/clutter-input-device.c | 42 ++++++++++++++++++++++++++
clutter/clutter/clutter-input-device.h | 3 ++
2 files changed, 45 insertions(+)
diff --git a/clutter/clutter/clutter-input-device.c b/clutter/clutter/clutter-input-device.c
index a37886e46a..c3fed10fbd 100644
--- a/clutter/clutter/clutter-input-device.c
+++ b/clutter/clutter/clutter-input-device.c
@@ -56,6 +56,7 @@ enum
PROP_NAME,
PROP_DEVICE_TYPE,
+ PROP_CAPABILITIES,
PROP_SEAT,
PROP_DEVICE_MODE,
@@ -80,6 +81,7 @@ typedef struct _ClutterInputDevicePrivate ClutterInputDevicePrivate;
struct _ClutterInputDevicePrivate
{
ClutterInputDeviceType device_type;
+ ClutterInputCapabilities capabilities;
ClutterInputMode device_mode;
char *device_name;
@@ -136,6 +138,10 @@ clutter_input_device_set_property (GObject *gobject,
priv->device_type = g_value_get_enum (value);
break;
+ case PROP_CAPABILITIES:
+ priv->capabilities = g_value_get_flags (value);
+ break;
+
case PROP_SEAT:
priv->seat = g_value_get_object (value);
break;
@@ -206,6 +212,10 @@ clutter_input_device_get_property (GObject *gobject,
g_value_set_enum (value, priv->device_type);
break;
+ case PROP_CAPABILITIES:
+ g_value_set_flags (value, priv->capabilities);
+ break;
+
case PROP_SEAT:
g_value_set_object (value, priv->seat);
break;
@@ -296,6 +306,19 @@ clutter_input_device_class_init (ClutterInputDeviceClass *klass)
CLUTTER_PARAM_READWRITE |
G_PARAM_CONSTRUCT_ONLY);
+ /**
+ * ClutterInputDevice:capabilities:
+ *
+ * The capabilities of the device
+ */
+ obj_props[PROP_CAPABILITIES] =
+ g_param_spec_flags ("capabilities",
+ P_("Capabilities"),
+ P_("The capabilities of the device"),
+ CLUTTER_TYPE_INPUT_CAPABILITIES, 0,
+ CLUTTER_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT_ONLY);
+
/**
* ClutterInputDevice:seat:
*
@@ -451,6 +474,25 @@ clutter_input_device_get_device_type (ClutterInputDevice *device)
return priv->device_type;
}
+/**
+ * clutter_input_device_get_capabilities:
+ * @device: a #ClutterInputDevice
+ *
+ * Retrieves the capabilities of @device
+ *
+ * Return value: the capabilities of the device
+ */
+ClutterInputCapabilities
+clutter_input_device_get_capabilities (ClutterInputDevice *device)
+{
+ ClutterInputDevicePrivate *priv =
+ clutter_input_device_get_instance_private (device);
+
+ g_return_val_if_fail (CLUTTER_IS_INPUT_DEVICE (device), 0);
+
+ return priv->capabilities;
+}
+
/**
* clutter_input_device_get_device_name:
* @device: a #ClutterInputDevice
diff --git a/clutter/clutter/clutter-input-device.h b/clutter/clutter/clutter-input-device.h
index 1a82ac9af6..d6fd62a038 100644
--- a/clutter/clutter/clutter-input-device.h
+++ b/clutter/clutter/clutter-input-device.h
@@ -121,6 +121,9 @@ int clutter_input_device_get_pad_feature_group (ClutterInputDevice *de
ClutterInputDevicePadFeature feature,
int n_feature);
+CLUTTER_EXPORT
+ClutterInputCapabilities clutter_input_device_get_capabilities (ClutterInputDevice *device);
+
G_END_DECLS
#endif /* __CLUTTER_INPUT_DEVICE_H__ */
--
GitLab
From 89e716113e3e08f7a87fdcfd9a7e166e82c4ffee Mon Sep 17 00:00:00 2001
From: Carlos Garnacho <carlosg@gnome.org>
Date: Tue, 8 Mar 2022 17:05:44 +0100
2022-03-09 16:48:49 +00:00
Subject: [PATCH 04/10] backends/native: Assign capabilities to input devices
These are extracted from the individual libinput_devices.
---
.../native/meta-input-device-native.c | 27 +++++++++++++++++++
1 file changed, 27 insertions(+)
diff --git a/src/backends/native/meta-input-device-native.c b/src/backends/native/meta-input-device-native.c
index fbd067b29a..380dda4f56 100644
--- a/src/backends/native/meta-input-device-native.c
+++ b/src/backends/native/meta-input-device-native.c
@@ -1350,6 +1350,30 @@ determine_device_type (struct libinput_device *ldev)
return CLUTTER_EXTENSION_DEVICE;
}
+static ClutterInputCapabilities
+translate_device_capabilities (struct libinput_device *ldev)
+{
+ ClutterInputCapabilities caps = 0;
+
+ /* 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)
+ caps |= CLUTTER_INPUT_CAPABILITY_TOUCHPAD;
+ if (libinput_device_has_capability (ldev, LIBINPUT_DEVICE_CAP_TABLET_TOOL))
+ caps |= CLUTTER_INPUT_CAPABILITY_TABLET_TOOL;
+ if (libinput_device_has_capability (ldev, LIBINPUT_DEVICE_CAP_TABLET_PAD))
+ caps |= CLUTTER_INPUT_CAPABILITY_TABLET_PAD;
+ if (libinput_device_has_capability (ldev, LIBINPUT_DEVICE_CAP_POINTER))
+ caps |= CLUTTER_INPUT_CAPABILITY_POINTER;
+ if (libinput_device_has_capability (ldev, LIBINPUT_DEVICE_CAP_TOUCH))
+ caps |= CLUTTER_INPUT_CAPABILITY_TOUCH;
+ if (libinput_device_has_capability (ldev, LIBINPUT_DEVICE_CAP_KEYBOARD))
+ caps |= CLUTTER_INPUT_CAPABILITY_KEYBOARD;
+
+ return caps;
+}
+
/*
* meta_input_device_native_new:
* @manager: the device manager
@@ -1365,11 +1389,13 @@ meta_input_device_native_new_in_impl (MetaSeatImpl *seat_impl,
{
MetaInputDeviceNative *device;
ClutterInputDeviceType type;
+ ClutterInputCapabilities capabilities;
char *vendor, *product;
int n_rings = 0, n_strips = 0, n_groups = 1, n_buttons = 0;
char *node_path;
double width, height;
+ capabilities = translate_device_capabilities (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));
@@ -1387,6 +1413,7 @@ meta_input_device_native_new_in_impl (MetaSeatImpl *seat_impl,
device = g_object_new (META_TYPE_INPUT_DEVICE_NATIVE,
"name", libinput_device_get_name (libinput_device),
"device-type", type,
+ "capabilities", capabilities,
"device-mode", CLUTTER_INPUT_MODE_PHYSICAL,
"vendor-id", vendor,
"product-id", product,
--
GitLab
From 5e34d70cf412af934c3f5bc4c3ce86e2b6b3119a Mon Sep 17 00:00:00 2001
From: Carlos Garnacho <carlosg@gnome.org>
Date: Tue, 8 Mar 2022 17:12:42 +0100
2022-03-09 16:48:49 +00:00
Subject: [PATCH 05/10] 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 device construction.
---
clutter/clutter/clutter-input-device.c | 48 ++++++++++++++++++++++++++
1 file changed, 48 insertions(+)
diff --git a/clutter/clutter/clutter-input-device.c b/clutter/clutter/clutter-input-device.c
index c3fed10fbd..8b99846ec0 100644
--- a/clutter/clutter/clutter-input-device.c
+++ b/clutter/clutter/clutter-input-device.c
@@ -104,6 +104,53 @@ struct _ClutterInputDevicePrivate
G_DEFINE_TYPE_WITH_PRIVATE (ClutterInputDevice, clutter_input_device, G_TYPE_OBJECT);
+static void
+clutter_input_device_constructed (GObject *gobject)
+{
+ ClutterInputDevice *device = CLUTTER_INPUT_DEVICE (gobject);
+ ClutterInputDevicePrivate *priv =
+ clutter_input_device_get_instance_private (device);
+
+ if (priv->capabilities == 0)
+ {
+ ClutterInputCapabilities capabilities = 0;
+
+ switch (priv->device_type)
+ {
+ case CLUTTER_POINTER_DEVICE:
+ capabilities = CLUTTER_INPUT_CAPABILITY_POINTER;
+ break;
+ case CLUTTER_KEYBOARD_DEVICE:
+ capabilities = CLUTTER_INPUT_CAPABILITY_KEYBOARD;
+ break;
+ case CLUTTER_TOUCHPAD_DEVICE:
+ capabilities = CLUTTER_INPUT_CAPABILITY_POINTER |
+ CLUTTER_INPUT_CAPABILITY_TOUCHPAD;
+ break;
+ case CLUTTER_TOUCHSCREEN_DEVICE:
+ capabilities = CLUTTER_INPUT_CAPABILITY_TOUCH;
+ break;
+ case CLUTTER_TABLET_DEVICE:
+ case CLUTTER_PEN_DEVICE:
+ case CLUTTER_ERASER_DEVICE:
+ case CLUTTER_CURSOR_DEVICE:
+ capabilities = CLUTTER_INPUT_CAPABILITY_TABLET_TOOL;
+ break;
+ case CLUTTER_PAD_DEVICE:
+ capabilities = CLUTTER_INPUT_CAPABILITY_TABLET_PAD;
+ break;
+ case CLUTTER_EXTENSION_DEVICE:
+ case CLUTTER_JOYSTICK_DEVICE:
+ break;
+ case CLUTTER_N_DEVICE_TYPES:
+ g_assert_not_reached ();
+ break;
+ }
+
+ priv->capabilities = capabilities;
+ }
+}
+
static void
clutter_input_device_dispose (GObject *gobject)
{
@@ -437,6 +484,7 @@ clutter_input_device_class_init (ClutterInputDeviceClass *klass)
NULL,
CLUTTER_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY);
+ gobject_class->constructed = clutter_input_device_constructed;
gobject_class->dispose = clutter_input_device_dispose;
gobject_class->set_property = clutter_input_device_set_property;
gobject_class->get_property = clutter_input_device_get_property;
--
GitLab
From f25f927763fa6c04898951a9c0a63a11213d7d50 Mon Sep 17 00:00:00 2001
From: Carlos Garnacho <carlosg@gnome.org>
Date: Tue, 8 Mar 2022 17:26:43 +0100
2022-03-09 16:48:49 +00:00
Subject: [PATCH 06/10] 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;
--
GitLab
From 79f463e110bc9efaa113e60231f59c22ed05db7c Mon Sep 17 00:00:00 2001
From: Carlos Garnacho <carlosg@gnome.org>
Date: Tue, 8 Mar 2022 17:31:20 +0100
2022-03-09 16:48:49 +00:00
Subject: [PATCH 07/10] wayland: Check input device capabilities in tablet
seats
Instead of looking for tablets and pads based on input device type,
check capabilities.
---
src/wayland/meta-wayland-tablet-manager.c | 12 ++++------
src/wayland/meta-wayland-tablet-seat.c | 28 +++++++++++------------
2 files changed, 19 insertions(+), 21 deletions(-)
diff --git a/src/wayland/meta-wayland-tablet-manager.c b/src/wayland/meta-wayland-tablet-manager.c
index a729c7b894..7ee1c9fe7b 100644
--- a/src/wayland/meta-wayland-tablet-manager.c
+++ b/src/wayland/meta-wayland-tablet-manager.c
@@ -43,18 +43,16 @@ unbind_resource (struct wl_resource *resource)
static gboolean
is_tablet_device (ClutterInputDevice *device)
{
- ClutterInputDeviceType device_type;
+ ClutterInputCapabilities capabilities;
if (clutter_input_device_get_device_mode (device) == CLUTTER_INPUT_MODE_LOGICAL)
return FALSE;
- device_type = clutter_input_device_get_device_type (device);
+ capabilities = clutter_input_device_get_capabilities (device);
- return (device_type == CLUTTER_TABLET_DEVICE ||
- device_type == CLUTTER_PEN_DEVICE ||
- device_type == CLUTTER_ERASER_DEVICE ||
- device_type == CLUTTER_CURSOR_DEVICE ||
- device_type == CLUTTER_PAD_DEVICE);
+ return (capabilities &
+ (CLUTTER_INPUT_CAPABILITY_TABLET_TOOL |
+ CLUTTER_INPUT_CAPABILITY_TABLET_PAD)) != 0;
}
static void
diff --git a/src/wayland/meta-wayland-tablet-seat.c b/src/wayland/meta-wayland-tablet-seat.c
index f9b95a6568..a5d3443c67 100644
--- a/src/wayland/meta-wayland-tablet-seat.c
+++ b/src/wayland/meta-wayland-tablet-seat.c
@@ -167,30 +167,27 @@ notify_pads (MetaWaylandTabletSeat *tablet_seat,
static gboolean
is_tablet_device (ClutterInputDevice *device)
{
- ClutterInputDeviceType device_type;
+ ClutterInputCapabilities capabilities;
if (clutter_input_device_get_device_mode (device) == CLUTTER_INPUT_MODE_LOGICAL)
return FALSE;
- device_type = clutter_input_device_get_device_type (device);
+ capabilities = clutter_input_device_get_capabilities (device);
- return (device_type == CLUTTER_TABLET_DEVICE ||
- device_type == CLUTTER_PEN_DEVICE ||
- device_type == CLUTTER_ERASER_DEVICE ||
- device_type == CLUTTER_CURSOR_DEVICE);
+ return (capabilities & CLUTTER_INPUT_CAPABILITY_TABLET_TOOL) != 0;
}
static gboolean
is_pad_device (ClutterInputDevice *device)
{
- ClutterInputDeviceType device_type;
+ ClutterInputCapabilities capabilities;
if (clutter_input_device_get_device_mode (device) == CLUTTER_INPUT_MODE_LOGICAL)
return FALSE;
- device_type = clutter_input_device_get_device_type (device);
+ capabilities = clutter_input_device_get_capabilities (device);
- return device_type == CLUTTER_PAD_DEVICE;
+ return (capabilities & CLUTTER_INPUT_CAPABILITY_TABLET_PAD) != 0;
}
static void
@@ -471,8 +468,8 @@ meta_wayland_tablet_seat_notify_tool (MetaWaylandTabletSeat *tablet_seat,
}
static GList *
-lookup_grouped_devices (ClutterInputDevice *device,
- ClutterInputDeviceType type)
+lookup_grouped_devices (ClutterInputDevice *device,
+ ClutterInputCapabilities capabilities)
{
ClutterSeat *clutter_seat;
GList *devices, *l;
@@ -485,7 +482,8 @@ lookup_grouped_devices (ClutterInputDevice *device,
{
if (l->data == device)
continue;
- if (clutter_input_device_get_device_type (l->data) != type)
+ if ((clutter_input_device_get_capabilities (l->data) & capabilities) ==
+ capabilities)
continue;
if (!clutter_input_device_is_grouped (device, l->data))
@@ -506,7 +504,8 @@ meta_wayland_tablet_seat_lookup_paired_tablet (MetaWaylandTabletSeat *tablet_sea
MetaWaylandTablet *tablet;
GList *devices;
- devices = lookup_grouped_devices (pad->device, CLUTTER_TABLET_DEVICE);
+ devices = lookup_grouped_devices (pad->device,
+ CLUTTER_INPUT_CAPABILITY_TABLET_TOOL);
if (!devices)
return NULL;
@@ -528,7 +527,8 @@ meta_wayland_tablet_seat_lookup_paired_pads (MetaWaylandTabletSeat *tablet_seat,
GList *l, *devices, *pads = NULL;
MetaWaylandTabletPad *pad;
- devices = lookup_grouped_devices (tablet->device, CLUTTER_PAD_DEVICE);
+ devices = lookup_grouped_devices (tablet->device,
+ CLUTTER_INPUT_CAPABILITY_TABLET_PAD);
for (l = devices; l; l = l->next)
{
--
GitLab
From 34de2bfca2102990f8325341f0bd932cfe0b6b6e Mon Sep 17 00:00:00 2001
From: Carlos Garnacho <carlosg@gnome.org>
Date: Tue, 8 Mar 2022 17:51:40 +0100
2022-03-09 16:48:49 +00:00
Subject: [PATCH 08/10] backends: Update MetaInputSettings to apply settings
based on capabilities
Since devices may be multiple things now, check all capabilities in order
to ensure all aspects of the device are correctly configured.
This change does the following observations:
- Devices that have TOUCHPAD | POINTER capabilities prefer the 'touchpad'
settings path. The regular pointer settings path is left for all
non-touchpads.
- The places that we looked for TOUCHPAD and POINTER devices can work
now by just looking at the POINTER capability.
- Devices that are both a tablet and a touchscreen prefer the tablet
relocatable schema. This works for both aspects as the touchscreen
schema is a subset of the tablet one.
Other than that it's a rather boring, even if verbose search and replace.
---
src/backends/meta-input-settings.c | 260 ++++++++++++++++-------------
1 file changed, 141 insertions(+), 119 deletions(-)
diff --git a/src/backends/meta-input-settings.c b/src/backends/meta-input-settings.c
index 16618608bb..d045315fa7 100644
--- a/src/backends/meta-input-settings.c
+++ b/src/backends/meta-input-settings.c
@@ -110,8 +110,8 @@ enum
static guint signals[N_SIGNALS] = { 0 };
static GSList *
-meta_input_settings_get_devices (MetaInputSettings *settings,
- ClutterInputDeviceType type)
+meta_input_settings_get_devices (MetaInputSettings *settings,
+ ClutterInputCapabilities capabilities)
{
MetaInputSettingsPrivate *priv;
GList *l;
@@ -123,7 +123,8 @@ meta_input_settings_get_devices (MetaInputSettings *settings,
{
ClutterInputDevice *device = l->data;
- if (clutter_input_device_get_device_type (device) == type &&
+ if ((clutter_input_device_get_capabilities (device) &
+ capabilities) == capabilities &&
clutter_input_device_get_device_mode (device) != CLUTTER_INPUT_MODE_LOGICAL)
list = g_slist_prepend (list, device);
}
@@ -160,15 +161,15 @@ settings_device_set_bool_setting (MetaInputSettings *input_settings,
}
static void
-settings_set_bool_setting (MetaInputSettings *input_settings,
- ClutterInputDeviceType type,
- ConfigBoolMappingFunc mapping_func,
- ConfigBoolFunc func,
- gboolean enabled)
+settings_set_bool_setting (MetaInputSettings *input_settings,
+ ClutterInputCapabilities capabilities,
+ ConfigBoolMappingFunc mapping_func,
+ ConfigBoolFunc func,
+ gboolean enabled)
{
GSList *devices, *l;
- devices = meta_input_settings_get_devices (input_settings, type);
+ devices = meta_input_settings_get_devices (input_settings, capabilities);
for (l = devices; l; l = l->next)
{
@@ -192,14 +193,14 @@ settings_device_set_double_setting (MetaInputSettings *input_settings,
}
static void
-settings_set_double_setting (MetaInputSettings *input_settings,
- ClutterInputDeviceType type,
- ConfigDoubleFunc func,
- gdouble value)
+settings_set_double_setting (MetaInputSettings *input_settings,
+ ClutterInputCapabilities capabilities,
+ ConfigDoubleFunc func,
+ gdouble value)
{
GSList *devices, *d;
- devices = meta_input_settings_get_devices (input_settings, type);
+ devices = meta_input_settings_get_devices (input_settings, capabilities);
for (d = devices; d; d = d->next)
settings_device_set_double_setting (input_settings, d->data, func, value);
@@ -217,14 +218,14 @@ settings_device_set_uint_setting (MetaInputSettings *input_settings,
}
static void
-settings_set_uint_setting (MetaInputSettings *input_settings,
- ClutterInputDeviceType type,
- ConfigUintFunc func,
- guint value)
+settings_set_uint_setting (MetaInputSettings *input_settings,
+ ClutterInputCapabilities capabilities,
+ ConfigUintFunc func,
+ guint value)
{
GSList *devices, *d;
- devices = meta_input_settings_get_devices (input_settings, type);
+ devices = meta_input_settings_get_devices (input_settings, capabilities);
for (d = devices; d; d = d->next)
settings_device_set_uint_setting (input_settings, d->data, func, value);
@@ -242,7 +243,8 @@ update_touchpad_left_handed (MetaInputSettings *input_settings,
gboolean enabled = FALSE;
if (device &&
- clutter_input_device_get_device_type (device) != CLUTTER_TOUCHPAD_DEVICE)
+ (clutter_input_device_get_capabilities (device) &
+ CLUTTER_INPUT_CAPABILITY_TOUCHPAD) == 0)
return;
priv = meta_input_settings_get_instance_private (input_settings);
@@ -272,7 +274,8 @@ update_touchpad_left_handed (MetaInputSettings *input_settings,
}
else
{
- settings_set_bool_setting (input_settings, CLUTTER_TOUCHPAD_DEVICE, NULL,
+ settings_set_bool_setting (input_settings,
+ CLUTTER_INPUT_CAPABILITY_TOUCHPAD, NULL,
input_settings_class->set_left_handed,
enabled);
}
@@ -284,11 +287,18 @@ update_mouse_left_handed (MetaInputSettings *input_settings,
{
MetaInputSettingsClass *input_settings_class;
MetaInputSettingsPrivate *priv;
+ ClutterInputCapabilities device_capabilities;
gboolean enabled;
- if (device &&
- clutter_input_device_get_device_type (device) != CLUTTER_POINTER_DEVICE)
- return;
+ if (device)
+ {
+ device_capabilities = clutter_input_device_get_capabilities (device);
+
+ if ((device_capabilities & CLUTTER_INPUT_CAPABILITY_TOUCHPAD) != 0)
+ return;
+ if ((device_capabilities & CLUTTER_INPUT_CAPABILITY_POINTER) == 0)
+ return;
+ }
priv = meta_input_settings_get_instance_private (input_settings);
input_settings_class = META_INPUT_SETTINGS_GET_CLASS (input_settings);
@@ -304,7 +314,8 @@ update_mouse_left_handed (MetaInputSettings *input_settings,
{
GDesktopTouchpadHandedness touchpad_handedness;
- settings_set_bool_setting (input_settings, CLUTTER_POINTER_DEVICE, NULL,
+ settings_set_bool_setting (input_settings,
+ CLUTTER_INPUT_CAPABILITY_POINTER, NULL,
input_settings_class->set_left_handed,
enabled);
@@ -373,20 +384,19 @@ update_pointer_accel_profile (MetaInputSettings *input_settings,
}
static GSettings *
-get_settings_for_device_type (MetaInputSettings *input_settings,
- ClutterInputDeviceType type)
+get_settings_for_capabilities (MetaInputSettings *input_settings,
+ ClutterInputCapabilities capabilities)
{
MetaInputSettingsPrivate *priv;
+
priv = meta_input_settings_get_instance_private (input_settings);
- switch (type)
- {
- case CLUTTER_POINTER_DEVICE:
- return priv->mouse_settings;
- case CLUTTER_TOUCHPAD_DEVICE:
- return priv->touchpad_settings;
- default:
- return NULL;
- }
+
+ if (capabilities & CLUTTER_INPUT_CAPABILITY_TOUCHPAD)
+ return priv->touchpad_settings;
+ if (capabilities & CLUTTER_INPUT_CAPABILITY_POINTER)
+ return priv->mouse_settings;
+
+ return NULL;
}
static void
@@ -417,7 +427,8 @@ update_middle_click_emulation (MetaInputSettings *input_settings,
}
else
{
- settings_set_bool_setting (input_settings, CLUTTER_POINTER_DEVICE,
+ settings_set_bool_setting (input_settings,
+ CLUTTER_INPUT_CAPABILITY_POINTER,
NULL, func,
g_settings_get_boolean (settings, key));
}
@@ -435,8 +446,8 @@ update_device_speed (MetaInputSettings *input_settings,
if (device)
{
- settings = get_settings_for_device_type (input_settings,
- clutter_input_device_get_device_type (device));
+ settings = get_settings_for_capabilities (input_settings,
+ clutter_input_device_get_capabilities (device));
if (!settings)
return;
@@ -445,11 +456,10 @@ update_device_speed (MetaInputSettings *input_settings,
}
else
{
- settings = get_settings_for_device_type (input_settings, CLUTTER_POINTER_DEVICE);
- settings_set_double_setting (input_settings, CLUTTER_POINTER_DEVICE, func,
- g_settings_get_double (settings, key));
- settings = get_settings_for_device_type (input_settings, CLUTTER_TOUCHPAD_DEVICE);
- settings_set_double_setting (input_settings, CLUTTER_TOUCHPAD_DEVICE, func,
+ settings = get_settings_for_capabilities (input_settings,
+ CLUTTER_INPUT_CAPABILITY_POINTER);
+ settings_set_double_setting (input_settings,
+ CLUTTER_INPUT_CAPABILITY_POINTER, func,
g_settings_get_double (settings, key));
}
}
@@ -466,8 +476,8 @@ update_device_natural_scroll (MetaInputSettings *input_settings,
if (device)
{
- settings = get_settings_for_device_type (input_settings,
- clutter_input_device_get_device_type (device));
+ settings = get_settings_for_capabilities (input_settings,
+ clutter_input_device_get_capabilities (device));
if (!settings)
return;
@@ -476,12 +486,10 @@ update_device_natural_scroll (MetaInputSettings *input_settings,
}
else
{
- settings = get_settings_for_device_type (input_settings, CLUTTER_POINTER_DEVICE);
- settings_set_bool_setting (input_settings, CLUTTER_POINTER_DEVICE,
- NULL, func,
- g_settings_get_boolean (settings, key));
- settings = get_settings_for_device_type (input_settings, CLUTTER_TOUCHPAD_DEVICE);
- settings_set_bool_setting (input_settings, CLUTTER_TOUCHPAD_DEVICE,
+ settings = get_settings_for_capabilities (input_settings,
+ CLUTTER_INPUT_CAPABILITY_POINTER);
+ settings_set_bool_setting (input_settings,
+ CLUTTER_INPUT_CAPABILITY_POINTER,
NULL, func,
g_settings_get_boolean (settings, key));
}
@@ -498,7 +506,8 @@ update_touchpad_disable_while_typing (MetaInputSettings *input_settings,
const gchar *key = "disable-while-typing";
if (device &&
- clutter_input_device_get_device_type (device) != CLUTTER_TOUCHPAD_DEVICE)
+ (clutter_input_device_get_capabilities (device) &
+ CLUTTER_INPUT_CAPABILITY_TOUCHPAD) == 0)
return;
priv = meta_input_settings_get_instance_private (input_settings);
@@ -507,8 +516,8 @@ update_touchpad_disable_while_typing (MetaInputSettings *input_settings,
if (device)
{
- settings = get_settings_for_device_type (input_settings,
- clutter_input_device_get_device_type (device));
+ settings = get_settings_for_capabilities (input_settings,
+ clutter_input_device_get_capabilities (device));
if (!settings)
return;
@@ -519,7 +528,8 @@ update_touchpad_disable_while_typing (MetaInputSettings *input_settings,
}
else
{
- settings_set_bool_setting (input_settings, CLUTTER_TOUCHPAD_DEVICE, NULL,
+ settings_set_bool_setting (input_settings,
+ CLUTTER_INPUT_CAPABILITY_TOUCHPAD, NULL,
input_settings_class->set_disable_while_typing,
enabled);
}
@@ -533,7 +543,9 @@ device_is_tablet_touchpad (MetaInputSettings *input_settings,
WacomIntegrationFlags flags = 0;
WacomDevice *wacom_device;
- if (clutter_input_device_get_device_type (device) != CLUTTER_TOUCHPAD_DEVICE)
+ if (device &&
+ (clutter_input_device_get_capabilities (device) &
+ CLUTTER_INPUT_CAPABILITY_TOUCHPAD) == 0)
return FALSE;
wacom_device = meta_input_device_get_wacom_device (META_INPUT_DEVICE (device));
@@ -568,7 +580,8 @@ update_touchpad_tap_enabled (MetaInputSettings *input_settings,
gboolean enabled;
if (device &&
- clutter_input_device_get_device_type (device) != CLUTTER_TOUCHPAD_DEVICE)
+ (clutter_input_device_get_capabilities (device) &
+ CLUTTER_INPUT_CAPABILITY_TOUCHPAD) == 0)
return;
priv = meta_input_settings_get_instance_private (input_settings);
@@ -584,7 +597,8 @@ update_touchpad_tap_enabled (MetaInputSettings *input_settings,
}
else
{
- settings_set_bool_setting (input_settings, CLUTTER_TOUCHPAD_DEVICE,
+ settings_set_bool_setting (input_settings,
+ CLUTTER_INPUT_CAPABILITY_TOUCHPAD,
force_enable_on_tablet,
input_settings_class->set_tap_enabled,
enabled);
@@ -600,7 +614,8 @@ update_touchpad_tap_button_map (MetaInputSettings *input_settings,
MetaInputSettingsPrivate *priv;
if (device &&
- clutter_input_device_get_device_type (device) != CLUTTER_TOUCHPAD_DEVICE)
+ (clutter_input_device_get_capabilities (device) &
+ CLUTTER_INPUT_CAPABILITY_TOUCHPAD) == 0)
return;
priv = meta_input_settings_get_instance_private (input_settings);
@@ -615,7 +630,8 @@ update_touchpad_tap_button_map (MetaInputSettings *input_settings,
}
else
{
- settings_set_uint_setting (input_settings, CLUTTER_TOUCHPAD_DEVICE,
+ settings_set_uint_setting (input_settings,
+ CLUTTER_INPUT_CAPABILITY_TOUCHPAD,
(ConfigUintFunc) input_settings_class->set_tap_button_map,
method);
}
@@ -630,7 +646,8 @@ update_touchpad_tap_and_drag_enabled (MetaInputSettings *input_settings,
gboolean enabled;
if (device &&
- clutter_input_device_get_device_type (device) != CLUTTER_TOUCHPAD_DEVICE)
+ (clutter_input_device_get_capabilities (device) &
+ CLUTTER_INPUT_CAPABILITY_TOUCHPAD) == 0)
return;
priv = meta_input_settings_get_instance_private (input_settings);
@@ -646,7 +663,8 @@ update_touchpad_tap_and_drag_enabled (MetaInputSettings *input_settings,
}
else
{
- settings_set_bool_setting (input_settings, CLUTTER_TOUCHPAD_DEVICE,
+ settings_set_bool_setting (input_settings,
+ CLUTTER_INPUT_CAPABILITY_TOUCHPAD,
force_enable_on_tablet,
input_settings_class->set_tap_and_drag_enabled,
enabled);
@@ -662,7 +680,8 @@ update_touchpad_tap_and_drag_lock_enabled (MetaInputSettings *input_settings,
gboolean enabled;
if (device &&
- clutter_input_device_get_device_type (device) != CLUTTER_TOUCHPAD_DEVICE)
+ (clutter_input_device_get_capabilities (device) &
+ CLUTTER_INPUT_CAPABILITY_TOUCHPAD) == 0)
return;
priv = meta_input_settings_get_instance_private (input_settings);
@@ -677,7 +696,8 @@ update_touchpad_tap_and_drag_lock_enabled (MetaInputSettings *input_settings,
}
else
{
- settings_set_bool_setting (input_settings, CLUTTER_TOUCHPAD_DEVICE,
+ settings_set_bool_setting (input_settings,
+ CLUTTER_INPUT_CAPABILITY_TOUCHPAD,
NULL,
input_settings_class->set_tap_and_drag_lock_enabled,
enabled);
@@ -695,7 +715,8 @@ update_touchpad_edge_scroll (MetaInputSettings *input_settings,
MetaInputSettingsPrivate *priv;
if (device &&
- clutter_input_device_get_device_type (device) != CLUTTER_TOUCHPAD_DEVICE)
+ (clutter_input_device_get_capabilities (device) &
+ CLUTTER_INPUT_CAPABILITY_TOUCHPAD) == 0)
return;
priv = meta_input_settings_get_instance_private (input_settings);
@@ -716,7 +737,8 @@ update_touchpad_edge_scroll (MetaInputSettings *input_settings,
}
else
{
- settings_set_bool_setting (input_settings, CLUTTER_TOUCHPAD_DEVICE, NULL,
+ settings_set_bool_setting (input_settings,
+ CLUTTER_INPUT_CAPABILITY_TOUCHPAD, NULL,
(ConfigBoolFunc) input_settings_class->set_edge_scroll,
edge_scroll_enabled);
}
@@ -731,7 +753,8 @@ update_touchpad_two_finger_scroll (MetaInputSettings *input_settings,
MetaInputSettingsPrivate *priv;
if (device &&
- clutter_input_device_get_device_type (device) != CLUTTER_TOUCHPAD_DEVICE)
+ (clutter_input_device_get_capabilities (device) &
+ CLUTTER_INPUT_CAPABILITY_TOUCHPAD) == 0)
return;
priv = meta_input_settings_get_instance_private (input_settings);
@@ -750,7 +773,8 @@ update_touchpad_two_finger_scroll (MetaInputSettings *input_settings,
}
else
{
- settings_set_bool_setting (input_settings, CLUTTER_TOUCHPAD_DEVICE, NULL,
+ settings_set_bool_setting (input_settings,
+ CLUTTER_INPUT_CAPABILITY_TOUCHPAD, NULL,
(ConfigBoolFunc) input_settings_class->set_two_finger_scroll,
two_finger_scroll_enabled);
}
@@ -769,7 +793,8 @@ update_touchpad_click_method (MetaInputSettings *input_settings,
MetaInputSettingsPrivate *priv;
if (device &&
- clutter_input_device_get_device_type (device) != CLUTTER_TOUCHPAD_DEVICE)
+ (clutter_input_device_get_capabilities (device) &
+ CLUTTER_INPUT_CAPABILITY_TOUCHPAD) == 0)
return;
priv = meta_input_settings_get_instance_private (input_settings);
@@ -784,7 +809,8 @@ update_touchpad_click_method (MetaInputSettings *input_settings,
}
else
{
- settings_set_uint_setting (input_settings, CLUTTER_TOUCHPAD_DEVICE,
+ settings_set_uint_setting (input_settings,
+ CLUTTER_INPUT_CAPABILITY_TOUCHPAD,
(ConfigUintFunc) input_settings_class->set_click_method,
method);
}
@@ -799,7 +825,8 @@ update_touchpad_send_events (MetaInputSettings *input_settings,
GDesktopDeviceSendEvents mode;
if (device &&
- clutter_input_device_get_device_type (device) != CLUTTER_TOUCHPAD_DEVICE)
+ (clutter_input_device_get_capabilities (device) &
+ CLUTTER_INPUT_CAPABILITY_TOUCHPAD) == 0)
return;
priv = meta_input_settings_get_instance_private (input_settings);
@@ -814,7 +841,8 @@ update_touchpad_send_events (MetaInputSettings *input_settings,
}
else
{
- settings_set_uint_setting (input_settings, CLUTTER_TOUCHPAD_DEVICE,
+ settings_set_uint_setting (input_settings,
+ CLUTTER_INPUT_CAPABILITY_TOUCHPAD,
input_settings_class->set_send_events,
mode);
}
@@ -890,9 +918,8 @@ update_tablet_keep_aspect (MetaInputSettings *input_settings,
gboolean keep_aspect;
double aspect_ratio;
- if (clutter_input_device_get_device_type (device) != CLUTTER_TABLET_DEVICE &&
- clutter_input_device_get_device_type (device) != CLUTTER_PEN_DEVICE &&
- clutter_input_device_get_device_type (device) != CLUTTER_ERASER_DEVICE)
+ if ((clutter_input_device_get_capabilities (device) &
+ CLUTTER_INPUT_CAPABILITY_TABLET_TOOL) == 0)
return;
priv = meta_input_settings_get_instance_private (input_settings);
@@ -933,9 +960,8 @@ update_tablet_mapping (MetaInputSettings *input_settings,
MetaInputSettingsClass *input_settings_class;
GDesktopTabletMapping mapping;
- if (clutter_input_device_get_device_type (device) != CLUTTER_TABLET_DEVICE &&
- clutter_input_device_get_device_type (device) != CLUTTER_PEN_DEVICE &&
- clutter_input_device_get_device_type (device) != CLUTTER_ERASER_DEVICE)
+ if ((clutter_input_device_get_capabilities (device) &
+ CLUTTER_INPUT_CAPABILITY_TABLET_TOOL) == 0)
return;
#ifdef HAVE_LIBWACOM
@@ -969,9 +995,8 @@ update_tablet_area (MetaInputSettings *input_settings,
const gdouble *area;
gsize n_elems;
- if (clutter_input_device_get_device_type (device) != CLUTTER_TABLET_DEVICE &&
- clutter_input_device_get_device_type (device) != CLUTTER_PEN_DEVICE &&
- clutter_input_device_get_device_type (device) != CLUTTER_ERASER_DEVICE)
+ if ((clutter_input_device_get_capabilities (device) &
+ CLUTTER_INPUT_CAPABILITY_TABLET_TOOL) == 0)
return;
#ifdef HAVE_LIBWACOM
@@ -1010,10 +1035,9 @@ update_tablet_left_handed (MetaInputSettings *input_settings,
MetaInputSettingsClass *input_settings_class;
gboolean enabled;
- if (clutter_input_device_get_device_type (device) != CLUTTER_TABLET_DEVICE &&
- clutter_input_device_get_device_type (device) != CLUTTER_PEN_DEVICE &&
- clutter_input_device_get_device_type (device) != CLUTTER_ERASER_DEVICE &&
- clutter_input_device_get_device_type (device) != CLUTTER_PAD_DEVICE)
+ if ((clutter_input_device_get_capabilities (device) &
+ (CLUTTER_INPUT_CAPABILITY_TABLET_TOOL |
+ CLUTTER_INPUT_CAPABILITY_TABLET_PAD)) == 0)
return;
#ifdef HAVE_LIBWACOM
@@ -1125,14 +1149,13 @@ static void
apply_mappable_device_settings (MetaInputSettings *input_settings,
DeviceMappingInfo *info)
{
- ClutterInputDeviceType device_type;
+ ClutterInputCapabilities capabilities;
- device_type = clutter_input_device_get_device_type (info->device);
+ capabilities = clutter_input_device_get_capabilities (info->device);
- if (device_type == CLUTTER_TABLET_DEVICE ||
- device_type == CLUTTER_PEN_DEVICE ||
- device_type == CLUTTER_ERASER_DEVICE ||
- device_type == CLUTTER_PAD_DEVICE)
+ if (capabilities &
+ (CLUTTER_INPUT_CAPABILITY_TABLET_TOOL |
+ CLUTTER_INPUT_CAPABILITY_TABLET_PAD))
{
update_tablet_mapping (input_settings, info->settings, info->device);
update_tablet_area (input_settings, info->settings, info->device);
@@ -1223,28 +1246,28 @@ static GSettings *
lookup_device_settings (ClutterInputDevice *device)
{
const gchar *group, *schema, *vendor, *product;
- ClutterInputDeviceType type;
+ ClutterInputCapabilities capabilities;
GSettings *settings;
gchar *path;
- type = clutter_input_device_get_device_type (device);
+ capabilities = clutter_input_device_get_capabilities (device);
- if (type == CLUTTER_TOUCHSCREEN_DEVICE)
+ if ((capabilities &
+ (CLUTTER_INPUT_CAPABILITY_TABLET_TOOL |
+ CLUTTER_INPUT_CAPABILITY_TABLET_PAD)) != 0)
+ {
+ group = "tablets";
+ schema = "org.gnome.desktop.peripherals.tablet";
+ }
+ else if ((capabilities & CLUTTER_INPUT_CAPABILITY_TOUCH) != 0)
{
group = "touchscreens";
schema = "org.gnome.desktop.peripherals.touchscreen";
}
- else if (type == CLUTTER_TABLET_DEVICE ||
- type == CLUTTER_PEN_DEVICE ||
- type == CLUTTER_ERASER_DEVICE ||
- type == CLUTTER_CURSOR_DEVICE ||
- type == CLUTTER_PAD_DEVICE)
+ else
{
- group = "tablets";
- schema = "org.gnome.desktop.peripherals.tablet";
+ return NULL;
}
- else
- return NULL;
vendor = clutter_input_device_get_vendor_id (device);
product = clutter_input_device_get_product_id (device);
@@ -1310,15 +1333,14 @@ check_add_mappable_device (MetaInputSettings *input_settings,
{
MetaInputSettingsPrivate *priv;
DeviceMappingInfo *info;
- ClutterInputDeviceType device_type;
+ ClutterInputCapabilities capabilities;
GSettings *settings;
- device_type = clutter_input_device_get_device_type (device);
+ capabilities = clutter_input_device_get_capabilities (device);
- if ((device_type == CLUTTER_TABLET_DEVICE ||
- device_type == CLUTTER_PEN_DEVICE ||
- device_type == CLUTTER_ERASER_DEVICE ||
- device_type == CLUTTER_PAD_DEVICE) &&
+ if ((capabilities &
+ (CLUTTER_INPUT_CAPABILITY_TABLET_TOOL |
+ CLUTTER_INPUT_CAPABILITY_TABLET_PAD)) != 0 &&
g_getenv ("MUTTER_DISABLE_WACOM_CONFIGURATION") != NULL)
return FALSE;
@@ -1334,7 +1356,7 @@ check_add_mappable_device (MetaInputSettings *input_settings,
info->device = device;
info->settings = settings;
- if (device_type == CLUTTER_PAD_DEVICE)
+ if ((capabilities & CLUTTER_INPUT_CAPABILITY_TABLET_PAD) != 0)
{
info->group_modes =
g_new0 (guint, clutter_input_device_get_n_mode_groups (device));
@@ -1398,9 +1420,8 @@ update_stylus_pressure (MetaInputSettings *input_settings,
GVariant *variant;
gsize n_elems;
- if (clutter_input_device_get_device_type (device) != CLUTTER_TABLET_DEVICE &&
- clutter_input_device_get_device_type (device) != CLUTTER_PEN_DEVICE &&
- clutter_input_device_get_device_type (device) != CLUTTER_ERASER_DEVICE)
+ if ((clutter_input_device_get_capabilities (device) &
+ CLUTTER_INPUT_CAPABILITY_TABLET_TOOL) == 0)
return;
if (!tool)
@@ -1431,9 +1452,8 @@ update_stylus_buttonmap (MetaInputSettings *input_settings,
GDesktopStylusButtonAction primary, secondary, tertiary;
GSettings *tool_settings;
- if (clutter_input_device_get_device_type (device) != CLUTTER_TABLET_DEVICE &&
- clutter_input_device_get_device_type (device) != CLUTTER_PEN_DEVICE &&
- clutter_input_device_get_device_type (device) != CLUTTER_ERASER_DEVICE)
+ if ((clutter_input_device_get_capabilities (device) &
+ CLUTTER_INPUT_CAPABILITY_TABLET_TOOL) == 0)
return;
if (!tool)
@@ -1466,7 +1486,8 @@ evaluate_two_finger_scrolling (MetaInputSettings *input_settings,
MetaInputSettingsClass *klass;
MetaInputSettingsPrivate *priv;
- if (clutter_input_device_get_device_type (device) != CLUTTER_TOUCHPAD_DEVICE)
+ if ((clutter_input_device_get_capabilities (device) &
+ CLUTTER_INPUT_CAPABILITY_TOUCHPAD) == 0)
return;
klass = META_INPUT_SETTINGS_GET_CLASS (input_settings);
@@ -1594,7 +1615,8 @@ meta_input_settings_constructed (GObject *object)
MetaInputSettings *input_settings = META_INPUT_SETTINGS (object);
GSList *devices, *d;
- devices = meta_input_settings_get_devices (input_settings, CLUTTER_TOUCHPAD_DEVICE);
+ devices = meta_input_settings_get_devices (input_settings,
+ CLUTTER_INPUT_CAPABILITY_TOUCHPAD);
for (d = devices; d; d = d->next)
evaluate_two_finger_scrolling (input_settings, d->data);
--
GitLab
From e7bee31884b9adf0ab71d0a010a3ef426351e97a Mon Sep 17 00:00:00 2001
From: Carlos Garnacho <carlosg@gnome.org>
Date: Tue, 8 Mar 2022 18:17:56 +0100
2022-03-09 16:48:49 +00:00
Subject: [PATCH 09/10] core: Port to input device capabilities in pad mapper
Check for tablets and pad devices using capabilities.
---
src/core/meta-pad-action-mapper.c | 16 +++++++++-------
1 file changed, 9 insertions(+), 7 deletions(-)
diff --git a/src/core/meta-pad-action-mapper.c b/src/core/meta-pad-action-mapper.c
index d80878304e..dc43924b55 100644
--- a/src/core/meta-pad-action-mapper.c
+++ b/src/core/meta-pad-action-mapper.c
@@ -141,7 +141,8 @@ device_added (ClutterSeat *seat,
{
PadMappingInfo *info;
- if (clutter_input_device_get_device_type (device) == CLUTTER_PAD_DEVICE)
+ if ((clutter_input_device_get_capabilities (device) &
+ CLUTTER_INPUT_CAPABILITY_TABLET_PAD) != 0)
{
info = pad_mapping_info_new (device);
g_hash_table_insert (mapper->pads, device, info);
@@ -384,8 +385,9 @@ meta_pad_action_mapper_cycle_tablet_output (MetaPadActionMapper *mapper,
g_return_if_fail (META_IS_PAD_ACTION_MAPPER (mapper));
g_return_if_fail (CLUTTER_IS_INPUT_DEVICE (device));
- g_return_if_fail (clutter_input_device_get_device_type (device) == CLUTTER_TABLET_DEVICE ||
- clutter_input_device_get_device_type (device) == CLUTTER_PAD_DEVICE);
+ g_return_if_fail ((clutter_input_device_get_capabilities (device) &
+ (CLUTTER_INPUT_CAPABILITY_TABLET_TOOL |
+ CLUTTER_INPUT_CAPABILITY_TABLET_PAD)) != 0);
info = g_hash_table_lookup (mapper->pads, device);
g_return_if_fail (info != NULL);
@@ -439,8 +441,8 @@ meta_pad_action_mapper_is_button_grabbed (MetaPadActionMapper *mapper,
{
g_return_val_if_fail (META_IS_PAD_ACTION_MAPPER (mapper), FALSE);
g_return_val_if_fail (CLUTTER_IS_INPUT_DEVICE (pad), FALSE);
- g_return_val_if_fail (clutter_input_device_get_device_type (pad) ==
- CLUTTER_PAD_DEVICE, FALSE);
+ g_return_val_if_fail ((clutter_input_device_get_capabilities (pad) &
+ CLUTTER_INPUT_CAPABILITY_TABLET_PAD) != 0, FALSE);
return (meta_pad_action_mapper_get_button_action (mapper, pad, button) !=
G_DESKTOP_PAD_BUTTON_ACTION_NONE);
@@ -827,8 +829,8 @@ meta_pad_action_mapper_get_button_label (MetaPadActionMapper *mapper,
g_return_val_if_fail (META_IS_PAD_ACTION_MAPPER (mapper), NULL);
g_return_val_if_fail (CLUTTER_IS_INPUT_DEVICE (pad), NULL);
- g_return_val_if_fail (clutter_input_device_get_device_type (pad) ==
- CLUTTER_PAD_DEVICE, NULL);
+ g_return_val_if_fail ((clutter_input_device_get_capabilities (pad) &
+ CLUTTER_INPUT_CAPABILITY_TABLET_PAD) != 0, NULL);
group = clutter_input_device_get_mode_switch_button_group (pad, button);
--
GitLab
2022-03-09 16:48:49 +00:00
From 8e27195bebd90c6aba2e669f4c3e7da8eb1e78aa Mon Sep 17 00:00:00 2001
From: Carlos Garnacho <carlosg@gnome.org>
Date: Wed, 9 Mar 2022 12:19:20 +0100
Subject: [PATCH 10/10] backends: Set mapping function for left-handed setting
We have separate left-handed settings for mice and touchpads,
which are slightly harder to be kept separate querying devices
by capabilities. These should just relate if the "follow mouse"
handedness is set on touchpads.
In order to keep applying the setting in a fine grained manner,
add a mapping function for the left-handed setting on mice, this
will replace the right configuration value depending on the pointer
device it is dealing with.
This ensures mouse preferences don't overwrite touchpad behavior
unless that preference is enabled.
---
src/backends/meta-input-settings.c | 45 +++++++++++++++++++++++-------
1 file changed, 35 insertions(+), 10 deletions(-)
diff --git a/src/backends/meta-input-settings.c b/src/backends/meta-input-settings.c
index d045315fa7..a2a6e6230f 100644
--- a/src/backends/meta-input-settings.c
+++ b/src/backends/meta-input-settings.c
@@ -281,6 +281,39 @@ update_touchpad_left_handed (MetaInputSettings *input_settings,
}
}
+static gboolean
+apply_device_handedness (MetaInputSettings *input_settings,
+ ClutterInputDevice *device,
+ gboolean value)
+{
+ if ((clutter_input_device_get_capabilities (device) &
+ CLUTTER_INPUT_CAPABILITY_TOUCHPAD) != 0)
+ {
+ GDesktopTouchpadHandedness handedness;
+ MetaInputSettingsPrivate *priv;
+
+ /* Look up correct handedness on touchpads */
+ priv = meta_input_settings_get_instance_private (input_settings);
+ handedness = g_settings_get_enum (priv->touchpad_settings, "left-handed");
+
+ switch (handedness)
+ {
+ case G_DESKTOP_TOUCHPAD_HANDEDNESS_RIGHT:
+ value = FALSE;
+ break;
+ case G_DESKTOP_TOUCHPAD_HANDEDNESS_LEFT:
+ value = TRUE;
+ break;
+ case G_DESKTOP_TOUCHPAD_HANDEDNESS_MOUSE:
+ break;
+ default:
+ g_assert_not_reached ();
+ }
+ }
+
+ return value;
+}
+
static void
update_mouse_left_handed (MetaInputSettings *input_settings,
ClutterInputDevice *device)
@@ -312,19 +345,11 @@ update_mouse_left_handed (MetaInputSettings *input_settings,
}
else
{
- GDesktopTouchpadHandedness touchpad_handedness;
-
settings_set_bool_setting (input_settings,
- CLUTTER_INPUT_CAPABILITY_POINTER, NULL,
+ CLUTTER_INPUT_CAPABILITY_POINTER,
+ apply_device_handedness,
input_settings_class->set_left_handed,
enabled);
-
- touchpad_handedness = g_settings_get_enum (priv->touchpad_settings,
- "left-handed");
-
- /* Also update touchpads if they're following mouse settings */
- if (touchpad_handedness == G_DESKTOP_TOUCHPAD_HANDEDNESS_MOUSE)
- update_touchpad_left_handed (input_settings, NULL);
}
}
--
GitLab