From 3ed0ddb242a4804cd7fcfcfcf39a47766eaa816d Mon Sep 17 00:00:00 2001 From: raveit65 Date: Sat, 10 Apr 2021 16:37:40 +0200 Subject: window: add support for _GNOME_WM_STRUT_AREA In addition to existing properties use also new _GNOME_WM_STRUT_AREA property that allows creating struts between monitors. https://mail.gnome.org/archives/wm-spec-list/2018-December/msg00000.html https://gitlab.freedesktop.org/xdg/xdg-specs/merge_requests/22 origin commit: https://gitlab.gnome.org/GNOME/metacity/commit/922de13 --- src/core/window.c | 88 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 88 insertions(+) (limited to 'src/core/window.c') diff --git a/src/core/window.c b/src/core/window.c index add00789..55badf54 100644 --- a/src/core/window.c +++ b/src/core/window.c @@ -6239,6 +6239,91 @@ meta_window_update_struts (MetaWindow *window) new_struts = NULL; if (meta_prop_get_cardinal_list (window->display, + window->xwindow, + window->display->atom__GNOME_WM_STRUT_AREA, + &struts, &nitems)) + { + if (nitems != 4) + { + meta_verbose ("_GNOME_WM_STRUT_AREA on %s has %d values instead of 4\n", + window->desc, nitems); + } + else + { + MetaStrut *temp; + MetaSide side; + gboolean valid; + int i; + + temp = g_new (MetaStrut, 1); + + temp->rect.x = struts[0]; + temp->rect.y = struts[1]; + temp->rect.width = struts[2]; + temp->rect.height = struts[3]; + + side = META_SIDE_LEFT; + valid = FALSE; + + for (i = 0; i < window->screen->n_xinerama_infos; i++) + { + MetaRectangle monitor; + + monitor = window->screen->xinerama_infos[i].rect; + if (!meta_rectangle_contains_rect (&monitor, &temp->rect)) + continue; + + if (temp->rect.height > temp->rect.width) + { + if (temp->rect.x == monitor.x) + { + side = META_SIDE_LEFT; + valid = TRUE; + } + else if (temp->rect.x + temp->rect.width == monitor.x + monitor.width) + { + side = META_SIDE_RIGHT; + valid = TRUE; + } + } + else + { + if (temp->rect.y == monitor.y) + { + side = META_SIDE_TOP; + valid = TRUE; + } + else if (temp->rect.y + temp->rect.height == monitor.y + monitor.height) + { + side = META_SIDE_BOTTOM; + valid = TRUE; + } + } + } + + if (valid) + { + temp->side = side; + temp->edge = META_EDGE_XINERAMA; + + new_struts = g_slist_prepend (new_struts, temp); + } + else + { + g_free (temp); + } + } + + meta_XFree (struts); + } + else + { + meta_verbose ("No _GNOME_WM_STRUT_AREA property for %s\n", + window->desc); + } + + if (!new_struts && + meta_prop_get_cardinal_list (window->display, window->xwindow, window->display->atom__NET_WM_STRUT_PARTIAL, &struts, &nitems)) @@ -6264,6 +6349,7 @@ meta_window_update_struts (MetaWindow *window) temp = g_new (MetaStrut, 1); temp->side = 1 << i; /* See MetaSide def. Matches nicely, eh? */ + temp->edge = META_EDGE_SCREEN; temp->rect = window->screen->rect; switch (temp->side) { @@ -6327,6 +6413,7 @@ meta_window_update_struts (MetaWindow *window) temp = g_new (MetaStrut, 1); temp->side = 1 << i; + temp->edge = META_EDGE_SCREEN; temp->rect = window->screen->rect; switch (temp->side) { @@ -6370,6 +6457,7 @@ meta_window_update_struts (MetaWindow *window) MetaStrut *new_strut = (MetaStrut*) new_iter->data; if (old_strut->side != new_strut->side || + old_strut->edge != new_strut->edge || !meta_rectangle_equal (&old_strut->rect, &new_strut->rect)) break; -- cgit v1.2.1