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
This commit is contained in:
MightyPlaza 2023-11-01 19:13:39 +00:00 committed by GitHub
parent 21e9313c10
commit c44e255194
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -314,13 +314,45 @@ bool CHyprGroupBarDecoration::onEndWindowDragOnDeco(CWindow* pDraggedWindow, con
const int WINDOWINDEX = BARRELATIVEX < 0 ? -1 : (BARRELATIVEX) / (m_fBarWidth + BAR_HORIZONTAL_PADDING); const int WINDOWINDEX = BARRELATIVEX < 0 ? -1 : (BARRELATIVEX) / (m_fBarWidth + BAR_HORIZONTAL_PADDING);
CWindow* pWindowInsertAfter = m_pWindow->getGroupWindowByIndex(WINDOWINDEX); 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);
}
// 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); g_pLayoutManager->getCurrentLayout()->onWindowRemoved(pDraggedWindow);
}
pWindowInsertAfter->insertWindowToGroup(pDraggedWindow); pWindowInsertAfter->insertWindowToGroup(pDraggedWindow);
if (WINDOWINDEX == -1) 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); m_pWindow->setGroupCurrent(pDraggedWindow);
pDraggedWindow->applyGroupRules(); pDraggedWindow->applyGroupRules();