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/xwayland/dnd.c b/xwayland/dnd.c
index eb9c5dd..a036b30 100644
--- a/xwayland/dnd.c
+++ b/xwayland/dnd.c
@@ -154,6 +154,7 @@
{
struct dnd_data_source *source;
struct weston_seat *seat = weston_wm_pick_seat(wm);
+ struct weston_pointer *pointer = weston_seat_get_pointer(seat);
char **p;
const char *name;
uint32_t *types;
@@ -213,7 +214,7 @@
}
free(reply);
- weston_pointer_start_drag(seat->pointer, &source->base, NULL, NULL);
+ weston_pointer_start_drag(pointer, &source->base, NULL, NULL);
}
int
diff --git a/xwayland/window-manager.c b/xwayland/window-manager.c
index c3a57c1..daebf47 100644
--- a/xwayland/window-manager.c
+++ b/xwayland/window-manager.c
@@ -1316,12 +1316,16 @@
seat = NULL;
wl_list_for_each(s, &wm->server->compositor->seat_list, link) {
- if (s->pointer != NULL && s->pointer->focus &&
- s->pointer->focus->surface == window->surface &&
- s->pointer->button_count > 0 &&
- (seat == NULL ||
- s->pointer->grab_serial -
- seat->pointer->grab_serial < (1 << 30)))
+ struct weston_pointer *pointer = weston_seat_get_pointer(s);
+ struct weston_pointer *old_pointer =
+ weston_seat_get_pointer(seat);
+
+ if (pointer && pointer->focus &&
+ pointer->focus->surface == window->surface &&
+ pointer->button_count > 0 &&
+ (!seat ||
+ pointer->grab_serial -
+ old_pointer->grab_serial < (1 << 30)))
seat = s;
}
@@ -1345,13 +1349,14 @@
struct weston_wm *wm = window->wm;
struct weston_seat *seat = weston_wm_pick_seat_for_window(window);
+ struct weston_pointer *pointer = weston_seat_get_pointer(seat);
int detail;
struct weston_shell_interface *shell_interface =
&wm->server->compositor->shell_interface;
- if (seat == NULL || seat->pointer->button_count != 1
- || !seat->pointer->focus
- || seat->pointer->focus->surface != window->surface)
+ if (!pointer || pointer->button_count != 1
+ || !pointer->focus
+ || pointer->focus->surface != window->surface)
return;
detail = client_message->data.data32[2];