xworkspaces: Deal with disappearing windows

Because the X server is asynchronous, there is no guarantee that after
reading _NET_CLIENT_LIST, all windows still exist.
For that reason we need to handle XCB_WINDOW errors appropriately.
This commit is contained in:
patrick96 2022-03-20 14:27:05 +01:00 committed by Patrick Ziegler
parent 8173eaf90a
commit b05b3a4c74
2 changed files with 13 additions and 2 deletions

View File

@ -13,6 +13,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- `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))
- `internal/xworkspaces`: The module sometimes crashed polybar when windows were closed. ([`#2655`](https://github.com/polybar/polybar/pull/2655))
## [3.6.1] - 2022-03-05
### Build

View File

@ -138,8 +138,18 @@ namespace modules {
for (auto&& client : newclients) {
if (m_clients.count(client) == 0) {
// new client: listen for changes (wm_hint or desktop)
m_connection.ensure_event_mask(client, XCB_EVENT_MASK_PROPERTY_CHANGE);
try {
// new client: listen for changes (wm_hint or desktop)
m_connection.ensure_event_mask(client, XCB_EVENT_MASK_PROPERTY_CHANGE);
} catch (const xpp::x::error::window& e) {
/*
* The "new client" may have already disappeared between reading the
* client list and setting the event mask.
* This is not a severe issue and it will eventually correct itself
* when a new _NET_CLIENT_LIST value is set.
*/
m_log.info("%s: New client window no longer exists, ignoring...");
}
}
}