[mutter/wip/gbsneto/edge-constraints: 3/4] wayland: Send edge constraints



commit 129dcbca980ea17c53da15dcdcbe887fcc45e2ba
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date:   Thu Aug 17 00:49:36 2017 -0300

    wayland: Send edge constraints
    
    Following up the previous patch, this patch makes the
    Wayland backend send the edge constraints through a
    custom protocol extension internal to GTK.
    
    As it mature, we can think of upstreaming the protocol
    to Wayland itself.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=751857

 src/wayland/meta-wayland-gtk-shell.c |   36 ++++++++++++++++++++++++++++-----
 src/wayland/protocol/gtk-shell.xml   |   11 ++++++++++
 2 files changed, 41 insertions(+), 6 deletions(-)
---
diff --git a/src/wayland/meta-wayland-gtk-shell.c b/src/wayland/meta-wayland-gtk-shell.c
index d6e249f..eba4e6f 100644
--- a/src/wayland/meta-wayland-gtk-shell.c
+++ b/src/wayland/meta-wayland-gtk-shell.c
@@ -153,12 +153,36 @@ fill_states (struct wl_array *states,
 {
   uint32_t *s;
 
-  if (window->tile_mode == META_TILE_LEFT ||
-      window->tile_mode == META_TILE_RIGHT)
-    {
-      s = wl_array_add (states, sizeof *s);
-      *s = GTK_SURFACE1_STATE_TILED;
-    }
+#define add_state(st) { s = wl_array_add (states, sizeof *s); *s = st; }
+
+  if (window->tile_mode == META_TILE_LEFT || window->tile_mode == META_TILE_RIGHT)
+    add_state (GTK_SURFACE1_STATE_TILED);
+
+  /* Top */
+  if (window->edge_constraints[0] != META_EDGE_CONSTRAINT_NONE)
+    add_state (GTK_SURFACE1_EDGE_CONSTRAINT_TOP_TILED);
+  if (window->edge_constraints[0] != META_EDGE_CONSTRAINT_MONITOR)
+    add_state (GTK_SURFACE1_EDGE_CONSTRAINT_TOP_RESIZABLE);
+
+  /* Right */
+  if (window->edge_constraints[1] != META_EDGE_CONSTRAINT_NONE)
+    add_state (GTK_SURFACE1_EDGE_CONSTRAINT_RIGHT_TILED);
+  if (window->edge_constraints[1] != META_EDGE_CONSTRAINT_MONITOR)
+    add_state (GTK_SURFACE1_EDGE_CONSTRAINT_RIGHT_RESIZABLE);
+
+  /* Bottom */
+  if (window->edge_constraints[2] != META_EDGE_CONSTRAINT_NONE)
+    add_state (GTK_SURFACE1_EDGE_CONSTRAINT_BOTTOM_TILED);
+  if (window->edge_constraints[2] != META_EDGE_CONSTRAINT_MONITOR)
+    add_state (GTK_SURFACE1_EDGE_CONSTRAINT_BOTTOM_RESIZABLE);
+
+  /* Left */
+  if (window->edge_constraints[3] != META_EDGE_CONSTRAINT_NONE)
+    add_state (GTK_SURFACE1_EDGE_CONSTRAINT_LEFT_TILED);
+  if (window->edge_constraints[3] != META_EDGE_CONSTRAINT_MONITOR)
+    add_state (GTK_SURFACE1_EDGE_CONSTRAINT_LEFT_RESIZABLE);
+
+#undef add_state
 }
 
 static void
diff --git a/src/wayland/protocol/gtk-shell.xml b/src/wayland/protocol/gtk-shell.xml
index 5cfdd42..711a0c0 100644
--- a/src/wayland/protocol/gtk-shell.xml
+++ b/src/wayland/protocol/gtk-shell.xml
@@ -53,6 +53,17 @@
       <entry name="tiled" value="1"/>
     </enum>
 
+    <enum name="edge_constraint">
+      <entry name="top_tiled" value="2"/>
+      <entry name="top_resizable" value="3"/>
+      <entry name="right_tiled" value="4"/>
+      <entry name="right_resizable" value="5"/>
+      <entry name="bottom_tiled" value="6"/>
+      <entry name="bottom_resizable" value="7"/>
+      <entry name="left_tiled" value="8"/>
+      <entry name="left_resizable" value="9"/>
+    </enum>
+
     <event name="configure">
       <arg name="states" type="array"/>
     </event>


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