From 9c3aeda9f987cf08886026c8f8b487c2f70f134b Mon Sep 17 00:00:00 2001 From: vaxerski <43317083+vaxerski@users.noreply.github.com> Date: Wed, 24 Aug 2022 21:40:36 +0200 Subject: added swapnext --- src/managers/KeybindManager.cpp | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'src/managers/KeybindManager.cpp') diff --git a/src/managers/KeybindManager.cpp b/src/managers/KeybindManager.cpp index b1b51dd7..75660304 100644 --- a/src/managers/KeybindManager.cpp +++ b/src/managers/KeybindManager.cpp @@ -39,6 +39,7 @@ CKeybindManager::CKeybindManager() { m_mDispatchers["dpms"] = dpms; m_mDispatchers["movewindowpixel"] = moveWindow; m_mDispatchers["resizewindowpixel"] = resizeWindow; + m_mDispatchers["swapnext"] = swapNext; m_tScrollTimer.reset(); } @@ -1437,3 +1438,22 @@ void CKeybindManager::dpms(std::string arg) { g_pCompositor->m_bDPMSStateON = enable; } + +void CKeybindManager::swapnext(std::string arg) { + + CWindow* toSwap = nullptr; + + if (!g_pCompositor->windowValidMapped(g_pCompositor->m_pLastWindow)) + return; + + const auto PLASTWINDOW = g_pCompositor->m_pLastWindow; + + if (arg == "last" || arg == "l" || arg == "prev" || arg == "p") + toSwap = g_pCompositor->getPrevWindowOnWorkspace(PLASTWINDOW); + else + toSwap = g_pCompositor->getNextWindowOnWorkspace(PLASTWINDOW); + + g_pLayoutManager->getCurrentLayout()->switchWindows(PLASTWINDOW, toSwap); + + g_pCompositor->focusWindow(PLASTWINDOW); +} -- cgit v1.2.3 From 00ef40dda19c369626da487c00cfa87da0e3b185 Mon Sep 17 00:00:00 2001 From: vaxerski <43317083+vaxerski@users.noreply.github.com> Date: Wed, 24 Aug 2022 21:50:48 +0200 Subject: added swapnext and swapprev for master --- src/managers/KeybindManager.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/managers/KeybindManager.cpp') diff --git a/src/managers/KeybindManager.cpp b/src/managers/KeybindManager.cpp index 75660304..a4ddd809 100644 --- a/src/managers/KeybindManager.cpp +++ b/src/managers/KeybindManager.cpp @@ -39,7 +39,7 @@ CKeybindManager::CKeybindManager() { m_mDispatchers["dpms"] = dpms; m_mDispatchers["movewindowpixel"] = moveWindow; m_mDispatchers["resizewindowpixel"] = resizeWindow; - m_mDispatchers["swapnext"] = swapNext; + m_mDispatchers["swapnext"] = swapnext; m_tScrollTimer.reset(); } -- cgit v1.2.3 From 6c2175ed525cbdc4bb263afbbcbf464ed091f4cd Mon Sep 17 00:00:00 2001 From: vaxerski <43317083+vaxerski@users.noreply.github.com> Date: Wed, 24 Aug 2022 22:01:25 +0200 Subject: fixes to swapnext logic on dwindle --- src/managers/KeybindManager.cpp | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'src/managers/KeybindManager.cpp') diff --git a/src/managers/KeybindManager.cpp b/src/managers/KeybindManager.cpp index a4ddd809..e3799a7c 100644 --- a/src/managers/KeybindManager.cpp +++ b/src/managers/KeybindManager.cpp @@ -1448,12 +1448,24 @@ void CKeybindManager::swapnext(std::string arg) { const auto PLASTWINDOW = g_pCompositor->m_pLastWindow; + const auto PLASTCYCLED = g_pCompositor->windowValidMapped(g_pCompositor->m_pLastWindow->m_pLastCycledWindow) && g_pCompositor->m_pLastWindow->m_pLastCycledWindow->m_iWorkspaceID == PLASTWINDOW->m_iWorkspaceID ? g_pCompositor->m_pLastWindow->m_pLastCycledWindow : nullptr; + if (arg == "last" || arg == "l" || arg == "prev" || arg == "p") - toSwap = g_pCompositor->getPrevWindowOnWorkspace(PLASTWINDOW); + toSwap = g_pCompositor->getPrevWindowOnWorkspace(PLASTCYCLED ? PLASTCYCLED : PLASTWINDOW); else - toSwap = g_pCompositor->getNextWindowOnWorkspace(PLASTWINDOW); + toSwap = g_pCompositor->getNextWindowOnWorkspace(PLASTCYCLED ? PLASTCYCLED : PLASTWINDOW); + + // sometimes we may come back to ourselves. + if (toSwap == PLASTWINDOW) { + if (arg == "last" || arg == "l" || arg == "prev" || arg == "p") + toSwap = g_pCompositor->getPrevWindowOnWorkspace(PLASTWINDOW); + else + toSwap = g_pCompositor->getNextWindowOnWorkspace(PLASTWINDOW); + } g_pLayoutManager->getCurrentLayout()->switchWindows(PLASTWINDOW, toSwap); + PLASTWINDOW->m_pLastCycledWindow = toSwap; + g_pCompositor->focusWindow(PLASTWINDOW); } -- cgit v1.2.3