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
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2331>
This commit is contained in:
Carlos Garnacho 2022-03-08 17:26:43 +01:00 committed by Marge Bot
parent 1fda60f03e
commit 844a729fa9

View File

@ -114,7 +114,7 @@ lookup_device_capabilities (ClutterSeat *seat)
for (l = devices; l; l = l->next) for (l = devices; l; l = l->next)
{ {
ClutterInputDeviceType device_type; ClutterInputCapabilities device_capabilities;
/* Only look for physical devices, logical devices have rather generic /* Only look for physical devices, logical devices have rather generic
* keyboard/pointer device types, which is not truly representative of * 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) if (clutter_input_device_get_device_mode (l->data) == CLUTTER_INPUT_MODE_LOGICAL)
continue; continue;
device_type = clutter_input_device_get_device_type (l->data); device_capabilities = clutter_input_device_get_capabilities (l->data);
switch (device_type) if (device_capabilities & CLUTTER_INPUT_CAPABILITY_POINTER)
{ capabilities |= WL_SEAT_CAPABILITY_POINTER;
case CLUTTER_TOUCHPAD_DEVICE: if (device_capabilities & CLUTTER_INPUT_CAPABILITY_KEYBOARD)
case CLUTTER_POINTER_DEVICE: capabilities |= WL_SEAT_CAPABILITY_KEYBOARD;
capabilities |= WL_SEAT_CAPABILITY_POINTER; if (device_capabilities & CLUTTER_INPUT_CAPABILITY_TOUCH)
break; capabilities |= WL_SEAT_CAPABILITY_TOUCH;
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;
}
} }
g_list_free (devices); g_list_free (devices);
@ -297,11 +285,11 @@ static gboolean
event_from_supported_hardware_device (MetaWaylandSeat *seat, event_from_supported_hardware_device (MetaWaylandSeat *seat,
const ClutterEvent *event) const ClutterEvent *event)
{ {
ClutterInputDevice *input_device; ClutterInputDevice *input_device;
ClutterInputMode input_mode; ClutterInputMode input_mode;
ClutterInputDeviceType device_type; ClutterInputCapabilities capabilities;
gboolean hardware_device = FALSE; gboolean hardware_device = FALSE;
gboolean supported_device = FALSE; gboolean supported_device = FALSE;
input_device = clutter_event_get_source_device (event); input_device = clutter_event_get_source_device (event);
@ -315,21 +303,13 @@ event_from_supported_hardware_device (MetaWaylandSeat *seat,
hardware_device = TRUE; hardware_device = TRUE;
device_type = clutter_input_device_get_device_type (input_device); capabilities = clutter_input_device_get_capabilities (input_device);
switch (device_type) if ((capabilities &
{ (CLUTTER_INPUT_CAPABILITY_POINTER |
case CLUTTER_TOUCHPAD_DEVICE: CLUTTER_INPUT_CAPABILITY_KEYBOARD |
case CLUTTER_POINTER_DEVICE: CLUTTER_INPUT_CAPABILITY_TOUCH)) != 0)
case CLUTTER_KEYBOARD_DEVICE: supported_device = TRUE;
case CLUTTER_TOUCHSCREEN_DEVICE:
supported_device = TRUE;
break;
default:
supported_device = FALSE;
break;
}
out: out:
return hardware_device && supported_device; return hardware_device && supported_device;