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>
This commit is contained in:
Derek Foreman
2015-07-31 16:55:32 -05:00
committed by Bryce Harrington
parent b41b59e2fa
commit 1281a36e3b
21 changed files with 484 additions and 260 deletions
+2 -1
View File
@@ -154,6 +154,7 @@ handle_enter(struct weston_wm *wm, xcb_client_message_event_t *client_message)
{
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 @@ handle_enter(struct weston_wm *wm, xcb_client_message_event_t *client_message)
}
free(reply);
weston_pointer_start_drag(seat->pointer, &source->base, NULL, NULL);
weston_pointer_start_drag(pointer, &source->base, NULL, NULL);
}
int
+14 -9
View File
@@ -1316,12 +1316,16 @@ weston_wm_pick_seat_for_window(struct weston_wm_window *window)
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 @@ weston_wm_window_handle_moveresize(struct weston_wm_window *window,
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];