[mutter/wip/fmuellner/contraint-tiling: 14/14] x11: Add support for _GTK_EDGE_CONSTRAINTS atom



commit 446c9b74604a26028c984fedcdf124b9d7ef5e6a
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date:   Fri Aug 18 20:21:37 2017 -0300

    x11: Add support for _GTK_EDGE_CONSTRAINTS atom
    
    To keep feature parity with the Wayland backend, and
    to improve the overall tiling experience with GTK apps,
    add the _GTK_EDGE_CONSTRAINTS X11 atom and update it
    when necessary.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=751857

 src/core/screen.c    |    1 +
 src/x11/atomnames.h  |    1 +
 src/x11/window-x11.c |   30 ++++++++++++++++++++++++++++++
 3 files changed, 32 insertions(+), 0 deletions(-)
---
diff --git a/src/core/screen.c b/src/core/screen.c
index e6c6cdd..429c2d6 100644
--- a/src/core/screen.c
+++ b/src/core/screen.c
@@ -308,6 +308,7 @@ set_supported_hint (MetaScreen *screen)
 
     screen->display->atom__GTK_FRAME_EXTENTS,
     screen->display->atom__GTK_SHOW_WINDOW_MENU,
+    screen->display->atom__GTK_EDGE_CONSTRAINTS,
   };
 
   XChangeProperty (screen->display->xdisplay, screen->xroot,
diff --git a/src/x11/atomnames.h b/src/x11/atomnames.h
index ff6c6cc..dcb1516 100644
--- a/src/x11/atomnames.h
+++ b/src/x11/atomnames.h
@@ -63,6 +63,7 @@ item(_GTK_APP_MENU_OBJECT_PATH)
 item(_GTK_MENUBAR_OBJECT_PATH)
 item(_GTK_FRAME_EXTENTS)
 item(_GTK_SHOW_WINDOW_MENU)
+item(_GTK_EDGE_CONSTRAINTS)
 item(_GNOME_WM_KEYBINDINGS)
 item(_GNOME_PANEL_ACTION)
 item(_GNOME_PANEL_ACTION_MAIN_MENU)
diff --git a/src/x11/window-x11.c b/src/x11/window-x11.c
index bc922c1..36a5e70 100644
--- a/src/x11/window-x11.c
+++ b/src/x11/window-x11.c
@@ -902,6 +902,31 @@ update_net_frame_extents (MetaWindow *window)
   meta_error_trap_pop (window->display);
 }
 
+static void
+update_gtk_edge_constraints (MetaWindow *window)
+{
+  MetaEdgeConstraint *constraints = window->edge_constraints;
+  unsigned long data[1];
+
+  /* Edge constraints */
+  data[0] = (constraints[0] != META_EDGE_CONSTRAINT_NONE ? 1 : 0)    << 0 |
+            (constraints[0] != META_EDGE_CONSTRAINT_MONITOR ? 1 : 0) << 1 |
+            (constraints[1] != META_EDGE_CONSTRAINT_NONE ? 1 : 0)    << 2 |
+            (constraints[1] != META_EDGE_CONSTRAINT_MONITOR ? 1 : 0) << 3 |
+            (constraints[2] != META_EDGE_CONSTRAINT_NONE ? 1 : 0)    << 4 |
+            (constraints[2] != META_EDGE_CONSTRAINT_MONITOR ? 1 : 0) << 5 |
+            (constraints[3] != META_EDGE_CONSTRAINT_NONE ? 1 : 0)    << 6 |
+            (constraints[3] != META_EDGE_CONSTRAINT_MONITOR ? 1 : 0) << 7;
+
+  meta_verbose ("Setting _GTK_EDGE_CONSTRAINTS to %lu\n", data[0]);
+
+  XChangeProperty (window->display->xdisplay,
+                   window->xwindow,
+                   window->display->atom__GTK_EDGE_CONSTRAINTS,
+                   XA_CARDINAL, 32, PropModeReplace,
+                   (guchar*) data, 1);
+}
+
 static gboolean
 sync_request_timeout (gpointer data)
 {
@@ -1259,6 +1284,8 @@ meta_window_x11_move_resize_internal (MetaWindow                *window,
     *result |= META_MOVE_RESIZE_RESULT_MOVED;
   if (need_resize_client || need_resize_frame)
     *result |= META_MOVE_RESIZE_RESULT_RESIZED;
+
+  update_gtk_edge_constraints (window);
 }
 
 static gboolean
@@ -1670,6 +1697,9 @@ meta_window_x11_set_net_wm_state (MetaWindow *window)
           meta_error_trap_pop (window->display);
         }
     }
+
+  /* Edge constraints */
+  update_gtk_edge_constraints (window);
 }
 
 static cairo_region_t *


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