wayland: Add support for the set_margin request

This commit is contained in:
Jasper St. Pierre 2014-02-07 17:29:35 -05:00
parent 0c213c8fee
commit def5e86673
5 changed files with 74 additions and 11 deletions

View File

@ -124,6 +124,32 @@
<arg name="parent" type="object" interface="wl_surface" allow-null="true"/> <arg name="parent" type="object" interface="wl_surface" allow-null="true"/>
</request> </request>
<request name="set_margin">
<description summary="set the visible frame boundaries">
This tells the compositor what the visible size of the window
should be, so it can use it to determine what borders to use for
constrainment and alignment.
CSD often has invisible areas for decoration purposes, like drop
shadows. These "shadow" drawings need to be subtracted out of the
normal boundaries of the window when computing where to place
windows (e.g. to set this window so it's centered on top of another,
or to put it to the left or right of the screen.)
This value should change as little as possible at runtime, to
prevent flicker.
This value is also ignored when the window is maximized or
fullscreen, and assumed to be 0.
If never called, this value is assumed to be 0.
</description>
<arg name="left_margin" type="int"/>
<arg name="right_margin" type="int"/>
<arg name="top_margin" type="int"/>
<arg name="bottom_margin" type="int"/>
</request>
<request name="set_title"> <request name="set_title">
<description summary="set surface title"> <description summary="set surface title">
Set a short title for the surface. Set a short title for the surface.

View File

@ -733,6 +733,9 @@ void meta_window_set_transient_for (MetaWindow *window,
void meta_window_set_opacity (MetaWindow *window, void meta_window_set_opacity (MetaWindow *window,
guint opacity); guint opacity);
void meta_window_set_custom_frame_extents (MetaWindow *window,
GtkBorder *extents);
void meta_window_handle_enter (MetaWindow *window, void meta_window_handle_enter (MetaWindow *window,
guint32 timestamp, guint32 timestamp,
guint root_x, guint root_x,

View File

@ -303,22 +303,18 @@ reload_gtk_frame_extents (MetaWindow *window,
} }
else else
{ {
GtkBorder *extents = &window->custom_frame_extents; GtkBorder extents;
extents.left = (int)value->v.cardinal_list.cardinals[0];
window->has_custom_frame_extents = TRUE; extents.right = (int)value->v.cardinal_list.cardinals[1];
extents->left = (int)value->v.cardinal_list.cardinals[0]; extents.top = (int)value->v.cardinal_list.cardinals[2];
extents->right = (int)value->v.cardinal_list.cardinals[1]; extents.bottom = (int)value->v.cardinal_list.cardinals[3];
extents->top = (int)value->v.cardinal_list.cardinals[2]; meta_window_set_custom_frame_extents (window, &extents);
extents->bottom = (int)value->v.cardinal_list.cardinals[3];
} }
} }
else else
{ {
window->has_custom_frame_extents = FALSE; meta_window_set_custom_frame_extents (window, NULL);
} }
if (!initial)
meta_window_queue(window, META_QUEUE_MOVE_RESIZE);
} }
static void static void

View File

@ -10882,3 +10882,20 @@ meta_window_get_toplevel_xwindow (MetaWindow *window)
{ {
return window->frame ? window->frame->xwindow : window->xwindow; return window->frame ? window->frame->xwindow : window->xwindow;
} }
void
meta_window_set_custom_frame_extents (MetaWindow *window,
GtkBorder *extents)
{
if (extents)
{
window->has_custom_frame_extents = TRUE;
window->custom_frame_extents = *extents;
}
else
{
window->has_custom_frame_extents = FALSE;
}
meta_window_queue (window, META_QUEUE_MOVE_RESIZE);
}

View File

@ -720,6 +720,26 @@ xdg_surface_set_transient_for (struct wl_client *client,
meta_window_set_transient_for (surface->window, transient_for); meta_window_set_transient_for (surface->window, transient_for);
} }
static void
xdg_surface_set_margin (struct wl_client *client,
struct wl_resource *resource,
int32_t left_margin,
int32_t right_margin,
int32_t top_margin,
int32_t bottom_margin)
{
MetaWaylandSurfaceExtension *xdg_surface = wl_resource_get_user_data (resource);
MetaWaylandSurface *surface = wl_container_of (xdg_surface, surface, xdg_surface);
GtkBorder extents;
extents.left = left_margin;
extents.right = right_margin;
extents.top = top_margin;
extents.bottom = bottom_margin;
meta_window_set_custom_frame_extents (surface->window, &extents);
}
static void static void
xdg_surface_set_title (struct wl_client *client, xdg_surface_set_title (struct wl_client *client,
struct wl_resource *resource, struct wl_resource *resource,
@ -901,6 +921,7 @@ xdg_surface_set_minimized (struct wl_client *client,
static const struct xdg_surface_interface meta_wayland_xdg_surface_interface = { static const struct xdg_surface_interface meta_wayland_xdg_surface_interface = {
xdg_surface_destroy, xdg_surface_destroy,
xdg_surface_set_transient_for, xdg_surface_set_transient_for,
xdg_surface_set_margin,
xdg_surface_set_title, xdg_surface_set_title,
xdg_surface_set_app_id, xdg_surface_set_app_id,
xdg_surface_pong, xdg_surface_pong,