1
0
Fork 0

wayland-surface: Support xdg_surface_resize as well

This commit is contained in:
Jasper St. Pierre 2013-11-14 21:45:34 -05:00
parent 3c7cd1f38c
commit b72315e27a

View file

@ -570,29 +570,23 @@ xdg_surface_pong (struct wl_client *client,
{ {
} }
static void static gboolean
xdg_surface_move (struct wl_client *client, begin_grab_op_on_surface (MetaWaylandSurface *surface,
struct wl_resource *resource, MetaWaylandSeat *seat,
struct wl_resource *seat_resource, MetaGrabOp grab_op)
guint32 serial)
{ {
MetaWaylandSeat *seat = wl_resource_get_user_data (seat_resource); MetaWindow *window = surface->window;
MetaWaylandSurfaceExtension *xdg_surface = wl_resource_get_user_data (resource);
MetaWindow *window;
if (seat->pointer.button_count == 0 ||
seat->pointer.grab_serial != serial ||
seat->pointer.focus != xdg_surface->surface)
return;
window = xdg_surface->surface->window;
if (!window) if (!window)
return; return FALSE;
meta_display_begin_grab_op (window->display, if (grab_op == META_GRAB_OP_NONE)
return FALSE;
return meta_display_begin_grab_op (window->display,
window->screen, window->screen,
window, window,
META_GRAB_OP_MOVING, grab_op,
TRUE, /* pointer_already_grabbed */ TRUE, /* pointer_already_grabbed */
FALSE, /* frame_action */ FALSE, /* frame_action */
1, /* button. XXX? */ 1, /* button. XXX? */
@ -602,14 +596,66 @@ xdg_surface_move (struct wl_client *client,
wl_fixed_to_int (seat->pointer.grab_y)); wl_fixed_to_int (seat->pointer.grab_y));
} }
static void
xdg_surface_move (struct wl_client *client,
struct wl_resource *resource,
struct wl_resource *seat_resource,
guint32 serial)
{
MetaWaylandSeat *seat = wl_resource_get_user_data (seat_resource);
MetaWaylandSurfaceExtension *xdg_surface = wl_resource_get_user_data (resource);
if (seat->pointer.button_count == 0 ||
seat->pointer.grab_serial != serial ||
seat->pointer.focus != xdg_surface->surface)
return;
begin_grab_op_on_surface (xdg_surface->surface, seat, META_GRAB_OP_MOVING);
}
static MetaGrabOp
grab_op_for_edge (int edge)
{
switch (edge)
{
case XDG_SURFACE_RESIZE_EDGE_TOP_LEFT:
return META_GRAB_OP_RESIZING_NW;
case XDG_SURFACE_RESIZE_EDGE_TOP:
return META_GRAB_OP_RESIZING_N;
case XDG_SURFACE_RESIZE_EDGE_TOP_RIGHT:
return META_GRAB_OP_RESIZING_NE;
case XDG_SURFACE_RESIZE_EDGE_RIGHT:
return META_GRAB_OP_RESIZING_E;
case XDG_SURFACE_RESIZE_EDGE_BOTTOM_RIGHT:
return META_GRAB_OP_RESIZING_SE;
case XDG_SURFACE_RESIZE_EDGE_BOTTOM:
return META_GRAB_OP_RESIZING_S;
case XDG_SURFACE_RESIZE_EDGE_BOTTOM_LEFT:
return META_GRAB_OP_RESIZING_SW;
case XDG_SURFACE_RESIZE_EDGE_LEFT:
return META_GRAB_OP_RESIZING_W;
default:
g_warning ("invalid edge: %d", edge);
return META_GRAB_OP_NONE;
}
}
static void static void
xdg_surface_resize (struct wl_client *client, xdg_surface_resize (struct wl_client *client,
struct wl_resource *resource, struct wl_resource *resource,
struct wl_resource *seat, struct wl_resource *seat_resource,
guint32 serial, guint32 serial,
guint32 edges) guint32 edges)
{ {
g_warning ("TODO: support xdg_surface.resize"); MetaWaylandSeat *seat = wl_resource_get_user_data (seat_resource);
MetaWaylandSurfaceExtension *xdg_surface = wl_resource_get_user_data (resource);
if (seat->pointer.button_count == 0 ||
seat->pointer.grab_serial != serial ||
seat->pointer.focus != xdg_surface->surface)
return;
begin_grab_op_on_surface (xdg_surface->surface, seat, grab_op_for_edge (edges));
} }
static void static void