diff --git a/CHANGELOG.md b/CHANGELOG.md index 1e28cdc0..40363f2e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -222,6 +222,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - `internal/battery`: More accurate battery state ([`#2563`](https://github.com/polybar/polybar/issues/2563)) - Some modules stop updating when system time moves backwards. ([`#857`](https://github.com/polybar/polybar/issues/857), [`#1932`](https://github.com/polybar/polybar/issues/1932)) +- Broken positioning in Openbox when the bar is hidden and shown again + ([`#2021`](https://github.com/polybar/polybar/issues/2021)) ## [3.5.7] - 2021-09-21 ### Fixed diff --git a/include/x11/icccm.hpp b/include/x11/icccm.hpp index d27bbb93..1dfa8a24 100644 --- a/include/x11/icccm.hpp +++ b/include/x11/icccm.hpp @@ -13,6 +13,8 @@ namespace icccm_util { void set_wm_name(xcb_connection_t* c, xcb_window_t w, const char* wmname, size_t l, const char* wmclass, size_t l2); void set_wm_protocols(xcb_connection_t* c, xcb_window_t w, vector flags); bool get_wm_urgency(xcb_connection_t* c, xcb_window_t w); + + void set_wm_size_hints(xcb_connection_t* c, xcb_window_t w, int x, int y, int width, int height); } POLYBAR_NS_END diff --git a/src/components/bar.cpp b/src/components/bar.cpp index a793a8d7..72716579 100644 --- a/src/components/bar.cpp +++ b/src/components/bar.cpp @@ -593,6 +593,8 @@ void bar::reconfigure_wm_hints() { m_log.trace("bar: Set window _NET_WM_PID"); ewmh_util::set_wm_pid(win); + + icccm_util::set_wm_size_hints(m_connection, win, m_opts.pos.x, m_opts.pos.y, m_opts.size.w, m_opts.size.h); } /** @@ -872,9 +874,6 @@ void bar::start() { // Notify all components that depend on the absolute bar position (such as the background manager). m_sig.emit(signals::ui::update_geometry{}); - // Reconfigure window position after mapping (required by Openbox) - reconfigure_pos(); - m_log.trace("bar: Draw empty bar"); m_renderer->begin(m_opts.inner_area()); m_renderer->end(); diff --git a/src/x11/icccm.cpp b/src/x11/icccm.cpp index a6e292ee..b4fffe39 100644 --- a/src/x11/icccm.cpp +++ b/src/x11/icccm.cpp @@ -38,6 +38,18 @@ namespace icccm_util { } return false; } + + void set_wm_size_hints(xcb_connection_t* c, xcb_window_t w, int x, int y, int width, int height) { + xcb_size_hints_t hints; + + xcb_icccm_size_hints_set_size(&hints, false, width, height); + xcb_icccm_size_hints_set_min_size(&hints, width, height); + xcb_icccm_size_hints_set_max_size(&hints, width, height); + xcb_icccm_size_hints_set_base_size(&hints, width, height); + xcb_icccm_size_hints_set_position(&hints, false, x, y); + + xcb_icccm_set_wm_size_hints(c, w, XCB_ATOM_WM_NORMAL_HINTS, &hints); + } } POLYBAR_NS_END