From e57a2d7ec87ae775828ea8628ef4eeafce8e6e70 Mon Sep 17 00:00:00 2001 From: Maarten de Vries Date: Wed, 17 Apr 2024 13:04:16 +0200 Subject: keybindmgr: add optional `silent` suffix to `movewindow`. (#5597) With the `silent` suffix, the focus remains on the current position in the layout or the current monitor, instead of following the moved window. When combined with `movewindow mon:X`, this this allows you to get the same behavior as xmonad's `windowToScreen` command. --- src/layout/MasterLayout.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'src/layout/MasterLayout.cpp') diff --git a/src/layout/MasterLayout.cpp b/src/layout/MasterLayout.cpp index 0999303f..4ef68712 100644 --- a/src/layout/MasterLayout.cpp +++ b/src/layout/MasterLayout.cpp @@ -949,7 +949,7 @@ SWindowRenderLayoutHints CHyprMasterLayout::requestRenderHints(CWindow* pWindow) return hints; // master doesnt have any hints } -void CHyprMasterLayout::moveWindowTo(CWindow* pWindow, const std::string& dir) { +void CHyprMasterLayout::moveWindowTo(CWindow* pWindow, const std::string& dir, bool silent) { if (!isDirection(dir)) return; @@ -965,12 +965,16 @@ void CHyprMasterLayout::moveWindowTo(CWindow* pWindow, const std::string& dir) { onWindowRemovedTiling(pWindow); pWindow->moveToWorkspace(PWINDOW2->m_pWorkspace); pWindow->m_iMonitorID = PWINDOW2->m_iMonitorID; - const auto pMonitor = g_pCompositor->getMonitorFromID(pWindow->m_iMonitorID); - g_pCompositor->setActiveMonitor(pMonitor); + if (!silent) { + const auto pMonitor = g_pCompositor->getMonitorFromID(pWindow->m_iMonitorID); + g_pCompositor->setActiveMonitor(pMonitor); + } onWindowCreatedTiling(pWindow); } else { // if same monitor, switch windows switchWindows(pWindow, PWINDOW2); + if (silent) + g_pCompositor->focusWindow(PWINDOW2); } } -- cgit v1.2.3