summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarlos Garnacho <carlosg@gnome.org>2022-03-08 17:31:20 +0100
committerMarge Bot <marge-bot@gnome.org>2022-03-30 12:06:52 +0000
commitfff36549418eafb21b41192beb0e0e39f0fe5467 (patch)
tree6bc1d9ec7f2033c5b05246be2c70721375364b1b
parent844a729fa95f4418b38f654a8b7378ea4b57e089 (diff)
downloadmutter-fff36549418eafb21b41192beb0e0e39f0fe5467.tar.gz
wayland: Check input device capabilities in tablet seats
Instead of looking for tablets and pads based on input device type, check capabilities. Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2331>
-rw-r--r--src/wayland/meta-wayland-tablet-manager.c12
-rw-r--r--src/wayland/meta-wayland-tablet-seat.c28
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 a729c7b89..7ee1c9fe7 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 f9b95a656..a5d3443c6 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)
{