From 2b8b34d8db2b2db0054db34ba8791139d38d7c8f Mon Sep 17 00:00:00 2001 From: vaxerski <43317083+vaxerski@users.noreply.github.com> Date: Thu, 21 Apr 2022 17:17:47 +0200 Subject: [PATCH] Added workspace windowrule --- src/config/ConfigManager.cpp | 3 ++- src/events/Windows.cpp | 14 +++++++++++--- src/managers/KeybindManager.cpp | 2 +- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/src/config/ConfigManager.cpp b/src/config/ConfigManager.cpp index e80b545d..96e8eadd 100644 --- a/src/config/ConfigManager.cpp +++ b/src/config/ConfigManager.cpp @@ -241,7 +241,8 @@ void CConfigManager::handleWindowRule(const std::string& command, const std::str && RULE.find("move") != 0 && RULE.find("size") != 0 && RULE.find("pseudo") != 0 - && RULE.find("monitor") != 0) { + && RULE.find("monitor") != 0 + && RULE.find("workspace") != 0) { Debug::log(ERR, "Invalid rule found: %s", RULE.c_str()); parseError = "Invalid rule found: " + RULE; return; diff --git a/src/events/Windows.cpp b/src/events/Windows.cpp index 77ec29cd..d62ea926 100644 --- a/src/events/Windows.cpp +++ b/src/events/Windows.cpp @@ -68,10 +68,18 @@ void Events::listener_mapWindow(void* owner, void* data) { PWINDOW->m_iWorkspaceID = g_pCompositor->getMonitorFromID(PWINDOW->m_iMonitorID)->activeWorkspace; - Debug::log(LOG, "Rule monitor, applying to window %x -> mon: %i, workspace: %i", PWINDOW, PWINDOW->m_iMonitorID, PWINDOW->m_iWorkspaceID); - } catch (...) { - Debug::log(LOG, "Rule monitor failed, rule: %s -> %s", r.szRule.c_str(), r.szValue.c_str()); + Debug::log(ERR, "Rule monitor, applying to window %x -> mon: %i, workspace: %i", PWINDOW, PWINDOW->m_iMonitorID, PWINDOW->m_iWorkspaceID); + } catch (std::exception& e) { + Debug::log(ERR, "Rule monitor failed, rule: %s -> %s | err: %s", r.szRule.c_str(), r.szValue.c_str(), e.what()); } + } else if (r.szRule.find("workspace") == 0) { + // switch to workspace + g_pKeybindManager->m_mDispatchers["workspace"](r.szRule.substr(r.szRule.find_first_of(' ') + 1)); + + PWINDOW->m_iMonitorID = g_pCompositor->m_pLastMonitor->ID; + PWINDOW->m_iWorkspaceID = g_pCompositor->m_pLastMonitor->activeWorkspace; + + Debug::log(LOG, "Rule workspace matched by window %x, %s applied.", PWINDOW, r.szValue.c_str()); } else if (r.szRule.find("float") == 0) { PWINDOW->m_bIsFloating = true; } else if (r.szRule.find("tile") == 0) { diff --git a/src/managers/KeybindManager.cpp b/src/managers/KeybindManager.cpp index 06fdf5f4..b1554465 100644 --- a/src/managers/KeybindManager.cpp +++ b/src/managers/KeybindManager.cpp @@ -161,7 +161,7 @@ void CKeybindManager::toggleActivePseudo(std::string args) { g_pLayoutManager->getCurrentLayout()->recalculateWindow(ACTIVEWINDOW); } -void CKeybindManager::changeworkspace(std::string args) { +void CKeybindManager::gichangeworkspace(std::string args) { int workspaceToChangeTo = 0; std::string workspaceName = "";