diff options
author | Vito Caputo <vcaputo@pengaru.com> | 2021-12-25 14:09:38 -0800 |
---|---|---|
committer | Vito Caputo <vcaputo@pengaru.com> | 2021-12-25 14:09:38 -0800 |
commit | f12e78b56fb26ea97b4e969a3ccb12c9e3f21a73 (patch) | |
tree | 344c6242f5cb8dbe7c73185d2cedc3f7dac2b7d1 /src/xwindow.c | |
parent | ce8954f3587e073a7c4b019b6fbdc4e3bc50b62d (diff) |
xwindow: introduce vwm_xwin_should_manage()
Preparatory commit for applying a heuristic to honoring
override_redirect.
The X11 specification more or less requires honoring this window
flag, but it's really a disaster to blindly do so.
This function will be used to evaluate override_redirect wherever
it's currently being directly used to determine wether a window
should be managed or not.
As-implemented it only ignores override_redirect when the window
dimensions match its screen dimensions (fullscreen windows). In
the future this might get loosened up a bit to encompass windows
covering more than something unexpectedly large for a
tooltip/popup, like 50% of the screen, since valid
override_redirect uses should arguably be limited to small
windows.
Diffstat (limited to 'src/xwindow.c')
-rw-r--r-- | src/xwindow.c | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/src/xwindow.c b/src/xwindow.c index 18ebf5f..a682e9f 100644 --- a/src/xwindow.c +++ b/src/xwindow.c @@ -109,6 +109,35 @@ void vwm_xwin_setup_chart(vwm_t *vwm, vwm_xwindow_t *xwin) } } +/* override_redirect windows typically should not be managed, and it'd be nice if we could + * just blindly respect that, but X is a dumpster fire and for multiple reasons I'm going + * to use some heuristics to only not manage override_redirect windows when they're substantially + * smaller than the size of the display (popup/popover type shit). + * + * When any old X client can create a fullscreen override_redirect window it not only makes + * fullscreen games and shit not explicitly focusable/managable from a vwm perspective, it + * also creates a real potential security issue. + */ +int vwm_xwin_should_manage(vwm_t *vwm, vwm_xwindow_t *xwin) +{ + const vwm_screen_t *scr; + + if (!xwin->attrs.override_redirect) + return 1; + + scr = vwm_screen_find(vwm, VWM_SCREEN_REL_XWIN, xwin); + if (!scr) + return 1; + + /* TODO: for now just using an exact fullscreen heuristic, but should really + * trigger for > XX% coverage. This suffices for managing annoying + * override_redirect fullscreen windows. + */ + if (xwin->attrs.width == scr->width && xwin->attrs.height == scr->height) + return 1; + + return 0; +} /* creates and potentially manages a new window (called in response to CreateNotify events, and during startup for all existing windows) */ /* if the window is already mapped and not an override_redirect window, it becomes managed here. */ |