summaryrefslogtreecommitdiff
path: root/src/managers/KeybindManager.cpp
diff options
context:
space:
mode:
authorlittleblack111 <littleblack11111@gmail.com>2026-03-28 23:31:04 +0800
committerGitHub <noreply@github.com>2026-03-28 15:31:04 +0000
commit1c25bcc811664a0dc206f3e4e616b88f5581e83d (patch)
tree19c11e42ba7b3170d5d7c1789e412677c5c587f7 /src/managers/KeybindManager.cpp
parent3103119b7cdda67e1d43588ad07a80465626b3c2 (diff)
dispatchers: add moveintoorcreategroup (#13325)
Diffstat (limited to 'src/managers/KeybindManager.cpp')
-rw-r--r--src/managers/KeybindManager.cpp40
1 files changed, 40 insertions, 0 deletions
diff --git a/src/managers/KeybindManager.cpp b/src/managers/KeybindManager.cpp
index 4a698c16..10f760a0 100644
--- a/src/managers/KeybindManager.cpp
+++ b/src/managers/KeybindManager.cpp
@@ -125,6 +125,7 @@ CKeybindManager::CKeybindManager() {
m_dispatchers["lockgroups"] = lockGroups;
m_dispatchers["lockactivegroup"] = lockActiveGroup;
m_dispatchers["moveintogroup"] = moveIntoGroup;
+ m_dispatchers["moveintoorcreategroup"] = moveIntoOrCreateGroup;
m_dispatchers["moveoutofgroup"] = moveOutOfGroup;
m_dispatchers["movewindoworgroup"] = moveWindowOrGroup;
m_dispatchers["setignoregrouplock"] = setIgnoreGroupLock;
@@ -2690,6 +2691,45 @@ SDispatchResult CKeybindManager::moveIntoGroup(std::string args) {
return {};
}
+SDispatchResult CKeybindManager::moveIntoOrCreateGroup(std::string args) {
+ static auto PIGNOREGROUPLOCK = CConfigValue<Hyprlang::INT>("binds:ignore_group_lock");
+
+ if (!*PIGNOREGROUPLOCK && g_pKeybindManager->m_groupsLocked)
+ return {};
+
+ Math::eDirection dir = Math::fromChar(args[0]);
+ if (dir == Math::DIRECTION_DEFAULT) {
+ Log::logger->log(Log::ERR, "Cannot move into or create group in direction {}, unsupported direction. Supported: l,r,u/t,d/b", args[0]);
+ return {.success = false, .error = std::format("Cannot move into or create group in direction {}, unsupported direction. Supported: l,r,u/t,d/b", args[0])};
+ }
+
+ const auto PWINDOW = Desktop::focusState()->window();
+
+ if (!PWINDOW)
+ return {};
+
+ auto PWINDOWINDIR = g_pCompositor->getWindowInDirection(PWINDOW, dir);
+
+ if (!PWINDOWINDIR)
+ return {};
+
+ if (!PWINDOWINDIR->m_group) {
+ if (PWINDOWINDIR->isFullscreen())
+ return {};
+
+ PWINDOWINDIR->m_group = Desktop::View::CGroup::create({PWINDOWINDIR});
+ }
+
+ const auto GROUP = PWINDOWINDIR->m_group;
+
+ if (!*PIGNOREGROUPLOCK && (GROUP->locked() || (PWINDOW->m_group && PWINDOW->m_group->locked())))
+ return {};
+
+ moveWindowIntoGroup(PWINDOW, PWINDOWINDIR);
+
+ return {};
+}
+
SDispatchResult CKeybindManager::moveOutOfGroup(std::string args) {
static auto PIGNOREGROUPLOCK = CConfigValue<Hyprlang::INT>("binds:ignore_group_lock");