From 894a9b0e3e359347172acc4f035a79f3ea4e16da Mon Sep 17 00:00:00 2001 From: vaxerski <43317083+vaxerski@users.noreply.github.com> Date: Sun, 3 Apr 2022 12:57:08 +0200 Subject: [PATCH] Added fullscreen and workspace rules --- src/config/ConfigManager.cpp | 2 ++ src/events/events.cpp | 46 ++++++++++++++++++++++++++++++++++++ 2 files changed, 48 insertions(+) diff --git a/src/config/ConfigManager.cpp b/src/config/ConfigManager.cpp index 52c8491..afafe70 100644 --- a/src/config/ConfigManager.cpp +++ b/src/config/ConfigManager.cpp @@ -242,6 +242,8 @@ void handleWindowRule(const std::string& command, const std::string& value) { && RULE.find("size") != 0 && RULE.find("nointerventions") != 0 && RULE.find("pseudo") != 0 + && RULE.find("fullscreen") != 0 + && RULE.find("workspace") != 0 && RULE.find("monitor") != 0) { Debug::log(ERR, "Invalid rule found: " + RULE); ConfigManager::parseError = "Invalid rule found: " + RULE; diff --git a/src/events/events.cpp b/src/events/events.cpp index f1480cb..028c7f1 100644 --- a/src/events/events.cpp +++ b/src/events/events.cpp @@ -217,6 +217,23 @@ CWindow* Events::remapFloatingWindow(int windowID, int forcemonitor) { if (rule.szRule.find("pseudo") == 0) { PWINDOWINARR->setIsPseudotiled(true); } + + if (rule.szRule.find("fullscreen") == 0) { + PWINDOWINARR->setFullscreen(true); + } + + if (rule.szRule.find("workspace") == 0) { + try { + const auto WORKSPACE = stoi(rule.szRule.substr(rule.szRule.find(" ") + 1)); + + Debug::log(LOG, "Rule workspace, applying to window " + std::to_string(windowID)); + + g_pWindowManager->changeWorkspaceByID(WORKSPACE); + forcemonitor = g_pWindowManager->getWorkspaceByID(WORKSPACE)->getMonitor(); + } catch (...) { + Debug::log(LOG, "Rule workspace failed, rule: " + rule.szRule + "=" + rule.szValue); + } + } } const auto CURRENTSCREEN = forcemonitor != -1 ? forcemonitor : PMONITOR->ID; @@ -399,6 +416,12 @@ CWindow* Events::remapFloatingWindow(int windowID, int forcemonitor) { PWINDOWINARR->setConstructed(true); PWINDOWINARR->setFirstOpen(false); + // Fullscreen rule + if (PWINDOWINARR->getFullscreen()) { + PWINDOWINARR->setFullscreen(false); + g_pWindowManager->toggleWindowFullscrenn(PWINDOWINARR->getDrawable()); + } + return PWINDOWINARR; } @@ -448,6 +471,23 @@ CWindow* Events::remapWindow(int windowID, bool wasfloating, int forcemonitor) { if (rule.szRule.find("pseudo") == 0) { PWINDOWINARR->setIsPseudotiled(true); } + + if (rule.szRule.find("fullscreen") == 0) { + PWINDOWINARR->setFullscreen(true); + } + + if (rule.szRule.find("workspace") == 0) { + try { + const auto WORKSPACE = stoi(rule.szRule.substr(rule.szRule.find(" ") + 1)); + + Debug::log(LOG, "Rule workspace, applying to window " + std::to_string(windowID)); + + g_pWindowManager->changeWorkspaceByID(WORKSPACE); + forcemonitor = g_pWindowManager->getWorkspaceByID(WORKSPACE)->getMonitor(); + } catch (...) { + Debug::log(LOG, "Rule workspace failed, rule: " + rule.szRule + "=" + rule.szValue); + } + } } if (g_pWindowManager->getWindowFromDrawable(g_pWindowManager->LastWindow) && forcemonitor == -1 && PMONITOR->ID != g_pWindowManager->getWindowFromDrawable(g_pWindowManager->LastWindow)->getMonitor()) { @@ -579,6 +619,12 @@ CWindow* Events::remapWindow(int windowID, bool wasfloating, int forcemonitor) { PWINDOWINARR->setConstructed(true); PWINDOWINARR->setFirstOpen(false); + // Fullscreen rule + if (PWINDOWINARR->getFullscreen()) { + PWINDOWINARR->setFullscreen(false); + g_pWindowManager->toggleWindowFullscrenn(PWINDOWINARR->getDrawable()); + } + return PWINDOWINARR; }