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: [PATCH] added swapnext --- src/managers/KeybindManager.cpp | 20 ++++++++++++++++++++ src/managers/KeybindManager.hpp | 1 + 2 files changed, 21 insertions(+) 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); +} diff --git a/src/managers/KeybindManager.hpp b/src/managers/KeybindManager.hpp index 29ebc7a1..2462f7a3 100644 --- a/src/managers/KeybindManager.hpp +++ b/src/managers/KeybindManager.hpp @@ -107,6 +107,7 @@ private: static void layoutmsg(std::string); static void toggleOpaque(std::string); static void dpms(std::string); + static void swapnext(std::string); friend class CCompositor; friend class CInputManager;