tDo not create windows outside the screen - glazier - window management experiments
(DIR) Log
(DIR) Files
(DIR) Refs
(DIR) Submodules
(DIR) README
(DIR) LICENSE
---
(DIR) commit 215e22e27c3ea682f94d7d7b40f0a18dffcf813c
(DIR) parent ccb463f6bf9e03b746e73f50f51a4dc27607a842
(HTM) Author: Willy Goiffon <dev@z3bra.org>
Date: Sun, 27 Oct 2019 10:38:24 +0100
Do not create windows outside the screen
Diffstat:
M glazier.c | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
---
(DIR) diff --git a/glazier.c b/glazier.c
t@@ -118,7 +118,7 @@ usage(char *name)
int
adopt(xcb_window_t wid)
{
- int x, y, w, h;
+ int x, y, w, h, sw, sh;
if (wm_is_ignored(wid))
return -1;
t@@ -127,6 +127,13 @@ adopt(xcb_window_t wid)
w = wm_get_attribute(wid, ATTR_W);
h = wm_get_attribute(wid, ATTR_H);
wm_get_cursor(0, scrn->root, &x, &y);
+
+ /* prevent windows to pop outside of the screen */
+ sw = wm_get_attribute(scrn->root, ATTR_W);
+ sh = wm_get_attribute(scrn->root, ATTR_H);
+ if ((x + w) > sw) x = sw - w/2;
+ if ((y + h) > sh) y = sh - h/2;
+
wm_teleport(wid, MAX(0, x - w/2), MAX(0, y - h/2), w, h);
}