From 58b3cc985e6a5f5c64d83b6e8461ac257cc9fabe Mon Sep 17 00:00:00 2001 From: normaltaro Date: Thu, 28 Nov 2024 05:03:57 +0530 Subject: [PATCH 1/4] modified movefocus dispatcher to prioritize focus change within groups --- src/managers/KeybindManager.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/managers/KeybindManager.cpp b/src/managers/KeybindManager.cpp index a53271498e6..39cb74e816a 100644 --- a/src/managers/KeybindManager.cpp +++ b/src/managers/KeybindManager.cpp @@ -1395,6 +1395,19 @@ 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 part of it. + 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); From 6f78a2e5a8c2f17f60e50fce5a78dfee7a6d93ea Mon Sep 17 00:00:00 2001 From: normaltaro Date: Thu, 28 Nov 2024 06:14:27 +0530 Subject: [PATCH 2/4] pass clang-format check --- src/managers/KeybindManager.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/managers/KeybindManager.cpp b/src/managers/KeybindManager.cpp index 39cb74e816a..68a70c0e4df 100644 --- a/src/managers/KeybindManager.cpp +++ b/src/managers/KeybindManager.cpp @@ -1401,13 +1401,13 @@ SDispatchResult CKeybindManager::moveFocusTo(std::string args) { 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); From 6b86fe4c00c5288df02492c0b12462bad38e918d Mon Sep 17 00:00:00 2001 From: normaltaro Date: Thu, 12 Dec 2024 01:51:32 +0530 Subject: [PATCH 3/4] `movefocus` cycling groups set optional to config bool `movefocus_cycles_groupfirst` --- src/config/ConfigDescriptions.hpp | 6 ++++++ src/config/ConfigManager.cpp | 1 + src/managers/KeybindManager.cpp | 21 ++++++++++++--------- 3 files changed, 19 insertions(+), 9 deletions(-) diff --git a/src/config/ConfigDescriptions.hpp b/src/config/ConfigDescriptions.hpp index a1d4858c32c..a782b134f7b 100644 --- a/src/config/ConfigDescriptions.hpp +++ b/src/config/ConfigDescriptions.hpp @@ -1200,6 +1200,12 @@ inline static const std::vector CONFIG_OPTIONS = { .type = CONFIG_OPTION_BOOL, .data = SConfigOptionDescription::SBoolData{true}, }, + SConfigOptionDescription{ + .value = "binds:movefocus_cycles_groupfirst", + .description = "If enabled, when in a grouped window, movefocus will cycle windows in the groups first, then at the end of 'tabs', it'll move on to other windows/groups", + .type = CONFIG_OPTION_BOOL, + .data = SConfigOptionDescription::SBoolData{false}, + }, SConfigOptionDescription{ .value = "binds:disable_keybind_grabbing", .description = "If enabled, apps that request keybinds to be disabled (e.g. VMs) will not be able to do so.", diff --git a/src/config/ConfigManager.cpp b/src/config/ConfigManager.cpp index ce474f94885..e1d26fe31c5 100644 --- a/src/config/ConfigManager.cpp +++ b/src/config/ConfigManager.cpp @@ -544,6 +544,7 @@ CConfigManager::CConfigManager() { m_pConfig->addConfigValue("binds:focus_preferred_method", Hyprlang::INT{0}); m_pConfig->addConfigValue("binds:ignore_group_lock", Hyprlang::INT{0}); m_pConfig->addConfigValue("binds:movefocus_cycles_fullscreen", Hyprlang::INT{1}); + m_pConfig->addConfigValue("binds:movefocus_cycles_groupfirst", Hyprlang::INT{0}); m_pConfig->addConfigValue("binds:disable_keybind_grabbing", Hyprlang::INT{0}); m_pConfig->addConfigValue("binds:window_direction_monitor_fallback", Hyprlang::INT{1}); m_pConfig->addConfigValue("binds:allow_pin_fullscreen", Hyprlang::INT{0}); diff --git a/src/managers/KeybindManager.cpp b/src/managers/KeybindManager.cpp index 066723ac3da..2dbbb0dad0f 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("binds:movefocus_cycles_fullscreen"); static auto PMONITORFALLBACK = CConfigValue("binds:window_direction_monitor_fallback"); + static auto PGROUPCYCLE = CConfigValue("binds:movefocus_cycles_groupfirst"); char arg = args[0]; if (!isDirection(args)) { @@ -1393,16 +1394,18 @@ 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 part of it. - if (!PLASTWINDOW->m_sGroupData.pNextWindow.expired()) { - if (arg == 'l' && PLASTWINDOW != PLASTWINDOW->getGroupHead()) { - PLASTWINDOW->setGroupCurrent(PLASTWINDOW->getGroupPrevious()); - return {}; - } + // 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 {}; + else if (arg == 'r' && PLASTWINDOW != PLASTWINDOW->getGroupTail()) { + PLASTWINDOW->setGroupCurrent(PLASTWINDOW->m_sGroupData.pNextWindow.lock()); + return {}; + } } } From 4f00cde81916b9f4016c2a159ce5184d9a523d85 Mon Sep 17 00:00:00 2001 From: normaltaro <30935678+normaltaro@users.noreply.github.com> Date: Thu, 12 Dec 2024 02:52:12 +0530 Subject: [PATCH 4/4] Update ConfigDescriptions.hpp --- src/config/ConfigDescriptions.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/config/ConfigDescriptions.hpp b/src/config/ConfigDescriptions.hpp index 5c955376e88..6792a763394 100644 --- a/src/config/ConfigDescriptions.hpp +++ b/src/config/ConfigDescriptions.hpp @@ -1202,7 +1202,7 @@ inline static const std::vector CONFIG_OPTIONS = { }, SConfigOptionDescription{ .value = "binds:movefocus_cycles_groupfirst", - .description = "If enabled, when in a grouped window, movefocus will cycle windows in the groups first, then at the end of 'tabs', it'll move on to other windows/groups", + .description = "If enabled, when in a grouped window, movefocus will cycle windows in the groups first, then at each ends of tabs, it'll move on to other windows/groups", .type = CONFIG_OPTION_BOOL, .data = SConfigOptionDescription::SBoolData{false}, },