diff options
| author | memchr <118117622+memchr@users.noreply.github.com> | 2023-09-13 10:13:29 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-09-13 11:13:29 +0100 |
| commit | 6b1ac659e005042a6970ffc489aef71e0875af15 (patch) | |
| tree | ce0e73429f76dcd884d27cafdadfda51b925b57f /src/managers/KeybindManager.cpp | |
| parent | b0d5e4008b96f2cdbb6f6c2449c790d921d1546b (diff) | |
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
Diffstat (limited to 'src/managers/KeybindManager.cpp')
| -rw-r--r-- | src/managers/KeybindManager.cpp | 23 |
1 files changed, 17 insertions, 6 deletions
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); } } |
