wayland: Move checks for grabbing into a central location

This means that we won't have as much work to do to introduce similar
checks for touch.
This commit is contained in:
Jasper St. Pierre 2014-05-22 10:57:02 -04:00
parent 47d72680ff
commit 6408e59c7c
5 changed files with 30 additions and 12 deletions

View File

@ -805,3 +805,13 @@ meta_wayland_pointer_create_new_resource (MetaWaylandPointer *pointer,
if (pointer->focus_surface && wl_resource_get_client (pointer->focus_surface->resource) == client)
meta_wayland_pointer_set_focus (pointer, pointer->focus_surface);
}
gboolean
meta_wayland_pointer_can_grab_surface (MetaWaylandPointer *pointer,
MetaWaylandSurface *surface,
uint32_t serial)
{
return (pointer->button_count == 0 &&
pointer->grab_serial == serial &&
pointer->focus_surface == surface);
}

View File

@ -110,4 +110,8 @@ void meta_wayland_pointer_create_new_resource (MetaWaylandPointer *pointer,
struct wl_resource *seat_resource,
uint32_t id);
gboolean meta_wayland_pointer_can_grab_surface (MetaWaylandPointer *pointer,
MetaWaylandSurface *surface,
uint32_t serial);
#endif /* META_WAYLAND_POINTER_H */

View File

@ -182,3 +182,11 @@ meta_wayland_seat_update_cursor_surface (MetaWaylandSeat *seat)
{
meta_wayland_pointer_update_cursor_surface (&seat->pointer);
}
gboolean
meta_wayland_seat_can_grab_surface (MetaWaylandSeat *seat,
MetaWaylandSurface *surface,
uint32_t serial)
{
return meta_wayland_pointer_can_grab_surface (&seat->pointer, surface, serial);
}

View File

@ -70,4 +70,8 @@ gboolean meta_wayland_seat_handle_event (MetaWaylandSeat *seat,
void meta_wayland_seat_repick (MetaWaylandSeat *seat);
void meta_wayland_seat_update_cursor_surface (MetaWaylandSeat *seat);
gboolean meta_wayland_seat_can_grab_surface (MetaWaylandSeat *seat,
MetaWaylandSurface *surface,
uint32_t serial);
#endif /* META_WAYLAND_SEAT_H */

View File

@ -802,9 +802,7 @@ xdg_surface_move (struct wl_client *client,
MetaWaylandSeat *seat = wl_resource_get_user_data (seat_resource);
MetaWaylandSurface *surface = wl_resource_get_user_data (resource);
if (seat->pointer.button_count == 0 ||
seat->pointer.grab_serial != serial ||
seat->pointer.focus_surface != surface)
if (!meta_wayland_seat_can_grab_surface (seat, surface, serial))
return;
begin_grab_op_on_surface (surface, seat, META_GRAB_OP_MOVING);
@ -847,9 +845,7 @@ xdg_surface_resize (struct wl_client *client,
MetaWaylandSeat *seat = wl_resource_get_user_data (seat_resource);
MetaWaylandSurface *surface = wl_resource_get_user_data (resource);
if (seat->pointer.button_count == 0 ||
seat->pointer.grab_serial != serial ||
seat->pointer.focus_surface != surface)
if (!meta_wayland_seat_can_grab_surface (seat, surface, serial))
return;
begin_grab_op_on_surface (surface, seat, grab_op_for_xdg_surface_resize_edge (edges));
@ -1105,9 +1101,7 @@ wl_shell_surface_move (struct wl_client *client,
MetaWaylandSeat *seat = wl_resource_get_user_data (seat_resource);
MetaWaylandSurface *surface = wl_resource_get_user_data (resource);
if (seat->pointer.button_count == 0 ||
seat->pointer.grab_serial != serial ||
seat->pointer.focus_surface != surface)
if (!meta_wayland_seat_can_grab_surface (seat, surface, serial))
return;
begin_grab_op_on_surface (surface, seat, META_GRAB_OP_MOVING);
@ -1150,9 +1144,7 @@ wl_shell_surface_resize (struct wl_client *client,
MetaWaylandSeat *seat = wl_resource_get_user_data (seat_resource);
MetaWaylandSurface *surface = wl_resource_get_user_data (resource);
if (seat->pointer.button_count == 0 ||
seat->pointer.grab_serial != serial ||
seat->pointer.focus_surface != surface)
if (!meta_wayland_seat_can_grab_surface (seat, surface, serial))
return;
begin_grab_op_on_surface (surface, seat, grab_op_for_wl_shell_surface_resize_edge (edges));