mirror of
https://github.com/hyprwm/Hyprland
synced 2024-11-29 19:45:58 +01:00
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
This commit is contained in:
parent
cf37922d42
commit
bca3068db2
7 changed files with 29 additions and 2 deletions
|
@ -645,6 +645,7 @@ void CWindow::insertWindowToGroup(CWindow* pWindow) {
|
|||
curr = curr->m_sGroupData.pNextWindow;
|
||||
PLAST->m_sGroupData.pNextWindow = nullptr;
|
||||
PLAST->m_sGroupData.head = false;
|
||||
PLAST->m_sGroupData.locked = false;
|
||||
} while (curr != pWindow);
|
||||
|
||||
for (auto& w : members) {
|
||||
|
|
|
@ -288,6 +288,7 @@ class CWindow {
|
|||
struct SGroupData {
|
||||
CWindow* pNextWindow = nullptr; // nullptr means no grouping. Self means single group.
|
||||
bool head = false;
|
||||
bool locked = false;
|
||||
} m_sGroupData;
|
||||
|
||||
// For the list lookup
|
||||
|
|
|
@ -311,7 +311,9 @@ void CHyprDwindleLayout::onWindowCreatedTiling(CWindow* pWindow) {
|
|||
}
|
||||
|
||||
// if it's a group, add the window
|
||||
if (OPENINGON->pWindow->m_sGroupData.pNextWindow && !g_pKeybindManager->m_bGroupsLocked) {
|
||||
if (OPENINGON->pWindow->m_sGroupData.pNextWindow && !OPENINGON->pWindow->getGroupHead()->m_sGroupData.locked && // target is an unlocked group
|
||||
(!pWindow->m_sGroupData.pNextWindow || !pWindow->getGroupHead()->m_sGroupData.locked) // source is not group or is a unlocked group
|
||||
&& !g_pKeybindManager->m_bGroupsLocked) {
|
||||
m_lDwindleNodesData.remove(*PNODE);
|
||||
|
||||
OPENINGON->pWindow->insertWindowToGroup(pWindow);
|
||||
|
|
|
@ -45,6 +45,8 @@ void IHyprLayout::onWindowRemoved(CWindow* pWindow) {
|
|||
if (pWindow->m_sGroupData.head) {
|
||||
pWindow->m_sGroupData.head = false;
|
||||
curr->m_sGroupData.head = true;
|
||||
curr->m_sGroupData.locked = pWindow->m_sGroupData.locked;
|
||||
pWindow->m_sGroupData.locked = false;
|
||||
}
|
||||
|
||||
if (pWindow == m_pLastTiledWindow)
|
||||
|
|
|
@ -91,7 +91,9 @@ void CHyprMasterLayout::onWindowCreatedTiling(CWindow* pWindow) {
|
|||
getNodeFromWindow(g_pCompositor->m_pLastWindow) :
|
||||
getMasterNodeOnWorkspace(pWindow->m_iWorkspaceID);
|
||||
|
||||
if (OPENINGON && OPENINGON->pWindow->m_sGroupData.pNextWindow && OPENINGON != PNODE && !g_pKeybindManager->m_bGroupsLocked) {
|
||||
if (OPENINGON && OPENINGON->pWindow->m_sGroupData.pNextWindow && !OPENINGON->pWindow->getGroupHead()->m_sGroupData.locked && // target is an unlocked group
|
||||
(!pWindow->m_sGroupData.pNextWindow || !pWindow->getGroupHead()->m_sGroupData.locked) // source is not group or is an unlocked group
|
||||
&& OPENINGON != PNODE && !g_pKeybindManager->m_bGroupsLocked) {
|
||||
m_lMasterNodesData.remove(*PNODE);
|
||||
|
||||
OPENINGON->pWindow->insertWindowToGroup(pWindow);
|
||||
|
|
|
@ -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];
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue