fix(bar): Update struts when hiding (#2702)

When the bar is hidden, the struts should be 0 so that WMs can resize
their windows and not leave a gap.

Ref #2701
This commit is contained in:
Patrick Ziegler 2022-04-27 21:09:59 +02:00 committed by GitHub
parent bc9dda266f
commit efbd8e394f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 43 additions and 35 deletions

View File

@ -14,6 +14,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- `internal/battery`: `poll-interval` not working ([`#2649`](https://github.com/polybar/polybar/issues/2649), [`#2677`](https://github.com/polybar/polybar/pull/2677))
- ipc: Polybar failing to open IPC channel after another user already ran polybar, if `XDG_RUNTIME_DIR` is not set ([`#2683`](https://github.com/polybar/polybar/issues/2683), [`#2684`](https://github.com/polybar/polybar/pull/2684))
- No overlines/underlines being drawn when using offsets ([`#2685`](https://github.com/polybar/polybar/pull/2685))
- Update struts (`_NET_WM_STRUT_PARTIAL`) when hiding the bar ([`#2702`](https://github.com/polybar/polybar/pull/2702))
## [3.6.2] - 2022-04-03
### Fixed

View File

@ -440,10 +440,11 @@ void bar::hide() {
try {
m_log.info("Hiding bar window");
m_visible = false;
reconfigure_struts();
m_sig.emit(visibility_change{false});
m_connection.unmap_window_checked(m_opts.window);
m_connection.flush();
m_visible = false;
} catch (const exception& err) {
m_log.err("Failed to unmap bar window (err=%s", err.what());
}
@ -556,6 +557,8 @@ void bar::reconfigure_pos() {
* Reconfigure window strut values
*/
void bar::reconfigure_struts() {
window win{m_connection, m_opts.window};
if (m_visible) {
auto geom = m_connection.get_geometry(m_screen->root());
int h = m_opts.size.h + m_opts.offset.y;
@ -589,9 +592,11 @@ void bar::reconfigure_struts() {
correction = std::max(correction, 0);
}
window win{m_connection, m_opts.window};
win.reconfigure_struts(m_opts.size.w, h + correction, m_opts.pos.x, m_opts.bottom);
} else {
// Set struts to 0 for invisible bars
win.reconfigure_struts(0, 0, 0, m_opts.bottom);
}
}
/**
@ -634,6 +639,8 @@ void bar::broadcast_visibility() {
}
void bar::map_window() {
m_visible = true;
/**
* First reconfigures the window so that WMs that discard some information
* when unmapping have the correct window properties (geometry etc).
@ -648,8 +655,6 @@ void bar::map_window() {
* mapping. Additionally updating the window position after mapping seems to fix that.
*/
reconfigure_pos();
m_visible = true;
}
void bar::trigger_click(mousebtn btn, int pos) {

View File

@ -57,14 +57,16 @@ window window::reconfigure_pos(short int x, short int y) {
window window::reconfigure_struts(uint32_t w, uint32_t strut, uint32_t x, bool bottom) {
std::array<uint32_t, 12> values{};
uint32_t end_x = std::max<int>(0, x + w - 1);
if (bottom) {
values[to_integral(strut::BOTTOM)] = strut;
values[to_integral(strut::BOTTOM_START_X)] = x;
values[to_integral(strut::BOTTOM_END_X)] = x + w - 1;
values[to_integral(strut::BOTTOM_END_X)] = end_x;
} else {
values[to_integral(strut::TOP)] = strut;
values[to_integral(strut::TOP_START_X)] = x;
values[to_integral(strut::TOP_END_X)] = x + w - 1;
values[to_integral(strut::TOP_END_X)] = end_x;
}
connection().change_property_checked(