summaryrefslogtreecommitdiff
path: root/src/managers/KeybindManager.cpp
diff options
context:
space:
mode:
authornormaltaro <30935678+normaltaro@users.noreply.github.com>2024-12-14 01:58:57 +0530
committerGitHub <noreply@github.com>2024-12-13 21:28:57 +0100
commit452a7e6905de61f076065ef4c294dc62f86327ae (patch)
treec326c34f0cd9f0d61a99615556556640e029a787 /src/managers/KeybindManager.cpp
parent61a51bb4ef5ff38a8482933da1756bf31d4475be (diff)
dispatchers: Add an option to prioritize focus change within groups with movefocus (#8601)
* modified movefocus dispatcher to prioritize focus change within groups * pass clang-format check * `movefocus` cycling groups set optional to config bool `movefocus_cycles_groupfirst` * Update ConfigDescriptions.hpp
Diffstat (limited to 'src/managers/KeybindManager.cpp')
-rw-r--r--src/managers/KeybindManager.cpp16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/managers/KeybindManager.cpp b/src/managers/KeybindManager.cpp
index 67c2c5d0..8afa330b 100644
--- a/src/managers/KeybindManager.cpp
+++ b/src/managers/KeybindManager.cpp
@@ -1374,6 +1374,7 @@ SDispatchResult CKeybindManager::moveActiveToWorkspaceSilent(std::string args) {
SDispatchResult CKeybindManager::moveFocusTo(std::string args) {
static auto PFULLCYCLE = CConfigValue<Hyprlang::INT>("binds:movefocus_cycles_fullscreen");
static auto PMONITORFALLBACK = CConfigValue<Hyprlang::INT>("binds:window_direction_monitor_fallback");
+ static auto PGROUPCYCLE = CConfigValue<Hyprlang::INT>("binds:movefocus_cycles_groupfirst");
char arg = args[0];
if (!isDirection(args)) {
@@ -1393,6 +1394,21 @@ SDispatchResult CKeybindManager::moveFocusTo(std::string args) {
(arg == 'd' || arg == 'b' || arg == 'r' ? g_pCompositor->getNextWindowOnWorkspace(PLASTWINDOW, true) : g_pCompositor->getPrevWindowOnWorkspace(PLASTWINDOW, true)) :
g_pCompositor->getWindowInDirection(PLASTWINDOW, arg);
+ // Prioritize focus change within groups if the window is a part of it.
+ if (*PGROUPCYCLE) {
+ if (!PLASTWINDOW->m_sGroupData.pNextWindow.expired()) {
+ if (arg == 'l' && PLASTWINDOW != PLASTWINDOW->getGroupHead()) {
+ PLASTWINDOW->setGroupCurrent(PLASTWINDOW->getGroupPrevious());
+ return {};
+ }
+
+ else if (arg == 'r' && PLASTWINDOW != PLASTWINDOW->getGroupTail()) {
+ PLASTWINDOW->setGroupCurrent(PLASTWINDOW->m_sGroupData.pNextWindow.lock());
+ return {};
+ }
+ }
+ }
+
// Found window in direction, switch to it
if (PWINDOWTOCHANGETO) {
switchToWindow(PWINDOWTOCHANGETO);