summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMightyPlaza <123664421+MightyPlaza@users.noreply.github.com>2023-07-03 10:49:56 +0000
committerGitHub <noreply@github.com>2023-07-03 12:49:56 +0200
commit05047f60f4a6303a26f5ecef712f249b770f27b9 (patch)
tree10cca6c3f8f095be53d162ddafa64d0401530026 /src
parent738ec900f4d5c5e2b00f90e71221ca380555b874 (diff)
groupbar fixes (#2630)
Fixes multiple groupbar decoration issues: - togglegroup removes fullscreen to avoid to avoid weird state - fixes issue where a group had multiple windows with head = true - fixes issue where merging 2 groups would cause a window to have 2 groupbar decorations - fixes issue where merging a group with more than 1 window into another group would make windows have no groupbar decoration - fixes issue where ungrouping windows could just move them into another group on the same workspace --------- Co-authored-by: vaxerski <43317083+vaxerski@users.noreply.github.com>
Diffstat (limited to 'src')
-rw-r--r--src/Window.cpp7
-rw-r--r--src/layout/DwindleLayout.cpp33
-rw-r--r--src/layout/MasterLayout.cpp34
-rw-r--r--src/managers/KeybindManager.cpp15
-rw-r--r--src/render/decorations/CHyprGroupBarDecoration.cpp7
5 files changed, 68 insertions, 28 deletions
diff --git a/src/Window.cpp b/src/Window.cpp
index 4a419f23..e84c3d23 100644
--- a/src/Window.cpp
+++ b/src/Window.cpp
@@ -670,8 +670,9 @@ void CWindow::insertWindowToGroup(CWindow* pWindow) {
const auto PTAIL = getGroupTail();
if (pWindow->m_sGroupData.pNextWindow) {
+ const auto PHEAD = pWindow->getGroupHead();
std::vector<CWindow*> members;
- CWindow* curr = pWindow;
+ CWindow* curr = PHEAD;
do {
const auto PLAST = curr;
members.push_back(curr);
@@ -679,7 +680,7 @@ void CWindow::insertWindowToGroup(CWindow* pWindow) {
PLAST->m_sGroupData.pNextWindow = nullptr;
PLAST->m_sGroupData.head = false;
PLAST->m_sGroupData.locked = false;
- } while (curr != pWindow);
+ } while (curr != PHEAD);
for (auto& w : members) {
insertWindowToGroup(w);
@@ -690,8 +691,6 @@ void CWindow::insertWindowToGroup(CWindow* pWindow) {
PTAIL->m_sGroupData.pNextWindow = pWindow;
pWindow->m_sGroupData.pNextWindow = PHEAD;
-
- setGroupCurrent(pWindow);
}
void CWindow::updateGroupOutputs() {
diff --git a/src/layout/DwindleLayout.cpp b/src/layout/DwindleLayout.cpp
index 3d16cb12..dda9a53f 100644
--- a/src/layout/DwindleLayout.cpp
+++ b/src/layout/DwindleLayout.cpp
@@ -311,18 +311,33 @@ void CHyprDwindleLayout::onWindowCreatedTiling(CWindow* pWindow) {
}
// if it's a group, add the window
- 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);
+ if (OPENINGON->pWindow->m_sGroupData.pNextWindow && !OPENINGON->pWindow->getGroupHead()->m_sGroupData.locked &&
+ !g_pKeybindManager->m_bGroupsLocked) { // target is an unlocked group
- OPENINGON->pWindow->insertWindowToGroup(pWindow);
+ if (!pWindow->m_sGroupData.pNextWindow) { // source is not a group
+ m_lDwindleNodesData.remove(*PNODE);
+ OPENINGON->pWindow->insertWindowToGroup(pWindow);
+ OPENINGON->pWindow->setGroupCurrent(pWindow);
- pWindow->m_dWindowDecorations.emplace_back(std::make_unique<CHyprGroupBarDecoration>(pWindow));
- pWindow->updateWindowDecos();
- recalculateWindow(pWindow);
+ pWindow->m_dWindowDecorations.emplace_back(std::make_unique<CHyprGroupBarDecoration>(pWindow));
+ pWindow->updateWindowDecos();
+ recalculateWindow(pWindow);
- return;
+ g_pCompositor->focusWindow(pWindow);
+ return;
+ }
+
+ if (!pWindow->getGroupHead()->m_sGroupData.locked) { // source is an unlocked group
+ m_lDwindleNodesData.remove(*PNODE);
+ OPENINGON->pWindow->insertWindowToGroup(pWindow);
+ OPENINGON->pWindow->setGroupCurrent(pWindow);
+
+ pWindow->updateWindowDecos();
+ recalculateWindow(pWindow);
+
+ g_pCompositor->focusWindow(pWindow);
+ return;
+ }
}
// If it's not, get the node under our cursor
diff --git a/src/layout/MasterLayout.cpp b/src/layout/MasterLayout.cpp
index 494fd7a2..b7e5a1bf 100644
--- a/src/layout/MasterLayout.cpp
+++ b/src/layout/MasterLayout.cpp
@@ -91,16 +91,34 @@ void CHyprMasterLayout::onWindowCreatedTiling(CWindow* pWindow) {
getNodeFromWindow(g_pCompositor->m_pLastWindow) :
getMasterNodeOnWorkspace(pWindow->m_iWorkspaceID);
- 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);
+ // if it's a group, add the window
+ if (OPENINGON && OPENINGON->pWindow->m_sGroupData.pNextWindow && !OPENINGON->pWindow->getGroupHead()->m_sGroupData.locked && !g_pKeybindManager->m_bGroupsLocked &&
+ OPENINGON != PNODE) { // target is an unlocked group
- OPENINGON->pWindow->insertWindowToGroup(pWindow);
+ if (!pWindow->m_sGroupData.pNextWindow) { // source is not a group
+ m_lMasterNodesData.remove(*PNODE);
+ OPENINGON->pWindow->insertWindowToGroup(pWindow);
+ OPENINGON->pWindow->setGroupCurrent(pWindow);
- pWindow->m_dWindowDecorations.emplace_back(std::make_unique<CHyprGroupBarDecoration>(pWindow));
+ pWindow->m_dWindowDecorations.emplace_back(std::make_unique<CHyprGroupBarDecoration>(pWindow));
+ pWindow->updateWindowDecos();
+ recalculateWindow(pWindow);
- return;
+ g_pCompositor->focusWindow(pWindow);
+ return;
+ }
+
+ if (!pWindow->getGroupHead()->m_sGroupData.locked) { // source is an unlocked group
+ m_lMasterNodesData.remove(*PNODE);
+ OPENINGON->pWindow->insertWindowToGroup(pWindow);
+ OPENINGON->pWindow->setGroupCurrent(pWindow);
+
+ pWindow->updateWindowDecos();
+ recalculateWindow(pWindow);
+
+ g_pCompositor->focusWindow(pWindow);
+ return;
+ }
}
if (*PNEWISMASTER || WINDOWSONWORKSPACE == 1 || (!pWindow->m_bFirstMap && OPENINGON->isMaster)) {
@@ -276,7 +294,7 @@ void CHyprMasterLayout::calculateWorkspace(const int& ws) {
if ((WINDOWS < 2) && !centerMasterWindow) {
PMASTERNODE->position = PMONITOR->vecReservedTopLeft + PMONITOR->vecPosition;
PMASTERNODE->size = Vector2D(PMONITOR->vecSize.x - PMONITOR->vecReservedTopLeft.x - PMONITOR->vecReservedBottomRight.x,
- PMONITOR->vecSize.y - PMONITOR->vecReservedBottomRight.y - PMONITOR->vecReservedTopLeft.y);
+ PMONITOR->vecSize.y - PMONITOR->vecReservedBottomRight.y - PMONITOR->vecReservedTopLeft.y);
applyNodeDataToWindow(PMASTERNODE);
return;
} else if (orientation == ORIENTATION_LEFT || orientation == ORIENTATION_RIGHT || (orientation == ORIENTATION_CENTER && STACKWINDOWS <= 1)) {
diff --git a/src/managers/KeybindManager.cpp b/src/managers/KeybindManager.cpp
index 52a18d2b..097b881c 100644
--- a/src/managers/KeybindManager.cpp
+++ b/src/managers/KeybindManager.cpp
@@ -1174,6 +1174,8 @@ void CKeybindManager::toggleGroup(std::string args) {
if (!PWINDOW)
return;
+ g_pCompositor->setWindowFullscreen(PWINDOW, false, FULLSCREEN_FULL);
+
if (!PWINDOW->m_sGroupData.pNextWindow) {
PWINDOW->m_sGroupData.pNextWindow = PWINDOW;
PWINDOW->m_sGroupData.head = true;
@@ -1205,10 +1207,12 @@ void CKeybindManager::toggleGroup(std::string args) {
w->m_sGroupData.head = false;
}
+ g_pKeybindManager->m_bGroupsLocked = true;
for (auto& w : members) {
g_pLayoutManager->getCurrentLayout()->onWindowCreated(w);
w->updateWindowDecos();
}
+ g_pKeybindManager->m_bGroupsLocked = false;
}
}
@@ -2027,14 +2031,19 @@ void CKeybindManager::moveIntoGroup(std::string args) {
if (!PWINDOWINDIR || !PWINDOWINDIR->m_sGroupData.pNextWindow)
return;
- g_pLayoutManager->getCurrentLayout()->onWindowRemoved(PWINDOW);
+ if (!PWINDOW->m_sGroupData.pNextWindow)
+ PWINDOW->m_dWindowDecorations.emplace_back(std::make_unique<CHyprGroupBarDecoration>(PWINDOW));
- PWINDOWINDIR->insertWindowToGroup(PWINDOW);
+ g_pLayoutManager->getCurrentLayout()->onWindowRemoved(PWINDOW); // This removes groupped property!
- PWINDOW->m_dWindowDecorations.emplace_back(std::make_unique<CHyprGroupBarDecoration>(PWINDOW));
+ PWINDOW->m_sGroupData.locked = false;
+ PWINDOW->m_sGroupData.head = false;
+ PWINDOWINDIR->insertWindowToGroup(PWINDOW);
+ PWINDOWINDIR->setGroupCurrent(PWINDOW);
PWINDOW->updateWindowDecos();
g_pLayoutManager->getCurrentLayout()->recalculateWindow(PWINDOW);
+ g_pCompositor->focusWindow(PWINDOW);
}
void CKeybindManager::moveOutOfGroup(std::string args) {
diff --git a/src/render/decorations/CHyprGroupBarDecoration.cpp b/src/render/decorations/CHyprGroupBarDecoration.cpp
index 71243f2d..9a544023 100644
--- a/src/render/decorations/CHyprGroupBarDecoration.cpp
+++ b/src/render/decorations/CHyprGroupBarDecoration.cpp
@@ -42,7 +42,7 @@ void CHyprGroupBarDecoration::updateWindow(CWindow* pWindow) {
// we draw 3px above the window's border with 3px
static auto* const PBORDERSIZE = &g_pConfigManager->getConfigValuePtr("general:border_size")->intValue;
- m_seExtents.topLeft = Vector2D(0, *PBORDERSIZE + BAR_PADDING_OUTER_VERT * 2 + BAR_INDICATOR_HEIGHT + (*PRENDERTITLES ? *PTITLEFONTSIZE : 0));
+ m_seExtents.topLeft = Vector2D(0, *PBORDERSIZE + BAR_PADDING_OUTER_VERT * 2 + BAR_INDICATOR_HEIGHT + (*PRENDERTITLES ? *PTITLEFONTSIZE : 0) + 2);
m_seExtents.bottomRight = Vector2D();
m_vLastWindowPos = pWindow->m_vRealPosition.vec() + WORKSPACEOFFSET;
@@ -80,9 +80,8 @@ void CHyprGroupBarDecoration::updateWindow(CWindow* pWindow) {
}
void CHyprGroupBarDecoration::damageEntire() {
- const auto EXTENTS = getWindowDecorationReservedArea();
- wlr_box dm = {m_vLastWindowPos.x - m_seExtents.topLeft.x + EXTENTS.topLeft.x, m_vLastWindowPos.y - m_seExtents.topLeft.y + EXTENTS.topLeft.y - 2,
- m_vLastWindowSize.x + m_seExtents.topLeft.x + m_seExtents.bottomRight.x, m_seExtents.topLeft.y};
+ wlr_box dm = {m_vLastWindowPos.x - m_seExtents.topLeft.x, m_vLastWindowPos.y - m_seExtents.topLeft.y, m_vLastWindowSize.x + m_seExtents.topLeft.x + m_seExtents.bottomRight.x,
+ m_seExtents.topLeft.y};
g_pHyprRenderer->damageBox(&dm);
}