diff options
author | Hans de Goede <hdegoede@redhat.com> | 2020-10-14 21:23:04 +0200 |
---|---|---|
committer | Carlos Garnacho <carlosg@gnome.org> | 2020-10-18 21:35:09 +0000 |
commit | 88cabf8039b4561520128ddb108341c75904aca8 (patch) | |
tree | 7b4865d82c1a10b0c0f2e51b41407d2386cc0461 | |
parent | 6c240dc83b33d26696825c6ee70560e201542fd7 (diff) | |
download | mutter-88cabf8039b4561520128ddb108341c75904aca8.tar.gz |
seat-native: Check for tablet-switch devices from meta_seat_native_constructed
Detect if a tablet-mode-switch device is already present when mutter
starts by checking for this from meta_seat_native_constructed. This
mirrors how we also set has_touchscreen from meta_seat_native_constructed.
This fixes tablet-mode-switches only being recognized when they are added
at runtime.
https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1506
-rw-r--r-- | src/backends/native/meta-seat-native.c | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/src/backends/native/meta-seat-native.c b/src/backends/native/meta-seat-native.c index 8f8f13a09..b96ae3a25 100644 --- a/src/backends/native/meta-seat-native.c +++ b/src/backends/native/meta-seat-native.c @@ -1367,6 +1367,25 @@ has_touchscreen (MetaSeatNative *seat) return FALSE; } +static gboolean +has_tablet_switch (MetaSeatNative *seat) +{ + GSList *l; + + for (l = seat->devices; l; l = l->next) + { + MetaInputDeviceNative *device_native = META_INPUT_DEVICE_NATIVE (l->data); + + if (libinput_device_has_capability (device_native->libinput_device, + LIBINPUT_DEVICE_CAP_SWITCH) && + libinput_device_switch_has_switch (device_native->libinput_device, + LIBINPUT_SWITCH_TABLET_MODE)) + return TRUE; + } + + return FALSE; +} + static void update_touch_mode (MetaSeatNative *seat) { @@ -2519,6 +2538,7 @@ meta_seat_native_constructed (GObject *object) } seat->has_touchscreen = has_touchscreen (seat); + seat->has_tablet_switch = has_tablet_switch (seat); update_touch_mode (seat); if (G_OBJECT_CLASS (meta_seat_native_parent_class)->constructed) |