From 5f83d9a5c854873746a31d0cc4d118c9a6d87ddd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Tue, 15 May 2018 12:04:56 +0100 Subject: [PATCH 1/2] clutter-seat-evdev: Add function to get device by id --- clutter/clutter/evdev/clutter-seat-evdev.c | 18 ++++++++++++++++++ clutter/clutter/evdev/clutter-seat-evdev.h | 3 +++ 2 files changed, 21 insertions(+) diff --git a/clutter/clutter/evdev/clutter-seat-evdev.c b/clutter/clutter/evdev/clutter-seat-evdev.c index e91f3673bf4..a453b1150af 100644 --- a/clutter/clutter/evdev/clutter-seat-evdev.c +++ b/clutter/clutter/evdev/clutter-seat-evdev.c @@ -858,6 +858,24 @@ clutter_seat_evdev_free (ClutterSeatEvdev *seat) g_free (seat); } +ClutterInputDevice * +clutter_seat_evdev_get_device (ClutterSeatEvdev *seat, + gint id) +{ + ClutterInputDevice *device; + GSList *l; + + for (l = seat->devices; l; l = l->next) + { + device = l->data; + + if (clutter_input_device_get_device_id (device) == id) + return device; + } + + return NULL; +} + void clutter_seat_evdev_set_stage (ClutterSeatEvdev *seat, ClutterStage *stage) diff --git a/clutter/clutter/evdev/clutter-seat-evdev.h b/clutter/clutter/evdev/clutter-seat-evdev.h index 0fb89e33e9d..4bb319b3ab8 100644 --- a/clutter/clutter/evdev/clutter-seat-evdev.h +++ b/clutter/clutter/evdev/clutter-seat-evdev.h @@ -139,6 +139,9 @@ void clutter_seat_evdev_set_libinput_seat (ClutterSeatEvdev *seat, void clutter_seat_evdev_sync_leds (ClutterSeatEvdev *seat); +ClutterInputDevice * clutter_seat_evdev_get_device (ClutterSeatEvdev *seat, + gint id); + ClutterTouchState * clutter_seat_evdev_acquire_touch_state (ClutterSeatEvdev *seat, int device_slot); -- GitLab From 3e85ac8131fc76312a2382d83df6926b88a37415 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Tue, 15 May 2018 12:09:59 +0100 Subject: [PATCH 2/2] clutter-device-evdev: Get devices from main seat if no real seat is set In devices such as ARM boards there could be no input devices connected on startup, leading to a crash when we try to process artificial events that could be queued (as gnome-shell does when syncing pointer). Those events still should refer to a device and, in case we don't have one provided by libinput we should still return the core devices defined in the main seat. --- .../clutter/evdev/clutter-device-manager-evdev.c | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/clutter/clutter/evdev/clutter-device-manager-evdev.c b/clutter/clutter/evdev/clutter-device-manager-evdev.c index bc9549de9e7..812ad8c080a 100644 --- a/clutter/clutter/evdev/clutter-device-manager-evdev.c +++ b/clutter/clutter/evdev/clutter-device-manager-evdev.c @@ -919,7 +919,6 @@ clutter_device_manager_evdev_get_device (ClutterDeviceManager *manager, ClutterDeviceManagerEvdev *manager_evdev; ClutterDeviceManagerEvdevPrivate *priv; GSList *l; - GSList *device_it; manager_evdev = CLUTTER_DEVICE_MANAGER_EVDEV (manager); priv = manager_evdev->priv; @@ -927,17 +926,13 @@ clutter_device_manager_evdev_get_device (ClutterDeviceManager *manager, for (l = priv->seats; l; l = l->next) { ClutterSeatEvdev *seat = l->data; + ClutterInputDevice *device = clutter_seat_evdev_get_device (seat, id); - for (device_it = seat->devices; device_it; device_it = device_it->next) - { - ClutterInputDevice *device = device_it->data; - - if (clutter_input_device_get_device_id (device) == id) - return device; - } + if (device) + return device; } - return NULL; + return clutter_seat_evdev_get_device (priv->main_seat, id); } static void -- GitLab