aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorMightyPlaza <[email protected]>2023-11-01 19:13:39 +0000
committerGitHub <[email protected]>2023-11-01 19:13:39 +0000
commitc44e255194c8cc275e31e62277a8a52143e31881 (patch)
tree2c1f1f4e31a2a23e92b4fe43ee9f431ae87615d0
parent21e9313c100e005ec2a9a5100c29258a2885546b (diff)
downloadHyprland-c44e255194c8cc275e31e62277a8a52143e31881.tar.gz
Hyprland-c44e255194c8cc275e31e62277a8a52143e31881.zip
group: fixes for dragging groups onto groupbars (#3708)
* fixes for dragging groups onto groupbars modified: src/render/decorations/CHyprGroupBarDecoration.cpp * use onWindowRemoved() modified: src/render/decorations/CHyprGroupBarDecoration.cpp
-rw-r--r--src/render/decorations/CHyprGroupBarDecoration.cpp36
1 files changed, 34 insertions, 2 deletions
diff --git a/src/render/decorations/CHyprGroupBarDecoration.cpp b/src/render/decorations/CHyprGroupBarDecoration.cpp
index 7f9fcde9..3e3075ea 100644
--- a/src/render/decorations/CHyprGroupBarDecoration.cpp
+++ b/src/render/decorations/CHyprGroupBarDecoration.cpp
@@ -314,13 +314,45 @@ bool CHyprGroupBarDecoration::onEndWindowDragOnDeco(CWindow* pDraggedWindow, con
const int WINDOWINDEX = BARRELATIVEX < 0 ? -1 : (BARRELATIVEX) / (m_fBarWidth + BAR_HORIZONTAL_PADDING);
CWindow* pWindowInsertAfter = m_pWindow->getGroupWindowByIndex(WINDOWINDEX);
+ CWindow* pWindowInsertEnd = pWindowInsertAfter->m_sGroupData.pNextWindow;
+ CWindow* pDraggedHead = pDraggedWindow->m_sGroupData.pNextWindow ? pDraggedWindow->getGroupHead() : pDraggedWindow;
+
+ if (pDraggedWindow->m_sGroupData.pNextWindow) {
+
+ // stores group data
+ std::vector<CWindow*> members;
+ CWindow* curr = pDraggedHead;
+ const bool WASLOCKED = pDraggedHead->m_sGroupData.locked;
+ do {
+ members.push_back(curr);
+ curr = curr->m_sGroupData.pNextWindow;
+ } while (curr != members[0]);
+
+ // removes all windows
+ for (CWindow* w : members) {
+ w->m_sGroupData.pNextWindow = nullptr;
+ w->m_sGroupData.head = false;
+ w->m_sGroupData.locked = false;
+ g_pLayoutManager->getCurrentLayout()->onWindowRemoved(w);
+ }
- g_pLayoutManager->getCurrentLayout()->onWindowRemoved(pDraggedWindow);
+ // restores the group
+ for (auto it = members.begin(); it != members.end(); ++it) {
+ if (std::next(it) != members.end())
+ (*it)->m_sGroupData.pNextWindow = *std::next(it);
+ else
+ (*it)->m_sGroupData.pNextWindow = members[0];
+ }
+ members[0]->m_sGroupData.head = true;
+ members[0]->m_sGroupData.locked = WASLOCKED;
+ } else {
+ g_pLayoutManager->getCurrentLayout()->onWindowRemoved(pDraggedWindow);
+ }
pWindowInsertAfter->insertWindowToGroup(pDraggedWindow);
if (WINDOWINDEX == -1)
- std::swap(pDraggedWindow->m_sGroupData.head, pDraggedWindow->m_sGroupData.pNextWindow->m_sGroupData.head);
+ std::swap(pDraggedHead->m_sGroupData.head, pWindowInsertEnd->m_sGroupData.head);
m_pWindow->setGroupCurrent(pDraggedWindow);
pDraggedWindow->applyGroupRules();