[mutter/xdg-shell: 3/3] wayland: Add support for the set_margin request



commit def5e86673ba423a84d0a415ab93d135a76a8259
Author: Jasper St. Pierre <jstpierre mecheye net>
Date:   Fri Feb 7 17:29:35 2014 -0500

    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 5c21f4e..f0d04aa 100644
--- a/protocol/xdg-shell.xml
+++ b/protocol/xdg-shell.xml
@@ -124,6 +124,32 @@
       <arg name="parent" type="object" interface="wl_surface" allow-null="true"/>
     </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">
       <description summary="set surface title">
        Set a short title for the surface.
diff --git a/src/core/window-private.h b/src/core/window-private.h
index c18b6a9..27ffc92 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 6bb44e9..eabdcfa 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 984b350..0edfbcb 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 cd72298..2e5201e 100644
--- a/src/wayland/meta-wayland-surface.c
+++ b/src/wayland/meta-wayland-surface.c
@@ -721,6 +721,26 @@ xdg_surface_set_transient_for (struct wl_client *client,
 }
 
 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,
                        const char *title)
@@ -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,


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]