summaryrefslogtreecommitdiff
path: root/src/managers
diff options
context:
space:
mode:
authormemchr <118117622+memchr@users.noreply.github.com>2023-06-09 21:44:18 +0000
committerGitHub <noreply@github.com>2023-06-09 23:44:18 +0200
commitbca3068db224d76b2da3f792efe4d0cb8cd2fe3e (patch)
treead65b8486745efa24faca33dfe2ecaadd5451937 /src/managers
parentcf37922d4285689990a648bc02aecb90a07a36ba (diff)
feat: add lockactivegroup dispatcher (#2478)
* feat: add lockactivegroup dispatcher The `lockactivewindow` dispatcher takes `lock`, `toggle` or `unlock` as arguments. When a group is locked, no window or group can be added to it, nor can it be added to another group, but the `moveintogroup` and `moveoutofgroup` dispatches are not affected. Implementation details: the lock is implement via `SGroupData.locked` flag (defaults to false). The flag is only relevant to the group head, and upon the group head's succession, the flag will be passed down to the new head. Meanwhile, the old head's flag will be set to false. The flag is set to false when a group is dismissed. New condition checks have been added to the dwindle and master layout to check if target group is unlocked (and if the source is also a group and unlocked) before adding windows to the target group. * refactor: `lockactivegroup dispatcher code ordering
Diffstat (limited to 'src/managers')
-rw-r--r--src/managers/KeybindManager.cpp18
-rw-r--r--src/managers/KeybindManager.hpp1
2 files changed, 19 insertions, 0 deletions
diff --git a/src/managers/KeybindManager.cpp b/src/managers/KeybindManager.cpp
index 34a7defa..77df730d 100644
--- a/src/managers/KeybindManager.cpp
+++ b/src/managers/KeybindManager.cpp
@@ -63,6 +63,7 @@ CKeybindManager::CKeybindManager() {
m_mDispatchers["focusurgentorlast"] = focusUrgentOrLast;
m_mDispatchers["focuscurrentorlast"] = focusCurrentOrLast;
m_mDispatchers["lockgroups"] = lockGroups;
+ m_mDispatchers["lockactivegroup"] = lockActiveGroup;
m_mDispatchers["moveintogroup"] = moveIntoGroup;
m_mDispatchers["moveoutofgroup"] = moveOutOfGroup;
m_mDispatchers["global"] = global;
@@ -1173,6 +1174,7 @@ void CKeybindManager::toggleGroup(std::string args) {
if (!PWINDOW->m_sGroupData.pNextWindow) {
PWINDOW->m_sGroupData.pNextWindow = PWINDOW;
PWINDOW->m_sGroupData.head = true;
+ PWINDOW->m_sGroupData.locked = false;
PWINDOW->m_dWindowDecorations.emplace_back(std::make_unique<CHyprGroupBarDecoration>(PWINDOW));
@@ -1989,6 +1991,22 @@ void CKeybindManager::lockGroups(std::string args) {
}
}
+void CKeybindManager::lockActiveGroup(std::string args) {
+ const auto PWINDOW = g_pCompositor->m_pLastWindow;
+
+ if (!PWINDOW || !PWINDOW->m_sGroupData.pNextWindow)
+ return;
+ const auto PHEAD = PWINDOW->getGroupHead();
+
+ if (args == "lock") {
+ PHEAD->m_sGroupData.locked = true;
+ } else if (args == "toggle") {
+ PHEAD->m_sGroupData.locked = !PHEAD->m_sGroupData.locked;
+ } else {
+ PHEAD->m_sGroupData.locked = false;
+ }
+}
+
void CKeybindManager::moveIntoGroup(std::string args) {
char arg = args[0];
diff --git a/src/managers/KeybindManager.hpp b/src/managers/KeybindManager.hpp
index 5b7e6186..b45e83fa 100644
--- a/src/managers/KeybindManager.hpp
+++ b/src/managers/KeybindManager.hpp
@@ -140,6 +140,7 @@ class CKeybindManager {
static void mouse(std::string);
static void bringActiveToTop(std::string);
static void lockGroups(std::string);
+ static void lockActiveGroup(std::string);
static void moveIntoGroup(std::string);
static void moveOutOfGroup(std::string);
static void global(std::string);