From 6b1ac659e005042a6970ffc489aef71e0875af15 Mon Sep 17 00:00:00 2001 From: memchr <118117622+memchr@users.noreply.github.com> Date: Wed, 13 Sep 2023 10:13:29 +0000 Subject: layout: add direction parameter to onWindowCreated and friends (#3269) * feat(layout): add direction parameter to onWindowCreated and friends In addition: - Implement directional moveWindowOutOfGroup for `movewindoworgroup` when using dwindle layout. (augmentation of #3006) - Replace `DWindleLayout::OneTimeFocus` with `IHyprLayout::eDirection`. - Slight formatting change (clang-format). * fix: nullptr dereference in dwindle window creation * refactor: generalized eDirection * refactor: eliminate DIRECTION_NONE * Update IHyprLayout.hpp --- src/managers/KeybindManager.cpp | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) (limited to 'src/managers/KeybindManager.cpp') diff --git a/src/managers/KeybindManager.cpp b/src/managers/KeybindManager.cpp index c2a7b6c0..b86a2844 100644 --- a/src/managers/KeybindManager.cpp +++ b/src/managers/KeybindManager.cpp @@ -1963,9 +1963,20 @@ void CKeybindManager::moveWindowIntoGroup(CWindow* pWindow, CWindow* pWindowInDi g_pCompositor->warpCursorTo(pWindow->middle()); } -void CKeybindManager::moveWindowOutOfGroup(CWindow* pWindow) { - static auto* const BFOCUSREMOVEDWINDOW = &g_pConfigManager->getConfigValuePtr("misc:group_focus_removed_window")->intValue; - const auto PWINDOWPREV = pWindow->getGroupPrevious(); +void CKeybindManager::moveWindowOutOfGroup(CWindow* pWindow, const std::string& dir) { + static auto* const BFOCUSREMOVEDWINDOW = &g_pConfigManager->getConfigValuePtr("misc:group_focus_removed_window")->intValue; + const auto PWINDOWPREV = pWindow->getGroupPrevious(); + eDirection direction; + + switch (dir[0]) { + case 't': + case 'u': direction = DIRECTION_UP; break; + case 'd': + case 'b': direction = DIRECTION_DOWN; break; + case 'l': direction = DIRECTION_LEFT; break; + case 'r': direction = DIRECTION_RIGHT; break; + default: direction = DIRECTION_DEFAULT; + } g_pLayoutManager->getCurrentLayout()->onWindowRemoved(pWindow); @@ -1973,7 +1984,7 @@ void CKeybindManager::moveWindowOutOfGroup(CWindow* pWindow) { g_pKeybindManager->m_bGroupsLocked = true; - g_pLayoutManager->getCurrentLayout()->onWindowCreated(pWindow); + g_pLayoutManager->getCurrentLayout()->onWindowCreated(pWindow, direction); g_pKeybindManager->m_bGroupsLocked = GROUPSLOCKEDPREV; @@ -2059,13 +2070,13 @@ void CKeybindManager::moveWindowOrGroup(std::string args) { moveWindowIntoGroup(PWINDOW, PWINDOWINDIR); } else if (PWINDOWINDIR) { if (ISWINDOWGROUP && (*BIGNOREGROUPLOCK || !ISWINDOWGROUPLOCKED)) - moveWindowOutOfGroup(PWINDOW); + moveWindowOutOfGroup(PWINDOW, args); else { g_pLayoutManager->getCurrentLayout()->moveWindowTo(PWINDOW, args); g_pCompositor->warpCursorTo(PWINDOW->middle()); } } else if (ISWINDOWGROUP && (*BIGNOREGROUPLOCK || !ISWINDOWGROUPLOCKED)) { - moveWindowOutOfGroup(PWINDOW); + moveWindowOutOfGroup(PWINDOW, args); } } -- cgit v1.2.3