wayland: don't try to use seat devices that aren't (yet) present
Before commit ac448bd42b
the pointer,
keyboard, and touch objects were initialized when the seat was created.
Now they're initialized later, when the clutter device manager finds and
loads them.
This commit makes sure we don't try to access those objects if they
aren't initialized.
https://bugzilla.gnome.org/show_bug.cgi?id=744640
This commit is contained in:
@ -44,6 +44,7 @@ seat_get_pointer (struct wl_client *client,
|
|||||||
MetaWaylandSeat *seat = wl_resource_get_user_data (resource);
|
MetaWaylandSeat *seat = wl_resource_get_user_data (resource);
|
||||||
MetaWaylandPointer *pointer = &seat->pointer;
|
MetaWaylandPointer *pointer = &seat->pointer;
|
||||||
|
|
||||||
|
if ((seat->capabilities & WL_SEAT_CAPABILITY_POINTER) != 0)
|
||||||
meta_wayland_pointer_create_new_resource (pointer, client, resource, id);
|
meta_wayland_pointer_create_new_resource (pointer, client, resource, id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -55,6 +56,7 @@ seat_get_keyboard (struct wl_client *client,
|
|||||||
MetaWaylandSeat *seat = wl_resource_get_user_data (resource);
|
MetaWaylandSeat *seat = wl_resource_get_user_data (resource);
|
||||||
MetaWaylandKeyboard *keyboard = &seat->keyboard;
|
MetaWaylandKeyboard *keyboard = &seat->keyboard;
|
||||||
|
|
||||||
|
if ((seat->capabilities & WL_SEAT_CAPABILITY_KEYBOARD) != 0)
|
||||||
meta_wayland_keyboard_create_new_resource (keyboard, client, resource, id);
|
meta_wayland_keyboard_create_new_resource (keyboard, client, resource, id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -66,6 +68,7 @@ seat_get_touch (struct wl_client *client,
|
|||||||
MetaWaylandSeat *seat = wl_resource_get_user_data (resource);
|
MetaWaylandSeat *seat = wl_resource_get_user_data (resource);
|
||||||
MetaWaylandTouch *touch = &seat->touch;
|
MetaWaylandTouch *touch = &seat->touch;
|
||||||
|
|
||||||
|
if ((seat->capabilities & WL_SEAT_CAPABILITY_TOUCH) != 0)
|
||||||
meta_wayland_touch_create_new_resource (touch, client, resource, id);
|
meta_wayland_touch_create_new_resource (touch, client, resource, id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -350,6 +353,9 @@ meta_wayland_seat_handle_event (MetaWaylandSeat *seat,
|
|||||||
void
|
void
|
||||||
meta_wayland_seat_repick (MetaWaylandSeat *seat)
|
meta_wayland_seat_repick (MetaWaylandSeat *seat)
|
||||||
{
|
{
|
||||||
|
if ((seat->capabilities & WL_SEAT_CAPABILITY_POINTER) == 0)
|
||||||
|
return;
|
||||||
|
|
||||||
meta_wayland_pointer_repick (&seat->pointer);
|
meta_wayland_pointer_repick (&seat->pointer);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -357,6 +363,9 @@ void
|
|||||||
meta_wayland_seat_set_input_focus (MetaWaylandSeat *seat,
|
meta_wayland_seat_set_input_focus (MetaWaylandSeat *seat,
|
||||||
MetaWaylandSurface *surface)
|
MetaWaylandSurface *surface)
|
||||||
{
|
{
|
||||||
|
if ((seat->capabilities & WL_SEAT_CAPABILITY_KEYBOARD) == 0)
|
||||||
|
return;
|
||||||
|
|
||||||
meta_wayland_keyboard_set_focus (&seat->keyboard, surface);
|
meta_wayland_keyboard_set_focus (&seat->keyboard, surface);
|
||||||
meta_wayland_data_device_set_keyboard_focus (&seat->data_device);
|
meta_wayland_data_device_set_keyboard_focus (&seat->data_device);
|
||||||
}
|
}
|
||||||
@ -364,6 +373,9 @@ meta_wayland_seat_set_input_focus (MetaWaylandSeat *seat,
|
|||||||
void
|
void
|
||||||
meta_wayland_seat_update_cursor_surface (MetaWaylandSeat *seat)
|
meta_wayland_seat_update_cursor_surface (MetaWaylandSeat *seat)
|
||||||
{
|
{
|
||||||
|
if ((seat->capabilities & WL_SEAT_CAPABILITY_POINTER) == 0)
|
||||||
|
return;
|
||||||
|
|
||||||
meta_wayland_pointer_update_cursor_surface (&seat->pointer);
|
meta_wayland_pointer_update_cursor_surface (&seat->pointer);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -374,21 +386,29 @@ meta_wayland_seat_get_grab_info (MetaWaylandSeat *seat,
|
|||||||
gfloat *x,
|
gfloat *x,
|
||||||
gfloat *y)
|
gfloat *y)
|
||||||
{
|
{
|
||||||
ClutterEventSequence *sequence;
|
ClutterEventSequence *sequence = NULL;
|
||||||
|
gboolean can_grab_surface = FALSE;
|
||||||
|
|
||||||
|
if ((seat->capabilities & WL_SEAT_CAPABILITY_TOUCH) != 0)
|
||||||
sequence = meta_wayland_touch_find_grab_sequence (&seat->touch, surface, serial);
|
sequence = meta_wayland_touch_find_grab_sequence (&seat->touch, surface, serial);
|
||||||
|
|
||||||
if (sequence)
|
if (sequence)
|
||||||
|
{
|
||||||
meta_wayland_touch_get_press_coords (&seat->touch, sequence, x, y);
|
meta_wayland_touch_get_press_coords (&seat->touch, sequence, x, y);
|
||||||
else if (meta_wayland_pointer_can_grab_surface (&seat->pointer, surface, serial))
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if ((seat->capabilities & WL_SEAT_CAPABILITY_POINTER) != 0)
|
||||||
|
can_grab_surface = meta_wayland_pointer_can_grab_surface (&seat->pointer, surface, serial);
|
||||||
|
|
||||||
|
if (can_grab_surface)
|
||||||
{
|
{
|
||||||
if (x)
|
if (x)
|
||||||
*x = seat->pointer.grab_x;
|
*x = seat->pointer.grab_x;
|
||||||
if (y)
|
if (y)
|
||||||
*y = seat->pointer.grab_y;
|
*y = seat->pointer.grab_y;
|
||||||
}
|
}
|
||||||
else
|
}
|
||||||
return FALSE;
|
|
||||||
|
|
||||||
return TRUE;
|
return sequence || can_grab_surface;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user