From 2901e1e4769e8ffcf2def9ced9b7bda02763294c Mon Sep 17 00:00:00 2001 From: Tim Schumacher Date: Fri, 2 Apr 2021 00:48:48 +0200 Subject: [PATCH] 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 --- CHANGELOG.md | 3 +++ config/config.cmake | 1 + src/components/bar.cpp | 14 +++++++++++++- 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2f136205..545bfef6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/config/config.cmake b/config/config.cmake index 5acd8ce9..a5472390 100644 --- a/config/config.cmake +++ b/config/config.cmake @@ -63,6 +63,7 @@ tray-position = right tray-padding = 2 ;tray-background = #0063ff +;wm-restack = generic ;wm-restack = bspwm ;wm-restack = i3 diff --git a/src/components/bar.cpp b/src/components/bar.cpp index 614f0f56..3abe7e43 100644 --- a/src/components/bar.cpp +++ b/src/components/bar.cpp @@ -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) {