From f8e2234ce59fbbfa3bc6f3c81afc2a249ae2d0ed Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Fri, 29 May 2020 13:28:11 +0200 Subject: [PATCH] backends/native: Drop external keyboard detection for ::touch-mode This cannot be made to work reliably. Some factoids: - Internal devices may be connected via USB. - The ACPI spec provides the _PLD (Physical location of device) hook to determine how is an USB device connected, with an anecdotal success rate. Internal devices may be seen as external and vice-versa, there is also an "unknown" value that is widely used. - There may be non-USB keyboards, the old "AT Translated Set 2 Keyboard" interface does not change on hotplugging. - Libinput has an internal series of quirks to classify keyboards as internal of external, also with an "unknown" value. These heuristics are kinda hopeless to get right by our own hand. Drop this external keyboard detection in the hope that there will be something more deterministic to rely on in the future (e.g. the libinput quirks made available to us directly or indirectly). Fixes: https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/2378 Related: https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/2353 https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1277 --- clutter/clutter/clutter-seat.c | 1 - src/backends/native/meta-seat-native.c | 48 +++----------------------- src/backends/native/meta-seat-native.h | 1 - 3 files changed, 4 insertions(+), 46 deletions(-) diff --git a/clutter/clutter/clutter-seat.c b/clutter/clutter/clutter-seat.c index a54269163..d0852fa44 100644 --- a/clutter/clutter/clutter-seat.c +++ b/clutter/clutter/clutter-seat.c @@ -682,7 +682,6 @@ clutter_seat_warp_pointer (ClutterSeat *seat, * requirements are fulfilled: * * - A touchscreen is available - * - No external keyboard is attached to the device * - A tablet mode switch, if present, is enabled * * Returns: %TRUE if the device is a tablet that doesn't have an external diff --git a/src/backends/native/meta-seat-native.c b/src/backends/native/meta-seat-native.c index 9c25d4abf..ecff929bd 100644 --- a/src/backends/native/meta-seat-native.c +++ b/src/backends/native/meta-seat-native.c @@ -1380,35 +1380,6 @@ has_touchscreen (MetaSeatNative *seat) return FALSE; } -static gboolean -has_external_keyboard (MetaSeatNative *seat) -{ - GList *devices, *l; - gboolean has_external = FALSE; - - devices = g_udev_client_query_by_subsystem (seat->udev_client, "input"); - - for (l = devices; l; l = l->next) - { - if (!g_udev_device_has_property (l->data, "ID_INPUT_KEYBOARD")) - continue; - - /* May be "hid" or something else, we don't care. This property - * will not be present in virtual "AT Translated Set 2 keyboard" - * devices. - */ - if (!g_udev_device_has_property (l->data, "ID_TYPE")) - break; - - has_external = TRUE; - break; - } - - g_list_free_full (devices, g_object_unref); - - return has_external; -} - static void update_touch_mode (MetaSeatNative *seat) { @@ -1421,10 +1392,10 @@ update_touch_mode (MetaSeatNative *seat) else if (seat->has_tablet_switch && !seat->tablet_mode_switch_state) touch_mode = FALSE; /* If tablet mode is enabled, or if there is no tablet mode switch - * (eg. kiosk machines), check availability of external keyboards. + * (eg. kiosk machines), assume touch-mode. */ else - touch_mode = !seat->has_external_keyboard; + touch_mode = TRUE; if (seat->touch_mode != touch_mode) { @@ -1465,12 +1436,7 @@ evdev_add_device (MetaSeatNative *seat, g_signal_emit_by_name (seat, "device-added", device); - if (type == CLUTTER_KEYBOARD_DEVICE) - { - seat->has_external_keyboard = has_external_keyboard (seat); - check_touch_mode = TRUE; - } - else if (type == CLUTTER_TOUCHSCREEN_DEVICE) + if (type == CLUTTER_TOUCHSCREEN_DEVICE) { seat->has_touchscreen = TRUE; check_touch_mode = TRUE; @@ -1503,12 +1469,7 @@ evdev_remove_device (MetaSeatNative *seat, device_type = clutter_input_device_get_device_type (device); - if (device_type == CLUTTER_KEYBOARD_DEVICE) - { - seat->has_external_keyboard = has_external_keyboard (seat); - update_touch_mode (seat); - } - else if (device_type == CLUTTER_TOUCHSCREEN_DEVICE) + if (device_type == CLUTTER_TOUCHSCREEN_DEVICE) { seat->has_touchscreen = has_touchscreen (seat); update_touch_mode (seat); @@ -2553,7 +2514,6 @@ meta_seat_native_constructed (GObject *object) xkb_keymap_led_get_index (xkb_keymap, XKB_LED_NAME_SCROLL); } - seat->has_external_keyboard = has_external_keyboard (seat); seat->has_touchscreen = has_touchscreen (seat); update_touch_mode (seat); diff --git a/src/backends/native/meta-seat-native.h b/src/backends/native/meta-seat-native.h index 2d780618f..61e6ffd30 100644 --- a/src/backends/native/meta-seat-native.h +++ b/src/backends/native/meta-seat-native.h @@ -120,7 +120,6 @@ struct _MetaSeatNative GUdevClient *udev_client; guint tablet_mode_switch_state : 1; - guint has_external_keyboard : 1; guint has_touchscreen : 1; guint has_tablet_switch : 1; guint touch_mode : 1;