mutter/2331.patch

1439 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-10 19:47:02 +00:00
Subject: [PATCH 1/9] 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
2022-03-10 19:47:02 +00:00
From ac0dd8b7a10f4ba87a47d6d1fe7a82733e5b971b Mon Sep 17 00:00:00 2001
From: Carlos Garnacho <carlosg@gnome.org>
Date: Tue, 8 Mar 2022 17:03:31 +0100
2022-03-10 19:47:02 +00:00
Subject: [PATCH 2/9] 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.
---
2022-03-10 19:47:02 +00:00
clutter/clutter/clutter-enums.h | 23 +++++++++++++++++++++++
1 file changed, 23 insertions(+)
diff --git a/clutter/clutter/clutter-enums.h b/clutter/clutter/clutter-enums.h
2022-03-10 19:47:02 +00:00
index 9ee55fb5c4..99debc1c11 100644
--- a/clutter/clutter/clutter-enums.h
+++ b/clutter/clutter/clutter-enums.h
2022-03-10 19:47:02 +00:00
@@ -935,6 +935,29 @@ typedef enum /*< prefix=CLUTTER_FLOW >*/
CLUTTER_FLOW_VERTICAL
} ClutterFlowOrientation;
+/**
+ * ClutterInputDeviceCapabilities:
2022-03-10 19:47:02 +00:00
+ * @CLUTTER_INPUT_CAPABILITY_NONE: No capabilities
+ * @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 >*/
+{
2022-03-10 19:47:02 +00:00
+ CLUTTER_INPUT_CAPABILITY_NONE = 0,
+ 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
2022-03-10 19:47:02 +00:00
From 65aa4bbfd09bfbdfe5759d4bc3fe46c42ca21e14 Mon Sep 17 00:00:00 2001
From: Carlos Garnacho <carlosg@gnome.org>
Date: Tue, 8 Mar 2022 17:04:40 +0100
2022-03-10 19:47:02 +00:00
Subject: [PATCH 3/9] 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
2022-03-10 19:47:02 +00:00
From 849004edb8373174c3f04d79c6be7ed6e191d934 Mon Sep 17 00:00:00 2001
From: Carlos Garnacho <carlosg@gnome.org>
Date: Tue, 8 Mar 2022 17:05:44 +0100
2022-03-10 19:47:02 +00:00
Subject: [PATCH 4/9] 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
2022-03-10 19:47:02 +00:00
From 73f2d0696119dc8fbc5d33fbaaba8cb7cef0d819 Mon Sep 17 00:00:00 2001
From: Carlos Garnacho <carlosg@gnome.org>
Date: Tue, 8 Mar 2022 17:12:42 +0100
2022-03-10 19:47:02 +00:00
Subject: [PATCH 5/9] clutter: Add compatibility code to get input capabilities
from device type
We not just have X11 devices, but also virtual devices on both backends.
2022-03-10 19:47:02 +00:00
In the mean time, keep these working on top of a ClutterInputDeviceType,
but transform that into capabilities on device construction so users can
rely on the new flagset.
---
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
2022-03-10 19:47:02 +00:00
From 8210aaa960b7d72818e7d2683f18f6343c7d463c Mon Sep 17 00:00:00 2001
From: Carlos Garnacho <carlosg@gnome.org>
Date: Tue, 8 Mar 2022 17:26:43 +0100
2022-03-10 19:47:02 +00:00
Subject: [PATCH 6/9] 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
2022-03-10 19:47:02 +00:00
From b18cf1de5cae178f8760dd13b0df0946fb964824 Mon Sep 17 00:00:00 2001
From: Carlos Garnacho <carlosg@gnome.org>
Date: Tue, 8 Mar 2022 17:31:20 +0100
2022-03-10 19:47:02 +00:00
Subject: [PATCH 7/9] 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
2022-03-10 19:47:02 +00:00
From 7f46fe60b73e3bf644e77dead18786e138dab4fe Mon Sep 17 00:00:00 2001
From: Carlos Garnacho <carlosg@gnome.org>
Date: Tue, 8 Mar 2022 17:51:40 +0100
2022-03-10 19:47:02 +00:00
Subject: [PATCH 8/9] 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.
- 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.
---
2022-03-10 19:47:02 +00:00
src/backends/meta-input-settings.c | 329 +++++++++++++++++++----------
1 file changed, 213 insertions(+), 116 deletions(-)
diff --git a/src/backends/meta-input-settings.c b/src/backends/meta-input-settings.c
2022-03-10 19:47:02 +00:00
index 16618608bb..7d03d7182c 100644
--- a/src/backends/meta-input-settings.c
+++ b/src/backends/meta-input-settings.c
2022-03-10 19:47:02 +00:00
@@ -109,9 +109,27 @@ enum
static guint signals[N_SIGNALS] = { 0 };
2022-03-10 19:47:02 +00:00
+static gboolean
+device_matches_capabilities (ClutterInputDevice *device,
+ ClutterInputCapabilities require_capabilities,
+ ClutterInputCapabilities reject_capabilities)
+{
+ ClutterInputCapabilities capabilities;
+
+ capabilities = clutter_input_device_get_capabilities (device);
+
+ if ((capabilities & require_capabilities) != require_capabilities)
+ return FALSE;
+ if ((capabilities & reject_capabilities) != 0)
+ return FALSE;
+
+ return TRUE;
+}
+
static GSList *
-meta_input_settings_get_devices (MetaInputSettings *settings,
- ClutterInputDeviceType type)
+meta_input_settings_get_devices (MetaInputSettings *settings,
2022-03-10 19:47:02 +00:00
+ ClutterInputCapabilities require_capabilities,
+ ClutterInputCapabilities reject_capabilities)
{
MetaInputSettingsPrivate *priv;
GList *l;
2022-03-10 19:47:02 +00:00
@@ -123,9 +141,15 @@ meta_input_settings_get_devices (MetaInputSettings *settings,
{
ClutterInputDevice *device = l->data;
- if (clutter_input_device_get_device_type (device) == type &&
2022-03-10 19:47:02 +00:00
- clutter_input_device_get_device_mode (device) != CLUTTER_INPUT_MODE_LOGICAL)
- list = g_slist_prepend (list, device);
+ if (clutter_input_device_get_device_mode (device) == CLUTTER_INPUT_MODE_LOGICAL)
+ continue;
+
+ if (!device_matches_capabilities (device,
+ require_capabilities,
+ reject_capabilities))
+ continue;
+
+ list = g_slist_prepend (list, device);
}
2022-03-10 19:47:02 +00:00
return list;
@@ -160,15 +184,18 @@ 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,
2022-03-10 19:47:02 +00:00
+ ClutterInputCapabilities unset_capabilities,
+ ConfigBoolMappingFunc mapping_func,
+ ConfigBoolFunc func,
+ gboolean enabled)
{
GSList *devices, *l;
- devices = meta_input_settings_get_devices (input_settings, type);
2022-03-10 19:47:02 +00:00
+ devices = meta_input_settings_get_devices (input_settings,
+ capabilities,
+ unset_capabilities);
for (l = devices; l; l = l->next)
{
2022-03-10 19:47:02 +00:00
@@ -192,14 +219,17 @@ 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,
2022-03-10 19:47:02 +00:00
+ ClutterInputCapabilities unset_capabilities,
+ ConfigDoubleFunc func,
+ gdouble value)
{
GSList *devices, *d;
- devices = meta_input_settings_get_devices (input_settings, type);
2022-03-10 19:47:02 +00:00
+ devices = meta_input_settings_get_devices (input_settings,
+ capabilities,
+ unset_capabilities);
for (d = devices; d; d = d->next)
settings_device_set_double_setting (input_settings, d->data, func, value);
2022-03-10 19:47:02 +00:00
@@ -217,14 +247,17 @@ 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,
2022-03-10 19:47:02 +00:00
+ ClutterInputCapabilities unset_capabilities,
+ ConfigUintFunc func,
+ guint value)
{
GSList *devices, *d;
- devices = meta_input_settings_get_devices (input_settings, type);
2022-03-10 19:47:02 +00:00
+ devices = meta_input_settings_get_devices (input_settings,
+ capabilities,
+ unset_capabilities);
for (d = devices; d; d = d->next)
settings_device_set_uint_setting (input_settings, d->data, func, value);
2022-03-10 19:47:02 +00:00
@@ -242,7 +275,9 @@ update_touchpad_left_handed (MetaInputSettings *input_settings,
gboolean enabled = FALSE;
if (device &&
- clutter_input_device_get_device_type (device) != CLUTTER_TOUCHPAD_DEVICE)
2022-03-10 19:47:02 +00:00
+ !device_matches_capabilities (device,
+ CLUTTER_INPUT_CAPABILITY_TOUCHPAD,
+ CLUTTER_INPUT_CAPABILITY_NONE))
return;
priv = meta_input_settings_get_instance_private (input_settings);
2022-03-10 19:47:02 +00:00
@@ -272,7 +307,10 @@ update_touchpad_left_handed (MetaInputSettings *input_settings,
}
else
{
- settings_set_bool_setting (input_settings, CLUTTER_TOUCHPAD_DEVICE, NULL,
+ settings_set_bool_setting (input_settings,
2022-03-10 19:47:02 +00:00
+ CLUTTER_INPUT_CAPABILITY_TOUCHPAD,
+ CLUTTER_INPUT_CAPABILITY_NONE,
+ NULL,
input_settings_class->set_left_handed,
enabled);
}
2022-03-10 19:47:02 +00:00
@@ -287,7 +325,9 @@ update_mouse_left_handed (MetaInputSettings *input_settings,
gboolean enabled;
2022-03-10 19:47:02 +00:00
if (device &&
- clutter_input_device_get_device_type (device) != CLUTTER_POINTER_DEVICE)
2022-03-10 19:47:02 +00:00
+ !device_matches_capabilities (device,
+ CLUTTER_INPUT_CAPABILITY_POINTER,
+ CLUTTER_INPUT_CAPABILITY_TOUCHPAD))
return;
priv = meta_input_settings_get_instance_private (input_settings);
2022-03-10 19:47:02 +00:00
@@ -304,7 +344,10 @@ 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,
2022-03-10 19:47:02 +00:00
+ CLUTTER_INPUT_CAPABILITY_POINTER,
+ CLUTTER_INPUT_CAPABILITY_TOUCHPAD,
+ NULL,
input_settings_class->set_left_handed,
enabled);
2022-03-10 19:47:02 +00:00
@@ -373,20 +416,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
2022-03-10 19:47:02 +00:00
@@ -417,7 +459,9 @@ 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,
2022-03-10 19:47:02 +00:00
+ CLUTTER_INPUT_CAPABILITY_NONE,
NULL, func,
g_settings_get_boolean (settings, key));
}
2022-03-10 19:47:02 +00:00
@@ -435,8 +479,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;
2022-03-10 19:47:02 +00:00
@@ -445,11 +489,20 @@ 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,
2022-03-10 19:47:02 +00:00
+ settings = get_settings_for_capabilities (input_settings,
+ CLUTTER_INPUT_CAPABILITY_POINTER);
+ settings_set_double_setting (input_settings,
+ CLUTTER_INPUT_CAPABILITY_POINTER,
+ CLUTTER_INPUT_CAPABILITY_TOUCHPAD,
+ 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,
2022-03-10 19:47:02 +00:00
+
+ settings = get_settings_for_capabilities (input_settings,
2022-03-10 19:47:02 +00:00
+ CLUTTER_INPUT_CAPABILITY_TOUCHPAD);
+ settings_set_double_setting (input_settings,
2022-03-10 19:47:02 +00:00
+ CLUTTER_INPUT_CAPABILITY_TOUCHPAD,
+ CLUTTER_INPUT_CAPABILITY_NONE,
+ func,
g_settings_get_double (settings, key));
}
}
2022-03-10 19:47:02 +00:00
@@ -466,8 +519,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;
2022-03-10 19:47:02 +00:00
@@ -476,12 +529,19 @@ 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,
+ settings = get_settings_for_capabilities (input_settings,
+ CLUTTER_INPUT_CAPABILITY_POINTER);
+ settings_set_bool_setting (input_settings,
+ CLUTTER_INPUT_CAPABILITY_POINTER,
2022-03-10 19:47:02 +00:00
+ CLUTTER_INPUT_CAPABILITY_TOUCHPAD,
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_TOUCHPAD);
+ settings_set_bool_setting (input_settings,
+ CLUTTER_INPUT_CAPABILITY_TOUCHPAD,
+ CLUTTER_INPUT_CAPABILITY_NONE,
NULL, func,
g_settings_get_boolean (settings, key));
}
2022-03-10 19:47:02 +00:00
@@ -498,7 +558,9 @@ 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)
2022-03-10 19:47:02 +00:00
+ !device_matches_capabilities (device,
+ CLUTTER_INPUT_CAPABILITY_TOUCHPAD,
+ CLUTTER_INPUT_CAPABILITY_NONE))
return;
priv = meta_input_settings_get_instance_private (input_settings);
2022-03-10 19:47:02 +00:00
@@ -507,8 +569,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;
2022-03-10 19:47:02 +00:00
@@ -519,7 +581,10 @@ 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,
2022-03-10 19:47:02 +00:00
+ CLUTTER_INPUT_CAPABILITY_TOUCHPAD,
+ CLUTTER_INPUT_CAPABILITY_NONE,
+ NULL,
input_settings_class->set_disable_while_typing,
enabled);
}
2022-03-10 19:47:02 +00:00
@@ -533,7 +598,10 @@ 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 &&
2022-03-10 19:47:02 +00:00
+ !device_matches_capabilities (device,
+ CLUTTER_INPUT_CAPABILITY_TOUCHPAD,
+ CLUTTER_INPUT_CAPABILITY_NONE))
return FALSE;
wacom_device = meta_input_device_get_wacom_device (META_INPUT_DEVICE (device));
2022-03-10 19:47:02 +00:00
@@ -568,7 +636,9 @@ update_touchpad_tap_enabled (MetaInputSettings *input_settings,
gboolean enabled;
if (device &&
- clutter_input_device_get_device_type (device) != CLUTTER_TOUCHPAD_DEVICE)
2022-03-10 19:47:02 +00:00
+ !device_matches_capabilities (device,
+ CLUTTER_INPUT_CAPABILITY_TOUCHPAD,
+ CLUTTER_INPUT_CAPABILITY_NONE))
return;
priv = meta_input_settings_get_instance_private (input_settings);
2022-03-10 19:47:02 +00:00
@@ -584,7 +654,9 @@ 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,
2022-03-10 19:47:02 +00:00
+ CLUTTER_INPUT_CAPABILITY_NONE,
force_enable_on_tablet,
input_settings_class->set_tap_enabled,
enabled);
2022-03-10 19:47:02 +00:00
@@ -600,7 +672,9 @@ update_touchpad_tap_button_map (MetaInputSettings *input_settings,
MetaInputSettingsPrivate *priv;
if (device &&
- clutter_input_device_get_device_type (device) != CLUTTER_TOUCHPAD_DEVICE)
2022-03-10 19:47:02 +00:00
+ !device_matches_capabilities (device,
+ CLUTTER_INPUT_CAPABILITY_TOUCHPAD,
+ CLUTTER_INPUT_CAPABILITY_NONE))
return;
priv = meta_input_settings_get_instance_private (input_settings);
2022-03-10 19:47:02 +00:00
@@ -615,7 +689,9 @@ 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,
2022-03-10 19:47:02 +00:00
+ CLUTTER_INPUT_CAPABILITY_NONE,
(ConfigUintFunc) input_settings_class->set_tap_button_map,
method);
}
2022-03-10 19:47:02 +00:00
@@ -630,7 +706,9 @@ update_touchpad_tap_and_drag_enabled (MetaInputSettings *input_settings,
gboolean enabled;
if (device &&
- clutter_input_device_get_device_type (device) != CLUTTER_TOUCHPAD_DEVICE)
2022-03-10 19:47:02 +00:00
+ !device_matches_capabilities (device,
+ CLUTTER_INPUT_CAPABILITY_TOUCHPAD,
+ CLUTTER_INPUT_CAPABILITY_NONE))
return;
priv = meta_input_settings_get_instance_private (input_settings);
2022-03-10 19:47:02 +00:00
@@ -646,7 +724,9 @@ 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,
2022-03-10 19:47:02 +00:00
+ CLUTTER_INPUT_CAPABILITY_NONE,
force_enable_on_tablet,
input_settings_class->set_tap_and_drag_enabled,
enabled);
2022-03-10 19:47:02 +00:00
@@ -662,7 +742,9 @@ update_touchpad_tap_and_drag_lock_enabled (MetaInputSettings *input_settings,
gboolean enabled;
if (device &&
- clutter_input_device_get_device_type (device) != CLUTTER_TOUCHPAD_DEVICE)
2022-03-10 19:47:02 +00:00
+ !device_matches_capabilities (device,
+ CLUTTER_INPUT_CAPABILITY_TOUCHPAD,
+ CLUTTER_INPUT_CAPABILITY_NONE))
return;
priv = meta_input_settings_get_instance_private (input_settings);
2022-03-10 19:47:02 +00:00
@@ -677,7 +759,9 @@ 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,
2022-03-10 19:47:02 +00:00
+ CLUTTER_INPUT_CAPABILITY_NONE,
NULL,
input_settings_class->set_tap_and_drag_lock_enabled,
enabled);
2022-03-10 19:47:02 +00:00
@@ -695,7 +779,9 @@ update_touchpad_edge_scroll (MetaInputSettings *input_settings,
MetaInputSettingsPrivate *priv;
if (device &&
- clutter_input_device_get_device_type (device) != CLUTTER_TOUCHPAD_DEVICE)
2022-03-10 19:47:02 +00:00
+ !device_matches_capabilities (device,
+ CLUTTER_INPUT_CAPABILITY_TOUCHPAD,
+ CLUTTER_INPUT_CAPABILITY_NONE))
return;
priv = meta_input_settings_get_instance_private (input_settings);
2022-03-10 19:47:02 +00:00
@@ -716,7 +802,10 @@ update_touchpad_edge_scroll (MetaInputSettings *input_settings,
}
else
{
- settings_set_bool_setting (input_settings, CLUTTER_TOUCHPAD_DEVICE, NULL,
+ settings_set_bool_setting (input_settings,
2022-03-10 19:47:02 +00:00
+ CLUTTER_INPUT_CAPABILITY_TOUCHPAD,
+ CLUTTER_INPUT_CAPABILITY_NONE,
+ NULL,
(ConfigBoolFunc) input_settings_class->set_edge_scroll,
edge_scroll_enabled);
}
2022-03-10 19:47:02 +00:00
@@ -731,7 +820,9 @@ update_touchpad_two_finger_scroll (MetaInputSettings *input_settings,
MetaInputSettingsPrivate *priv;
if (device &&
- clutter_input_device_get_device_type (device) != CLUTTER_TOUCHPAD_DEVICE)
2022-03-10 19:47:02 +00:00
+ !device_matches_capabilities (device,
+ CLUTTER_INPUT_CAPABILITY_TOUCHPAD,
+ CLUTTER_INPUT_CAPABILITY_NONE))
return;
priv = meta_input_settings_get_instance_private (input_settings);
2022-03-10 19:47:02 +00:00
@@ -750,7 +841,10 @@ 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,
2022-03-10 19:47:02 +00:00
+ CLUTTER_INPUT_CAPABILITY_TOUCHPAD,
+ CLUTTER_INPUT_CAPABILITY_NONE,
+ NULL,
(ConfigBoolFunc) input_settings_class->set_two_finger_scroll,
two_finger_scroll_enabled);
}
2022-03-10 19:47:02 +00:00
@@ -769,7 +863,9 @@ update_touchpad_click_method (MetaInputSettings *input_settings,
MetaInputSettingsPrivate *priv;
if (device &&
- clutter_input_device_get_device_type (device) != CLUTTER_TOUCHPAD_DEVICE)
2022-03-10 19:47:02 +00:00
+ !device_matches_capabilities (device,
+ CLUTTER_INPUT_CAPABILITY_TOUCHPAD,
+ CLUTTER_INPUT_CAPABILITY_NONE))
return;
priv = meta_input_settings_get_instance_private (input_settings);
2022-03-10 19:47:02 +00:00
@@ -784,7 +880,9 @@ 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,
2022-03-10 19:47:02 +00:00
+ CLUTTER_INPUT_CAPABILITY_NONE,
(ConfigUintFunc) input_settings_class->set_click_method,
method);
}
2022-03-10 19:47:02 +00:00
@@ -799,7 +897,9 @@ update_touchpad_send_events (MetaInputSettings *input_settings,
GDesktopDeviceSendEvents mode;
if (device &&
- clutter_input_device_get_device_type (device) != CLUTTER_TOUCHPAD_DEVICE)
2022-03-10 19:47:02 +00:00
+ !device_matches_capabilities (device,
+ CLUTTER_INPUT_CAPABILITY_TOUCHPAD,
+ CLUTTER_INPUT_CAPABILITY_NONE))
return;
priv = meta_input_settings_get_instance_private (input_settings);
2022-03-10 19:47:02 +00:00
@@ -814,7 +914,9 @@ 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,
2022-03-10 19:47:02 +00:00
+ CLUTTER_INPUT_CAPABILITY_NONE,
input_settings_class->set_send_events,
mode);
}
2022-03-10 19:47:02 +00:00
@@ -890,9 +992,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);
2022-03-10 19:47:02 +00:00
@@ -933,9 +1034,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
2022-03-10 19:47:02 +00:00
@@ -969,9 +1069,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
2022-03-10 19:47:02 +00:00
@@ -1010,10 +1109,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
2022-03-10 19:47:02 +00:00
@@ -1125,14 +1223,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);
2022-03-10 19:47:02 +00:00
@@ -1223,28 +1320,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);
2022-03-10 19:47:02 +00:00
@@ -1310,15 +1407,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;
2022-03-10 19:47:02 +00:00
@@ -1334,7 +1430,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));
2022-03-10 19:47:02 +00:00
@@ -1398,9 +1494,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)
2022-03-10 19:47:02 +00:00
@@ -1431,9 +1526,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)
2022-03-10 19:47:02 +00:00
@@ -1466,7 +1560,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);
2022-03-10 19:47:02 +00:00
@@ -1594,7 +1689,9 @@ 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,
2022-03-10 19:47:02 +00:00
+ CLUTTER_INPUT_CAPABILITY_TOUCHPAD,
+ CLUTTER_INPUT_CAPABILITY_NONE);
for (d = devices; d; d = d->next)
evaluate_two_finger_scrolling (input_settings, d->data);
--
GitLab
2022-03-10 19:47:02 +00:00
From 21d242f45c1f64a5c0ff07c4a003f2334eb70459 Mon Sep 17 00:00:00 2001
From: Carlos Garnacho <carlosg@gnome.org>
Date: Tue, 8 Mar 2022 18:17:56 +0100
2022-03-10 19:47:02 +00:00
Subject: [PATCH 9/9] 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