From 1476f078eeb6bfcce1e29c732fb621745f112a2a Mon Sep 17 00:00:00 2001 From: WhySoBad <49595640+WhySoBad@users.noreply.github.com> Date: Thu, 19 Dec 2024 00:25:24 +0100 Subject: [PATCH 1/2] fix: fix moveto dispatcher with re2 --- src/VirtualDeskManager.cpp | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/src/VirtualDeskManager.cpp b/src/VirtualDeskManager.cpp index ccef35b..4b1599a 100644 --- a/src/VirtualDeskManager.cpp +++ b/src/VirtualDeskManager.cpp @@ -1,4 +1,5 @@ #include "VirtualDeskManager.hpp" +#include "src/desktop/DesktopTypes.hpp" #include #include #include @@ -114,10 +115,17 @@ int VirtualDeskManager::moveToDesk(std::string& arg, int vdeskId) { auto vdesk = getOrCreateVdesk(vdeskId); - PHLWINDOW window = g_pCompositor->getWindowByRegex(arg); - if (!window) { - printLog(std::format("Window {} does not exist???", arg), eLogLevel::ERR); - return vdeskId; + // monitor of the target window + // if no arg is provided, it's the currently focussed monitor and otherwise + // it's the monitor of the window matched by the arg regex + PHLMONITORREF monitor = g_pCompositor->m_pLastMonitor; + if (arg != "") { + PHLWINDOW window = g_pCompositor->getWindowByRegex(arg); + if (!window) { + printLog(std::format("Window {} does not exist???", arg), eLogLevel::ERR); + return vdeskId; + } + monitor = window->m_pMonitor; } // take the first workspace wherever in the layout @@ -125,7 +133,7 @@ int VirtualDeskManager::moveToDesk(std::string& arg, int vdeskId) { // of the window auto wid = vdesk->activeLayout(conf).begin()->second; for (auto const& [mon, workspace] : vdesk->activeLayout(conf)) { - if (mon == window->m_pMonitor) { + if (mon == monitor) { wid = workspace; } } From b6b944cfb0ac9da173d8747a9aecb4204f0ac612 Mon Sep 17 00:00:00 2001 From: WhySoBad <49595640+WhySoBad@users.noreply.github.com> Date: Thu, 19 Dec 2024 00:32:47 +0100 Subject: [PATCH 2/2] fix: move to default monitor if unmatched --- src/VirtualDeskManager.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/VirtualDeskManager.cpp b/src/VirtualDeskManager.cpp index 4b1599a..39b0408 100644 --- a/src/VirtualDeskManager.cpp +++ b/src/VirtualDeskManager.cpp @@ -1,5 +1,4 @@ #include "VirtualDeskManager.hpp" -#include "src/desktop/DesktopTypes.hpp" #include #include #include @@ -123,9 +122,9 @@ int VirtualDeskManager::moveToDesk(std::string& arg, int vdeskId) { PHLWINDOW window = g_pCompositor->getWindowByRegex(arg); if (!window) { printLog(std::format("Window {} does not exist???", arg), eLogLevel::ERR); - return vdeskId; + } else { + monitor = window->m_pMonitor; } - monitor = window->m_pMonitor; } // take the first workspace wherever in the layout