From 281fdf638255c9a52256817a4ad76fb6424d00c9 Mon Sep 17 00:00:00 2001 From: Tim Schumacher Date: Mon, 11 Oct 2021 14:40:14 +0200 Subject: [PATCH] The xworkspaces module should wait for EWMH to become available (#2429) * The xworkspaces module should wait for EWMH to become available Before this change if EWMH wasn't available the xworkspaces module was permanently disabled. When polybar was started alongside the window manager e.g. from .xinitrc this caused a race condition between polybar and the window manager and the xworkspaces module may or may not be displayed. After this change polybar will wait for EWMH to become available. This change closes #1915, see that issue for more details. Curiously this only required the removal of the error condition which used the be raised when EWMH wasn't available. The xworkspaces module will show up on the bar as soon as the first EWMH event is processed by the existing event handling code. I can't argue much about the correctness of this patch but it seems to work flawlessly in my testing with xmonad. I didn't test any other window managers. Note that removing the error condition below which checks that _NET_DESKTOP_VIEWPORT is available might make this work with pin-workspaces=true. I couldn't test the effects of that change because I only tested with xmonad and xmonad doesn't support _NET_DESKTOP_VIEWPORT, so I didn't make that change. * xworkspaces: Remove check fo _NET_DESKTOP_VIEWPORT Implementations that don't support it will just return an empty list for get_desktop_viewports and pin-workspaces won't do anything. * Update changelog Fixes #1915 Co-authored-by: Tim Schumacher Co-authored-by: patrick96 --- CHANGELOG.md | 9 ++++++--- include/modules/xworkspaces.hpp | 2 -- src/modules/xworkspaces.cpp | 20 +------------------- 3 files changed, 7 insertions(+), 24 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 47f88c97..64802916 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -161,7 +161,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Increased the double click interval from 150ms to 400ms. - Stop ignoring actions if they arrive while the previous one hasn't been processed yet. ([`#2469`](https://github.com/polybar/polybar/issues/2469)) -- Polybar can now be run without passing the bar name as argument given that +- Polybar can now be run without passing the bar name as argument given that the configuration file only defines one bar ([`#2525`](https://github.com/polybar/polybar/issues/2525)) @@ -182,8 +182,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ([`#2371`](https://github.com/polybar/polybar/issues/2371)) - `polybar -m` used to show both physical outputs and randr monitors, even if the outputs were covered by monitors. ([`#2481`](https://github.com/polybar/polybar/issues/2481)) -- `internal/xworkspaces`: Broken scroll-wrapping and order of workspaces when scrolling - ([`#2491`](https://github.com/polybar/polybar/issues/2491)) +- `internal/xworkspaces`: + - Broken scroll-wrapping and order of workspaces when scrolling + ([`#2491`](https://github.com/polybar/polybar/issues/2491)) + - Module would error if WM was not full started up. + ([`#1915`](https://github.com/polybar/polybar/issues/1915)) ## [3.5.7] - 2021-09-21 ### Fixed diff --git a/include/modules/xworkspaces.hpp b/include/modules/xworkspaces.hpp index 58268360..72da2b62 100644 --- a/include/modules/xworkspaces.hpp +++ b/include/modules/xworkspaces.hpp @@ -86,12 +86,10 @@ namespace modules { ewmh_connection_t m_ewmh; vector m_monitors; - bool m_monitorsupport{true}; vector m_desktop_names; vector m_urgent_desktops; unsigned int m_current_desktop; - string m_current_desktop_name; /** * Maps an xcb window to its desktop number diff --git a/src/modules/xworkspaces.cpp b/src/modules/xworkspaces.cpp index b2acc2ea..e2bfd695 100644 --- a/src/modules/xworkspaces.cpp +++ b/src/modules/xworkspaces.cpp @@ -50,16 +50,6 @@ namespace modules { throw module_error("Failed to initialize ewmh atoms"); } - // Check if the WM supports _NET_CURRENT_DESKTOP - if (!ewmh_util::supports(m_ewmh->_NET_CURRENT_DESKTOP)) { - throw module_error("The WM does not support _NET_CURRENT_DESKTOP, aborting..."); - } - - // Check if the WM supports _NET_DESKTOP_VIEWPORT - if (!(m_monitorsupport = ewmh_util::supports(m_ewmh->_NET_DESKTOP_VIEWPORT)) && m_pinworkspaces) { - throw module_error("The WM does not support _NET_DESKTOP_VIEWPORT (required when `pin-workspaces = true`)"); - } - // Add formats and elements m_formatter->add(DEFAULT_FORMAT, TAG_LABEL_STATE, {TAG_LABEL_STATE, TAG_LABEL_MONITOR}); @@ -106,11 +96,6 @@ namespace modules { void xworkspaces_module::update_current_desktop() { m_current_desktop = ewmh_util::get_current_desktop(); - if (m_current_desktop < m_desktop_names.size()) { - m_current_desktop_name = m_desktop_names[m_current_desktop]; - } else { - throw module_error("The current desktop is outside of the number of desktops reported by the WM"); - } } /** @@ -204,10 +189,7 @@ namespace modules { * We use this to map workspaces to viewports, desktop i is at position * ws_positions[i]. */ - vector ws_positions; - if (m_monitorsupport) { - ws_positions = ewmh_util::get_desktop_viewports(); - } + vector ws_positions = ewmh_util::get_desktop_viewports(); /* * Not all desktops were assigned a viewport, add (0, 0) for all missing