input: Don't test keyboard/pointer/touch pointers
Keyboards and pointers aren't freed when devices are removed, so we should
really be testing keyboard_device_count and pointer_device_count in most
cases, not the actual pointers. Otherwise we end up with different
behaviour after removing a device than we had before it was inserted.
This commit renames the touch/keyboard/pointer pointers and adds helper
functions to get them that hide this complexity and return NULL when
*_device_count is 0.
Signed-off-by: Derek Foreman <derekf@osg.samsung.com>
Reviewed-by: Jonas Ã…dahl <jadahl@gmail.com>
diff --git a/src/libinput-seat.c b/src/libinput-seat.c
index 6353667..e6d44b0 100644
--- a/src/libinput-seat.c
+++ b/src/libinput-seat.c
@@ -60,6 +60,7 @@
struct libinput_seat *libinput_seat;
struct weston_seat *seat;
struct udev_seat *udev_seat;
+ struct weston_pointer *pointer;
c = input->compositor;
libinput_seat = libinput_device_get_seat(libinput_device);
@@ -77,10 +78,11 @@
udev_seat = (struct udev_seat *) seat;
wl_list_insert(udev_seat->devices_list.prev, &device->link);
- if (seat->output && seat->pointer)
- weston_pointer_clamp(seat->pointer,
- &seat->pointer->x,
- &seat->pointer->y);
+ pointer = weston_seat_get_pointer(seat);
+ if (seat->output && pointer)
+ weston_pointer_clamp(pointer,
+ &pointer->x,
+ &pointer->y);
output_name = libinput_device_get_output_name(libinput_device);
if (output_name) {
@@ -378,8 +380,11 @@
static void
udev_seat_destroy(struct udev_seat *seat)
{
+ struct weston_keyboard *keyboard =
+ weston_seat_get_keyboard(&seat->base);
+
udev_seat_remove_devices(seat);
- if (seat->base.keyboard)
+ if (keyboard)
notify_keyboard_focus_out(&seat->base);
weston_seat_release(&seat->base);
wl_list_remove(&seat->output_create_listener.link);