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/compositor.c b/src/compositor.c
index 66c3eee..541829c 100644
--- a/src/compositor.c
+++ b/src/compositor.c
@@ -95,7 +95,7 @@
/* If a pointer falls outside the outputs new geometry, move it to its
* lower-right corner */
wl_list_for_each(seat, &output->compositor->seat_list, link) {
- struct weston_pointer *pointer = seat->pointer;
+ struct weston_pointer *pointer = weston_seat_get_pointer(seat);
int32_t x, y;
if (!pointer)
@@ -1752,15 +1752,20 @@
return;
wl_list_for_each(seat, &view->surface->compositor->seat_list, link) {
- if (seat->keyboard && seat->keyboard->focus == view->surface)
- weston_keyboard_set_focus(seat->keyboard, NULL);
- if (seat->pointer && seat->pointer->focus == view)
- weston_pointer_set_focus(seat->pointer,
+ struct weston_touch *touch = weston_seat_get_touch(seat);
+ struct weston_pointer *pointer = weston_seat_get_pointer(seat);
+ struct weston_keyboard *keyboard =
+ weston_seat_get_keyboard(seat);
+
+ if (keyboard && keyboard->focus == view->surface)
+ weston_keyboard_set_focus(keyboard, NULL);
+ if (pointer && pointer->focus == view)
+ weston_pointer_set_focus(pointer,
NULL,
wl_fixed_from_int(0),
wl_fixed_from_int(0));
- if (seat->touch && seat->touch->focus == view)
- weston_touch_set_focus(seat->touch, NULL);
+ if (touch && touch->focus == view)
+ weston_touch_set_focus(touch, NULL);
}
}
@@ -4587,10 +4592,10 @@
ec->default_pointer_grab = interface;
wl_list_for_each(seat, &ec->seat_list, link) {
- if (seat->pointer) {
- weston_pointer_set_default_grab(seat->pointer,
- interface);
- }
+ struct weston_pointer *pointer = weston_seat_get_pointer(seat);
+
+ if (pointer)
+ weston_pointer_set_default_grab(pointer, interface);
}
}