From 8173eaf90ad5038dd952c631e632c8562ff05e37 Mon Sep 17 00:00:00 2001 From: patrick96 Date: Tue, 15 Mar 2022 21:48:19 +0100 Subject: [PATCH] fix: Positioning in awesomeWM Since polybar sets WM_NORMAL_HINTS, awesomeWM for some reason no longer respect the position set by polybar before mapping. reconfiguring the window position once again after mapping the window, again positions it correctly. --- CHANGELOG.md | 4 ++-- include/components/bar.hpp | 2 ++ src/components/bar.cpp | 31 +++++++++++++++++++++---------- src/x11/icccm.cpp | 7 ++++--- 4 files changed, 29 insertions(+), 15 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5a402df5..a8d03049 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed - `format-offset` being ignored ([`#2643`](https://github.com/polybar/polybar/pull/2643)) - Negative struts (`margin-bottom`, `margin-top`) being ignored ([`#2642`](https://github.com/polybar/polybar/issues/2642), [`#2644`](https://github.com/polybar/polybar/pull/2644)) +- Positioning in awesomeWM ([`#2651`](https://github.com/polybar/polybar/pull/2651)) ## [3.6.1] - 2022-03-05 ### Build @@ -166,8 +167,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed - Empty color values are no longer treated as invalid and no longer produce an error. -[Unreleased]: https://github.com/polybar/polybar/compare/3.6.1...HEAD -[3.6.1]: https://github.com/polybar/polybar/releases/tag/3.6.1 +[Unreleased]: https://github.com/polybar/polybar/compare/3.6.0...HEAD [3.6.0]: https://github.com/polybar/polybar/releases/tag/3.6.0 [3.5.7]: https://github.com/polybar/polybar/releases/tag/3.5.7 [3.5.6]: https://github.com/polybar/polybar/releases/tag/3.5.6 diff --git a/include/components/bar.hpp b/include/components/bar.hpp index e16f9563..384bb8c3 100644 --- a/include/components/bar.hpp +++ b/include/components/bar.hpp @@ -65,6 +65,8 @@ class bar : public xpp::event::sinkhas_action(btn, pos); @@ -883,10 +896,8 @@ void bar::start() { m_connection.ensure_event_mask(m_opts.window, XCB_EVENT_MASK_STRUCTURE_NOTIFY); m_log.info("Bar window: %s", m_connection.id(m_opts.window)); - reconfigure_window(); - m_log.trace("bar: Map window"); - m_connection.map_window_checked(m_opts.window); + map_window(); // With the mapping, the absolute position of our window may have changed (due to re-parenting for example). // Notify all components that depend on the absolute bar position (such as the background manager). diff --git a/src/x11/icccm.cpp b/src/x11/icccm.cpp index b4fffe39..db0894f9 100644 --- a/src/x11/icccm.cpp +++ b/src/x11/icccm.cpp @@ -1,4 +1,5 @@ #include "x11/icccm.hpp" + #include "x11/atoms.hpp" POLYBAR_NS @@ -33,14 +34,14 @@ namespace icccm_util { bool get_wm_urgency(xcb_connection_t* c, xcb_window_t w) { xcb_icccm_wm_hints_t hints; if (xcb_icccm_get_wm_hints_reply(c, xcb_icccm_get_wm_hints(c, w), &hints, NULL)) { - if(xcb_icccm_wm_hints_get_urgency(&hints) == XCB_ICCCM_WM_HINT_X_URGENCY) + if (xcb_icccm_wm_hints_get_urgency(&hints) == XCB_ICCCM_WM_HINT_X_URGENCY) return true; } 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_size_hints_t hints{}; xcb_icccm_size_hints_set_size(&hints, false, width, height); xcb_icccm_size_hints_set_min_size(&hints, width, height); @@ -50,6 +51,6 @@ namespace icccm_util { xcb_icccm_set_wm_size_hints(c, w, XCB_ATOM_WM_NORMAL_HINTS, &hints); } -} +} // namespace icccm_util POLYBAR_NS_END