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 <tim@timakro.de>
Co-authored-by: patrick96 <p.ziegler96@gmail.com>
This commit is contained in:
Tim Schumacher 2021-10-11 14:40:14 +02:00 committed by GitHub
parent 231af35354
commit 281fdf6382
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 7 additions and 24 deletions

View File

@ -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
- `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

View File

@ -86,12 +86,10 @@ namespace modules {
ewmh_connection_t m_ewmh;
vector<monitor_t> m_monitors;
bool m_monitorsupport{true};
vector<string> m_desktop_names;
vector<bool> m_urgent_desktops;
unsigned int m_current_desktop;
string m_current_desktop_name;
/**
* Maps an xcb window to its desktop number

View File

@ -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<position> ws_positions;
if (m_monitorsupport) {
ws_positions = ewmh_util::get_desktop_viewports();
}
vector<position> ws_positions = ewmh_util::get_desktop_viewports();
/*
* Not all desktops were assigned a viewport, add (0, 0) for all missing