[metacity/wip/muktupavels/work-areas-v3] screen: add support for _GTK_WORKAREAS_Dn



commit 3d8b03dc68774e35d80bdb6eebba2cce75551933
Author: Alberts Muktupāvels <alberts muktupavels gmail com>
Date:   Sun Dec 23 17:58:16 2018 +0200

    screen: add support for _GTK_WORKAREAS_Dn
    
    In addition to existing _NET_WORKAREA property set also new
    _GTK_WORKAREAS_Dn property where n is desktop number (between 0
    and _NET_NUMBER_OF_DESKTOPS - 1).
    
    https://mail.gnome.org/archives/wm-spec-list/2018-December/msg00000.html
    https://gitlab.freedesktop.org/xdg/xdg-specs/merge_requests/22
    
    https://gitlab.gnome.org/GNOME/metacity/merge_requests/3

 src/core/atomnames.h |  1 +
 src/core/screen.c    | 47 ++++++++++++++++++++++++++++++++++++++++++++++-
 2 files changed, 47 insertions(+), 1 deletion(-)
---
diff --git a/src/core/atomnames.h b/src/core/atomnames.h
index e44dc2f3..8e2b4593 100644
--- a/src/core/atomnames.h
+++ b/src/core/atomnames.h
@@ -60,6 +60,7 @@ item(_METACITY_TOGGLE_VERBOSE)
 item(_GTK_THEME_VARIANT)
 item(_GTK_FRAME_EXTENTS)
 item(_GTK_SHOW_WINDOW_MENU)
+item(_GTK_WORKAREAS)
 item(_GNOME_PANEL_ACTION)
 item(_GNOME_PANEL_ACTION_MAIN_MENU)
 item(_GNOME_PANEL_ACTION_RUN_DIALOG)
diff --git a/src/core/screen.c b/src/core/screen.c
index 87474f74..5560bdd2 100644
--- a/src/core/screen.c
+++ b/src/core/screen.c
@@ -100,7 +100,8 @@ set_supported_hint (MetaScreen *screen)
 #undef EWMH_ATOMS_ONLY
 
     screen->display->atom__GTK_FRAME_EXTENTS,
-    screen->display->atom__GTK_SHOW_WINDOW_MENU
+    screen->display->atom__GTK_SHOW_WINDOW_MENU,
+    screen->display->atom__GTK_WORKAREAS
   };
 
   XChangeProperty (screen->display->xdisplay, screen->xroot,
@@ -1837,6 +1838,48 @@ meta_create_offscreen_window (Display *xdisplay,
                         &attrs);
 }
 
+static void
+set_workspace_work_area_hint (MetaWorkspace *workspace,
+                              MetaScreen    *screen)
+{
+  unsigned long *data;
+  unsigned long *tmp;
+  int i;
+  gchar *workarea_name;
+  Atom workarea_atom;
+
+  data = g_new (unsigned long, screen->n_monitor_infos * 4);
+  tmp = data;
+
+  for (i = 0; i < screen->n_monitor_infos; i++)
+    {
+      MetaRectangle area;
+
+      meta_workspace_get_work_area_for_monitor (workspace, i, &area);
+
+      tmp[0] = area.x;
+      tmp[1] = area.y;
+      tmp[2] = area.width;
+      tmp[3] = area.height;
+
+      tmp += 4;
+    }
+
+  workarea_name = g_strdup_printf ("_GTK_WORKAREAS_D%d",
+                                   meta_workspace_index (workspace));
+
+  workarea_atom = XInternAtom (screen->display->xdisplay, workarea_name, False);
+  g_free (workarea_name);
+
+  meta_error_trap_push (screen->display);
+  XChangeProperty (screen->display->xdisplay, screen->xroot, workarea_atom,
+                   XA_CARDINAL, 32, PropModeReplace,
+                   (guchar*) data, screen->n_monitor_infos * 4);
+  meta_error_trap_pop (screen->display);
+
+  g_free (data);
+}
+
 static void
 set_work_area_hint (MetaScreen *screen)
 {
@@ -1857,6 +1900,8 @@ set_work_area_hint (MetaScreen *screen)
       if (workspace->screen == screen)
         {
           meta_workspace_get_work_area_all_monitors (workspace, &area);
+          set_workspace_work_area_hint (workspace, screen);
+
           tmp[0] = area.x;
           tmp[1] = area.y;
           tmp[2] = area.width;


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