[metacity/wip/muktupavels/work-areas-v3: 1/4] screen: add support for _NET_WORKAREAS_Dn



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

    screen: add support for _NET_WORKAREAS_Dn
    
    In addition to existing property set also new _NET_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

 src/core/atomnames.h |  1 +
 src/core/screen.c    | 44 ++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 45 insertions(+)
---
diff --git a/src/core/atomnames.h b/src/core/atomnames.h
index bab2630b..8480d20d 100644
--- a/src/core/atomnames.h
+++ b/src/core/atomnames.h
@@ -135,6 +135,7 @@ item(_NET_WM_STATE_FULLSCREEN)
 item(_NET_WM_PING)
 item(_NET_WM_PID)
 item(_NET_WORKAREA)
+item(_NET_WORKAREAS)
 item(_NET_SHOWING_DESKTOP)
 item(_NET_DESKTOP_LAYOUT)
 item(_NET_DESKTOP_NAMES)
diff --git a/src/core/screen.c b/src/core/screen.c
index aec8f11f..19e35202 100644
--- a/src/core/screen.c
+++ b/src/core/screen.c
@@ -1838,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 ("_NET_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)
 {
@@ -1858,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]