From def5e86673ba423a84d0a415ab93d135a76a8259 Mon Sep 17 00:00:00 2001 From: "Jasper St. Pierre" Date: Fri, 7 Feb 2014 17:29:35 -0500 Subject: [PATCH] wayland: Add support for the set_margin request --- protocol/xdg-shell.xml | 26 ++++++++++++++++++++++++++ src/core/window-private.h | 3 +++ src/core/window-props.c | 18 +++++++----------- src/core/window.c | 17 +++++++++++++++++ src/wayland/meta-wayland-surface.c | 21 +++++++++++++++++++++ 5 files changed, 74 insertions(+), 11 deletions(-) diff --git a/protocol/xdg-shell.xml b/protocol/xdg-shell.xml index 5c21f4ebc..f0d04aa34 100644 --- a/protocol/xdg-shell.xml +++ b/protocol/xdg-shell.xml @@ -124,6 +124,32 @@ + + + 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. + + + + + + + Set a short title for the surface. diff --git a/src/core/window-private.h b/src/core/window-private.h index c18b6a99a..27ffc9298 100644 --- a/src/core/window-private.h +++ b/src/core/window-private.h @@ -733,6 +733,9 @@ void meta_window_set_transient_for (MetaWindow *window, void meta_window_set_opacity (MetaWindow *window, guint opacity); +void meta_window_set_custom_frame_extents (MetaWindow *window, + GtkBorder *extents); + void meta_window_handle_enter (MetaWindow *window, guint32 timestamp, guint root_x, diff --git a/src/core/window-props.c b/src/core/window-props.c index 6bb44e934..eabdcfae4 100644 --- a/src/core/window-props.c +++ b/src/core/window-props.c @@ -303,22 +303,18 @@ reload_gtk_frame_extents (MetaWindow *window, } else { - GtkBorder *extents = &window->custom_frame_extents; - - window->has_custom_frame_extents = TRUE; - extents->left = (int)value->v.cardinal_list.cardinals[0]; - extents->right = (int)value->v.cardinal_list.cardinals[1]; - extents->top = (int)value->v.cardinal_list.cardinals[2]; - extents->bottom = (int)value->v.cardinal_list.cardinals[3]; + GtkBorder extents; + extents.left = (int)value->v.cardinal_list.cardinals[0]; + extents.right = (int)value->v.cardinal_list.cardinals[1]; + extents.top = (int)value->v.cardinal_list.cardinals[2]; + extents.bottom = (int)value->v.cardinal_list.cardinals[3]; + meta_window_set_custom_frame_extents (window, &extents); } } 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 diff --git a/src/core/window.c b/src/core/window.c index 984b3508a..0edfbcbfd 100644 --- a/src/core/window.c +++ b/src/core/window.c @@ -10882,3 +10882,20 @@ meta_window_get_toplevel_xwindow (MetaWindow *window) { 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); +} diff --git a/src/wayland/meta-wayland-surface.c b/src/wayland/meta-wayland-surface.c index cd7229813..2e5201e44 100644 --- a/src/wayland/meta-wayland-surface.c +++ b/src/wayland/meta-wayland-surface.c @@ -720,6 +720,26 @@ xdg_surface_set_transient_for (struct wl_client *client, 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 xdg_surface_set_title (struct wl_client *client, 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 = { xdg_surface_destroy, xdg_surface_set_transient_for, + xdg_surface_set_margin, xdg_surface_set_title, xdg_surface_set_app_id, xdg_surface_pong,