summaryrefslogtreecommitdiff
path: root/src/managers/KeybindManager.cpp
diff options
context:
space:
mode:
authorNotAShelf <itsashelf@gmail.com>2022-08-24 23:05:22 +0300
committerGitHub <noreply@github.com>2022-08-24 23:05:22 +0300
commita9761cb1c8bd7c120549f897ee19e86684102246 (patch)
treea9d8c841d202ee85b7742542f75241e3e13b81a6 /src/managers/KeybindManager.cpp
parenta4f7bd4bc2139c2e6ac51443675e3fc7f9bde606 (diff)
parent6c2175ed525cbdc4bb263afbbcbf464ed091f4cd (diff)
Merge branch 'hyprwm:main' into main
Diffstat (limited to 'src/managers/KeybindManager.cpp')
-rw-r--r--src/managers/KeybindManager.cpp32
1 files changed, 32 insertions, 0 deletions
diff --git a/src/managers/KeybindManager.cpp b/src/managers/KeybindManager.cpp
index b1b51dd7..e3799a7c 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,34 @@ 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;
+
+ 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(PLASTCYCLED ? PLASTCYCLED : PLASTWINDOW);
+ else
+ 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);
+}