summaryrefslogtreecommitdiff
path: root/src/Window.cpp
diff options
context:
space:
mode:
authormemchr <118117622+memchr@users.noreply.github.com>2023-09-21 23:42:00 +0000
committerGitHub <noreply@github.com>2023-09-22 00:42:00 +0100
commit1357b66091ecd73f097d19d527a23a9ae72a4ff1 (patch)
treee629bedcce584757ebd1afae0dcc12ea25f15c95 /src/Window.cpp
parent2e1842b5ff140bc81a604c663482221d86c30cff (diff)
windowrules: add rule `group` to map windows grouped (#3279)
* windows: add rule group to map windows grouped * group rule: use `invade` to force open a window in a locked group
Diffstat (limited to 'src/Window.cpp')
-rw-r--r--src/Window.cpp63
1 files changed, 63 insertions, 0 deletions
diff --git a/src/Window.cpp b/src/Window.cpp
index 3df30123..4ee40dff 100644
--- a/src/Window.cpp
+++ b/src/Window.cpp
@@ -641,6 +641,69 @@ bool CWindow::hasPopupAt(const Vector2D& pos) {
return resultSurf;
}
+void CWindow::applyGroupRules() {
+ if ((m_eGroupRules & GROUP_SET && m_bFirstMap) || m_eGroupRules & GROUP_SET_ALWAYS)
+ createGroup();
+
+ if (m_sGroupData.pNextWindow && ((m_eGroupRules & GROUP_LOCK && m_bFirstMap) || m_eGroupRules & GROUP_LOCK_ALWAYS))
+ getGroupHead()->m_sGroupData.locked = true;
+}
+
+void CWindow::createGroup() {
+ if (m_sGroupData.deny) {
+ Debug::log(LOG, "createGroup: window:{:x},title:{} is denied as a group, ignored", (uintptr_t)this, this->m_szTitle);
+ return;
+ }
+ if (!m_sGroupData.pNextWindow) {
+ m_sGroupData.pNextWindow = this;
+ m_sGroupData.head = true;
+ m_sGroupData.locked = false;
+ m_sGroupData.deny = false;
+
+ m_dWindowDecorations.emplace_back(std::make_unique<CHyprGroupBarDecoration>(this));
+ updateWindowDecos();
+
+ g_pLayoutManager->getCurrentLayout()->recalculateWindow(this);
+ g_pCompositor->updateAllWindowsAnimatedDecorationValues();
+ }
+}
+
+void CWindow::destroyGroup() {
+ if (m_sGroupData.pNextWindow == this) {
+ if (m_eGroupRules & GROUP_SET_ALWAYS) {
+ Debug::log(LOG, "destoryGroup: window:{:x},title:{} has rule [group set always], ignored", (uintptr_t)this, this->m_szTitle);
+ return;
+ }
+ m_sGroupData.pNextWindow = nullptr;
+ updateWindowDecos();
+ return;
+ }
+
+ CWindow* curr = this;
+ std::vector<CWindow*> members;
+ do {
+ const auto PLASTWIN = curr;
+ curr = curr->m_sGroupData.pNextWindow;
+ PLASTWIN->m_sGroupData.pNextWindow = nullptr;
+ curr->setHidden(false);
+ members.push_back(curr);
+ } while (curr != this);
+
+ for (auto& w : members) {
+ if (w->m_sGroupData.head)
+ g_pLayoutManager->getCurrentLayout()->onWindowRemoved(curr);
+ w->m_sGroupData.head = false;
+ }
+
+ const bool GROUPSLOCKEDPREV = g_pKeybindManager->m_bGroupsLocked;
+ g_pKeybindManager->m_bGroupsLocked = true;
+ for (auto& w : members) {
+ g_pLayoutManager->getCurrentLayout()->onWindowCreated(w);
+ w->updateWindowDecos();
+ }
+ g_pKeybindManager->m_bGroupsLocked = GROUPSLOCKEDPREV;
+}
+
CWindow* CWindow::getGroupHead() {
CWindow* curr = this;
while (!curr->m_sGroupData.head)