fix(xworkspaces): active ws upon ws deletion (#1713)

Active desktop was tracked via it's index, but when desktops are removed from `_NET_DESKTOP_NAMES` that index may become invalid.

Fixes #1710
This commit is contained in:
DrunkenChicken 2019-04-02 00:04:44 +08:00 committed by Patrick Ziegler
parent 31a25af3d3
commit 25f99c0a61
2 changed files with 4 additions and 1 deletions

View File

@ -92,6 +92,7 @@ namespace modules {
vector<string> m_desktop_names;
unsigned int m_current_desktop;
string m_current_desktop_name;
vector<xcb_window_t> m_clientlist;
vector<unique_ptr<viewport>> m_viewports;

View File

@ -83,6 +83,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];
rebuild_desktops();
rebuild_desktop_states();
@ -103,6 +104,7 @@ namespace modules {
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];
rebuild_desktop_states();
} else if (evt->atom == WM_HINTS) {
if (icccm_util::get_wm_urgency(m_connection, evt->window)) {
@ -209,7 +211,7 @@ namespace modules {
void xworkspaces_module::rebuild_desktop_states() {
for (auto&& v : m_viewports) {
for (auto&& d : v->desktops) {
if (d->index == m_current_desktop) {
if (m_desktop_names[d->index] == m_current_desktop_name) {
d->state = desktop_state::ACTIVE;
} else {
d->state = desktop_state::EMPTY;