diff --git a/include/modules/xworkspaces.hpp b/include/modules/xworkspaces.hpp index f98d6465..17578502 100644 --- a/include/modules/xworkspaces.hpp +++ b/include/modules/xworkspaces.hpp @@ -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(); diff --git a/lib/xpp b/lib/xpp index 4d67025c..7a9960bb 160000 --- a/lib/xpp +++ b/lib/xpp @@ -1 +1 @@ -Subproject commit 4d67025cdbcc7f3c65d1a620c97a8443e0a08129 +Subproject commit 7a9960bbb912f0ed66929c978aaeb1c30acf4bfd diff --git a/src/modules/xworkspaces.cpp b/src/modules/xworkspaces.cpp index 2e78b371..e6c3cee4 100644 --- a/src/modules/xworkspaces.cpp +++ b/src/modules/xworkspaces.cpp @@ -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();