From 2e5b146e57364795aabeb2dea6fd2257db8b2c3a Mon Sep 17 00:00:00 2001 From: Vaxry Date: Tue, 2 Apr 2024 12:10:03 +0100 Subject: workspace: remove lastFocusedWindow on unmap --- src/desktop/Workspace.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'src/desktop/Workspace.cpp') diff --git a/src/desktop/Workspace.cpp b/src/desktop/Workspace.cpp index a0c14bba..9200b4d7 100644 --- a/src/desktop/Workspace.cpp +++ b/src/desktop/Workspace.cpp @@ -30,6 +30,13 @@ CWorkspace::CWorkspace(int id, int monitorID, std::string name, bool special) { m_szName = rule.defaultName.value(); } + m_pFocusedWindowHook = g_pHookSystem->hookDynamic("closeWindow", [this](void* self, SCallbackInfo& info, std::any param) { + const auto PWINDOW = std::any_cast(param); + + if (PWINDOW == m_pLastFocusedWindow) + m_pLastFocusedWindow = nullptr; + }); + g_pEventManager->postEvent({"createworkspace", m_szName}); g_pEventManager->postEvent({"createworkspacev2", std::format("{},{}", m_iID, m_szName)}); EMIT_HOOK_EVENT("createWorkspace", this); @@ -40,6 +47,8 @@ CWorkspace::~CWorkspace() { Debug::log(LOG, "Destroying workspace ID {}", m_iID); + g_pHookSystem->unhook(m_pFocusedWindowHook); + g_pEventManager->postEvent({"destroyworkspace", m_szName}); g_pEventManager->postEvent({"destroyworkspacev2", std::format("{},{}", m_iID, m_szName)}); EMIT_HOOK_EVENT("destroyWorkspace", this); -- cgit v1.2.3