diff options
author | raveit65 <[email protected]> | 2021-04-10 16:37:40 +0200 |
---|---|---|
committer | raveit65 <[email protected]> | 2021-06-07 20:09:03 +0200 |
commit | 3ed0ddb242a4804cd7fcfcfcf39a47766eaa816d (patch) | |
tree | b11f566e6c4f90db6a1868c834c6d84ca5dd15a7 /src/core/window.c | |
parent | 4e4fd6c512423b16640914b33192a32f290b0ef1 (diff) | |
download | marco-3ed0ddb242a4804cd7fcfcfcf39a47766eaa816d.tar.bz2 marco-3ed0ddb242a4804cd7fcfcfcf39a47766eaa816d.tar.xz |
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
Diffstat (limited to 'src/core/window.c')
-rw-r--r-- | src/core/window.c | 88 |
1 files changed, 88 insertions, 0 deletions
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 @@ -6240,6 +6240,91 @@ meta_window_update_struts (MetaWindow *window) 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; |