mirror of
https://github.com/polybar/polybar.git
synced 2026-02-05 22:35:40 +00:00
fix(xworkspaces): Segfault for wrong _NET_CURRENT_DESKTOP
While it shouldn't happen with compliant WMs, it was possibe to crash polybar with _NET_CURRENT_DESKTOP >= _NET_NUMBER_OF_DESKTOPS and this should not be possible. Includes polybar/xpp#31 Fixes #2398
This commit is contained in:
committed by
Patrick Ziegler
parent
c197cff511
commit
2fd6d20999
@ -71,6 +71,7 @@ namespace modules {
|
||||
void rebuild_urgent_hints();
|
||||
void rebuild_desktops();
|
||||
void rebuild_desktop_states();
|
||||
void update_current_desktop();
|
||||
|
||||
void action_focus(const string& data);
|
||||
void action_next();
|
||||
|
||||
2
lib/xpp
2
lib/xpp
Submodule lib/xpp updated: 4d67025cdb...7a9960bbb9
@ -95,8 +95,7 @@ namespace modules {
|
||||
|
||||
// Get desktop details
|
||||
m_desktop_names = get_desktop_names();
|
||||
m_current_desktop = ewmh_util::get_current_desktop();
|
||||
m_current_desktop_name = m_desktop_names[m_current_desktop];
|
||||
update_current_desktop();
|
||||
|
||||
rebuild_desktops();
|
||||
|
||||
@ -105,6 +104,15 @@ namespace modules {
|
||||
rebuild_desktop_states();
|
||||
}
|
||||
|
||||
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");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Handler for XCB_PROPERTY_NOTIFY events
|
||||
*/
|
||||
@ -120,8 +128,7 @@ namespace modules {
|
||||
rebuild_clientlist();
|
||||
rebuild_desktop_states();
|
||||
} else if (evt->atom == m_ewmh->_NET_CURRENT_DESKTOP) {
|
||||
m_current_desktop = ewmh_util::get_current_desktop();
|
||||
m_current_desktop_name = m_desktop_names[m_current_desktop];
|
||||
update_current_desktop();
|
||||
rebuild_desktop_states();
|
||||
} else if (evt->atom == WM_HINTS) {
|
||||
rebuild_urgent_hints();
|
||||
|
||||
Reference in New Issue
Block a user