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/fullscreen-shell/fullscreen-shell.c b/fullscreen-shell/fullscreen-shell.c
index cae6ed5..ef9302b 100644
--- a/fullscreen-shell/fullscreen-shell.c
+++ b/fullscreen-shell/fullscreen-shell.c
@@ -96,15 +96,17 @@
seat_caps_changed(struct wl_listener *l, void *data)
{
struct weston_seat *seat = data;
+ struct weston_keyboard *keyboard = weston_seat_get_keyboard(seat);
+ struct weston_pointer *pointer = weston_seat_get_pointer(seat);
struct pointer_focus_listener *listener;
struct fs_output *fsout;
listener = container_of(l, struct pointer_focus_listener, seat_caps);
/* no pointer */
- if (seat->pointer_device_count) {
+ if (pointer) {
if (!listener->pointer_focus.link.prev) {
- wl_signal_add(&seat->pointer->focus_signal,
+ wl_signal_add(&pointer->focus_signal,
&listener->pointer_focus);
}
} else {
@@ -113,7 +115,7 @@
}
}
- if (seat->keyboard_device_count && seat->keyboard->focus != NULL) {
+ if (keyboard && keyboard->focus != NULL) {
wl_list_for_each(fsout, &listener->shell->output_list, link) {
if (fsout->surface) {
weston_surface_activate(fsout->surface, seat);
@@ -681,7 +683,10 @@
if (surface) {
wl_list_for_each(seat, &shell->compositor->seat_list, link) {
- if (seat->keyboard && seat->keyboard->focus == NULL)
+ struct weston_keyboard *keyboard =
+ weston_seat_get_keyboard(seat);
+
+ if (keyboard && !keyboard->focus)
weston_surface_activate(surface, seat);
}
}
@@ -729,7 +734,10 @@
fsout, mode_feedback_destroyed);
wl_list_for_each(seat, &shell->compositor->seat_list, link) {
- if (seat->keyboard && seat->keyboard->focus == NULL)
+ struct weston_keyboard *keyboard =
+ weston_seat_get_keyboard(seat);
+
+ if (keyboard && !keyboard->focus)
weston_surface_activate(surface, seat);
}
}