Add wm-restack=generic option that lowers polybar to the bottom of the stack (#2404)

* Add wm-restack=generic to lower polybar to the bottom of the stack

Previously wm-restack only supported bspwm and i3. Both have a special
top-level window that polybar detects and places itself directly above.
This patch adds wm-restack=generic which simply lowers polybar to the
very bottom of the stack. This option was tested and confirmed to work
with xmonad which doesn't have a special top-level window and therefore
doesn't require special handling like bspwm and i3.

Fixes #2205

* Update src/components/bar.cpp

Co-authored-by: Patrick Ziegler <p.ziegler96@gmail.com>
This commit is contained in:
Tim Schumacher 2021-04-02 00:48:48 +02:00 committed by GitHub
parent 97759ce585
commit 2901e1e476
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 17 additions and 1 deletions

View File

@ -90,6 +90,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
windows per workspace
([`#604`](https://github.com/polybar/polybar/issues/604))
- `internal/backlight`: added `use-actual-brightness` option
- Added `wm-restack = generic` option that lowers polybar to the bottom of the stack.
Fixes the issue where the bar is being drawn on top of fullscreen windows in xmonad.
([`#2205`](https://github.com/polybar/polybar/issues/2205))
### Changed
- Slight changes to the value ranges the different ramp levels are responsible

View File

@ -63,6 +63,7 @@ tray-position = right
tray-padding = 2
;tray-background = #0063ff
;wm-restack = generic
;wm-restack = bspwm
;wm-restack = i3

View File

@ -458,7 +458,19 @@ void bar::restack_window() {
auto restacked = false;
if (wm_restack == "bspwm") {
if (wm_restack == "generic") {
try {
auto children = m_connection.query_tree(m_connection.screen()->root).children();
if (children.begin() != children.end() && *children.begin() != m_opts.window) {
const unsigned int value_mask = XCB_CONFIG_WINDOW_SIBLING | XCB_CONFIG_WINDOW_STACK_MODE;
const unsigned int value_list[2]{*children.begin(), XCB_STACK_MODE_BELOW};
m_connection.configure_window_checked(m_opts.window, value_mask, value_list);
}
restacked = true;
} catch (const exception& err) {
m_log.err("Failed to restack bar window (err=%s)", err.what());
}
} else if (wm_restack == "bspwm") {
restacked = bspwm_util::restack_to_root(m_connection, m_opts.monitor, m_opts.window);
#if ENABLE_I3
} else if (wm_restack == "i3" && m_opts.override_redirect) {