From b413672a51d1fc59cb14709a38a0af20b09c8935 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alberts=20Muktup=C4=81vels?= Date: Fri, 15 Jun 2018 01:17:24 +0300 Subject: [PATCH] x11-display: set per-monitor work areas In addition to existing property set also new _NET_WORKAREA_Mn property where n is Xinerama monitor index. The property in its form is same as _NET_WORKAREA except that work area is for monitor not whole screen. --- src/x11/atomnames.h | 1 + src/x11/meta-x11-display.c | 47 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 48 insertions(+) diff --git a/src/x11/atomnames.h b/src/x11/atomnames.h index ed3c72a09..0a5b3dedd 100644 --- a/src/x11/atomnames.h +++ b/src/x11/atomnames.h @@ -142,6 +142,7 @@ item(_NET_WM_STATE_FULLSCREEN) item(_NET_WM_PING) item(_NET_WM_PID) item(_NET_WORKAREA) +item(_NET_WORKAREA_Mn) item(_NET_SHOWING_DESKTOP) item(_NET_DESKTOP_LAYOUT) item(_NET_DESKTOP_NAMES) diff --git a/src/x11/meta-x11-display.c b/src/x11/meta-x11-display.c index b2510b530..4fb251e57 100644 --- a/src/x11/meta-x11-display.c +++ b/src/x11/meta-x11-display.c @@ -915,6 +915,9 @@ set_work_area_hint (MetaDisplay *display, GList *l; unsigned long *data, *tmp; MetaRectangle area; + MetaBackend *backend; + MetaMonitorManager *monitor_manager; + GList *logical_monitors, *lm; num_workspaces = meta_workspace_manager_get_n_workspaces (workspace_manager); data = g_new (unsigned long, num_workspaces * 4); @@ -941,6 +944,50 @@ set_work_area_hint (MetaDisplay *display, (guchar*) data, num_workspaces*4); meta_x11_error_trap_pop (x11_display); + backend = meta_get_backend (); + monitor_manager = meta_backend_get_monitor_manager (backend); + logical_monitors = meta_monitor_manager_get_logical_monitors (monitor_manager); + + for (lm = logical_monitors; lm; lm = lm->next) + { + MetaLogicalMonitor *logical_monitor = lm->data; + int xinerama_index; + gchar *workarea_name; + Atom workarea_atom; + + tmp = data; + + for (l = workspace_manager->workspaces; l; l = l->next) + { + MetaWorkspace *workspace = l->data; + + meta_workspace_get_work_area_for_logical_monitor (workspace, + logical_monitor, + &area); + + tmp[0] = area.x; + tmp[1] = area.y; + tmp[2] = area.width; + tmp[3] = area.height; + + tmp += 4; + } + + xinerama_index = meta_x11_display_logical_monitor_to_xinerama_index (x11_display, + logical_monitor); + workarea_name = g_strdup_printf ("_NET_WORKAREA_M%d", xinerama_index); + workarea_atom = XInternAtom (x11_display->xdisplay, workarea_name, False); + g_free (workarea_name); + + meta_x11_error_trap_push (x11_display); + XChangeProperty (x11_display->xdisplay, + x11_display->xroot, + workarea_atom, + XA_CARDINAL, 32, PropModeReplace, + (guchar*) data, num_workspaces*4); + meta_x11_error_trap_pop (x11_display); + } + g_free (data); }