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>
This commit is contained in:
Carlos Garnacho 2022-03-08 17:31:20 +01:00 committed by Marge Bot
parent 844a729fa9
commit fff3654941
2 changed files with 19 additions and 21 deletions

View File

@ -43,18 +43,16 @@ unbind_resource (struct wl_resource *resource)
static gboolean static gboolean
is_tablet_device (ClutterInputDevice *device) is_tablet_device (ClutterInputDevice *device)
{ {
ClutterInputDeviceType device_type; ClutterInputCapabilities capabilities;
if (clutter_input_device_get_device_mode (device) == CLUTTER_INPUT_MODE_LOGICAL) if (clutter_input_device_get_device_mode (device) == CLUTTER_INPUT_MODE_LOGICAL)
return FALSE; return FALSE;
device_type = clutter_input_device_get_device_type (device); capabilities = clutter_input_device_get_capabilities (device);
return (device_type == CLUTTER_TABLET_DEVICE || return (capabilities &
device_type == CLUTTER_PEN_DEVICE || (CLUTTER_INPUT_CAPABILITY_TABLET_TOOL |
device_type == CLUTTER_ERASER_DEVICE || CLUTTER_INPUT_CAPABILITY_TABLET_PAD)) != 0;
device_type == CLUTTER_CURSOR_DEVICE ||
device_type == CLUTTER_PAD_DEVICE);
} }
static void static void

View File

@ -167,30 +167,27 @@ notify_pads (MetaWaylandTabletSeat *tablet_seat,
static gboolean static gboolean
is_tablet_device (ClutterInputDevice *device) is_tablet_device (ClutterInputDevice *device)
{ {
ClutterInputDeviceType device_type; ClutterInputCapabilities capabilities;
if (clutter_input_device_get_device_mode (device) == CLUTTER_INPUT_MODE_LOGICAL) if (clutter_input_device_get_device_mode (device) == CLUTTER_INPUT_MODE_LOGICAL)
return FALSE; return FALSE;
device_type = clutter_input_device_get_device_type (device); capabilities = clutter_input_device_get_capabilities (device);
return (device_type == CLUTTER_TABLET_DEVICE || return (capabilities & CLUTTER_INPUT_CAPABILITY_TABLET_TOOL) != 0;
device_type == CLUTTER_PEN_DEVICE ||
device_type == CLUTTER_ERASER_DEVICE ||
device_type == CLUTTER_CURSOR_DEVICE);
} }
static gboolean static gboolean
is_pad_device (ClutterInputDevice *device) is_pad_device (ClutterInputDevice *device)
{ {
ClutterInputDeviceType device_type; ClutterInputCapabilities capabilities;
if (clutter_input_device_get_device_mode (device) == CLUTTER_INPUT_MODE_LOGICAL) if (clutter_input_device_get_device_mode (device) == CLUTTER_INPUT_MODE_LOGICAL)
return FALSE; 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 static void
@ -471,8 +468,8 @@ meta_wayland_tablet_seat_notify_tool (MetaWaylandTabletSeat *tablet_seat,
} }
static GList * static GList *
lookup_grouped_devices (ClutterInputDevice *device, lookup_grouped_devices (ClutterInputDevice *device,
ClutterInputDeviceType type) ClutterInputCapabilities capabilities)
{ {
ClutterSeat *clutter_seat; ClutterSeat *clutter_seat;
GList *devices, *l; GList *devices, *l;
@ -485,7 +482,8 @@ lookup_grouped_devices (ClutterInputDevice *device,
{ {
if (l->data == device) if (l->data == device)
continue; continue;
if (clutter_input_device_get_device_type (l->data) != type) if ((clutter_input_device_get_capabilities (l->data) & capabilities) ==
capabilities)
continue; continue;
if (!clutter_input_device_is_grouped (device, l->data)) 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; MetaWaylandTablet *tablet;
GList *devices; GList *devices;
devices = lookup_grouped_devices (pad->device, CLUTTER_TABLET_DEVICE); devices = lookup_grouped_devices (pad->device,
CLUTTER_INPUT_CAPABILITY_TABLET_TOOL);
if (!devices) if (!devices)
return NULL; return NULL;
@ -528,7 +527,8 @@ meta_wayland_tablet_seat_lookup_paired_pads (MetaWaylandTabletSeat *tablet_seat,
GList *l, *devices, *pads = NULL; GList *l, *devices, *pads = NULL;
MetaWaylandTabletPad *pad; 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) for (l = devices; l; l = l->next)
{ {