diff options
author | Vaxry <[email protected]> | 2024-04-02 12:10:03 +0100 |
---|---|---|
committer | Vaxry <[email protected]> | 2024-04-02 12:10:03 +0100 |
commit | 2e5b146e57364795aabeb2dea6fd2257db8b2c3a (patch) | |
tree | 0b72dc9174b2f7c9c923780bd7f48e5c10baa570 | |
parent | af3a61a4e437fe728ef69c2739cae79e5a6254c0 (diff) | |
download | Hyprland-2e5b146e57364795aabeb2dea6fd2257db8b2c3a.tar.gz Hyprland-2e5b146e57364795aabeb2dea6fd2257db8b2c3a.zip |
workspace: remove lastFocusedWindow on unmap
-rw-r--r-- | src/desktop/Workspace.cpp | 9 | ||||
-rw-r--r-- | src/desktop/Workspace.hpp | 3 |
2 files changed, 12 insertions, 0 deletions
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<CWindow*>(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); diff --git a/src/desktop/Workspace.hpp b/src/desktop/Workspace.hpp index f1bdb333..0cae1859 100644 --- a/src/desktop/Workspace.hpp +++ b/src/desktop/Workspace.hpp @@ -66,4 +66,7 @@ class CWorkspace { std::string getConfigName(); bool matchesStaticSelector(const std::string& selector); + + private: + HOOK_CALLBACK_FN* m_pFocusedWindowHook = nullptr; }; |