From 25f99c0a6173e96eeaa63d3fcb5ade9e1e1794d5 Mon Sep 17 00:00:00 2001 From: DrunkenChicken Date: Tue, 2 Apr 2019 00:04:44 +0800 Subject: [PATCH] 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 --- include/modules/xworkspaces.hpp | 1 + src/modules/xworkspaces.cpp | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/include/modules/xworkspaces.hpp b/include/modules/xworkspaces.hpp index 191f7f4e..cd6522e7 100644 --- a/include/modules/xworkspaces.hpp +++ b/include/modules/xworkspaces.hpp @@ -92,6 +92,7 @@ namespace modules { vector m_desktop_names; unsigned int m_current_desktop; + string m_current_desktop_name; vector m_clientlist; vector> m_viewports; diff --git a/src/modules/xworkspaces.cpp b/src/modules/xworkspaces.cpp index 22587a1f..da94264b 100644 --- a/src/modules/xworkspaces.cpp +++ b/src/modules/xworkspaces.cpp @@ -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;