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:
committed by
Bryce Harrington
parent
b41b59e2fa
commit
1281a36e3b
@@ -139,6 +139,7 @@ trigger_binding(struct weston_keyboard *keyboard, uint32_t time, uint32_t key,
|
||||
char fname[1024];
|
||||
struct weston_surface *surface;
|
||||
struct weston_seat *seat = keyboard->seat;
|
||||
struct weston_pointer *pointer = weston_seat_get_pointer(seat);
|
||||
int width, height;
|
||||
char desc[512];
|
||||
void *pixels;
|
||||
@@ -147,12 +148,10 @@ trigger_binding(struct weston_keyboard *keyboard, uint32_t time, uint32_t key,
|
||||
int ret;
|
||||
FILE *fp;
|
||||
|
||||
if (seat->pointer_device_count == 0 ||
|
||||
!seat->pointer ||
|
||||
!seat->pointer->focus)
|
||||
if (!pointer || !pointer->focus)
|
||||
return;
|
||||
|
||||
surface = seat->pointer->focus->surface;
|
||||
surface = pointer->focus->surface;
|
||||
|
||||
weston_surface_get_content_size(surface, &width, &height);
|
||||
|
||||
|
||||
+5
-4
@@ -83,7 +83,7 @@ static void
|
||||
notify_pointer_position(struct weston_test *test, struct wl_resource *resource)
|
||||
{
|
||||
struct weston_seat *seat = get_seat(test);
|
||||
struct weston_pointer *pointer = seat->pointer;
|
||||
struct weston_pointer *pointer = weston_seat_get_pointer(seat);
|
||||
|
||||
weston_test_send_pointer_position(resource, pointer->x, pointer->y);
|
||||
}
|
||||
@@ -144,7 +144,7 @@ move_pointer(struct wl_client *client, struct wl_resource *resource,
|
||||
{
|
||||
struct weston_test *test = wl_resource_get_user_data(resource);
|
||||
struct weston_seat *seat = get_seat(test);
|
||||
struct weston_pointer *pointer = seat->pointer;
|
||||
struct weston_pointer *pointer = weston_seat_get_pointer(seat);
|
||||
|
||||
notify_motion(seat, 100,
|
||||
wl_fixed_from_int(x) - pointer->x,
|
||||
@@ -171,12 +171,13 @@ activate_surface(struct wl_client *client, struct wl_resource *resource,
|
||||
wl_resource_get_user_data(surface_resource) : NULL;
|
||||
struct weston_test *test = wl_resource_get_user_data(resource);
|
||||
struct weston_seat *seat;
|
||||
struct weston_keyboard *keyboard;
|
||||
|
||||
seat = get_seat(test);
|
||||
|
||||
keyboard = weston_seat_get_keyboard(seat);
|
||||
if (surface) {
|
||||
weston_surface_activate(surface, seat);
|
||||
notify_keyboard_focus_in(seat, &seat->keyboard->keys,
|
||||
notify_keyboard_focus_in(seat, &keyboard->keys,
|
||||
STATE_UPDATE_AUTOMATIC);
|
||||
}
|
||||
else {
|
||||
|
||||
Reference in New Issue
Block a user