aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Window.cpp
diff options
context:
space:
mode:
authorVaxry <[email protected]>2023-02-19 21:07:32 +0000
committerGitHub <[email protected]>2023-02-19 21:07:32 +0000
commite5a4c0c986f72813e8822f31ed3d5fa6be1b6c13 (patch)
tree8ce0ad44055c63e905303f49da61c9f44316170a /src/Window.cpp
parent2363cc2572c8b1f99a3ac5ff4104067b0503a302 (diff)
downloadHyprland-e5a4c0c986f72813e8822f31ed3d5fa6be1b6c13.tar.gz
Hyprland-e5a4c0c986f72813e8822f31ed3d5fa6be1b6c13.zip
Group/Tab Rework (#1580)
Diffstat (limited to 'src/Window.cpp')
-rw-r--r--src/Window.cpp68
1 files changed, 68 insertions, 0 deletions
diff --git a/src/Window.cpp b/src/Window.cpp
index e7d4a02a..1ca35ab3 100644
--- a/src/Window.cpp
+++ b/src/Window.cpp
@@ -468,3 +468,71 @@ bool CWindow::hasPopupAt(const Vector2D& pos) {
return resultSurf;
}
+
+CWindow* CWindow::getGroupHead() {
+ CWindow* curr = this;
+ while (!curr->m_sGroupData.head)
+ curr = curr->m_sGroupData.pNextWindow;
+ return curr;
+}
+
+CWindow* CWindow::getGroupTail() {
+ CWindow* curr = this;
+ while (!curr->m_sGroupData.pNextWindow->m_sGroupData.head)
+ curr = curr->m_sGroupData.pNextWindow;
+ return curr;
+}
+
+CWindow* CWindow::getGroupCurrent() {
+ CWindow* curr = this;
+ while (curr->isHidden())
+ curr = curr->m_sGroupData.pNextWindow;
+ return curr;
+}
+
+void CWindow::setGroupCurrent(CWindow* pWindow) {
+ CWindow* curr = this->m_sGroupData.pNextWindow;
+ bool isMember = false;
+ while (curr != this) {
+ if (curr == pWindow) {
+ isMember = true;
+ break;
+ }
+ curr = curr->m_sGroupData.pNextWindow;
+ }
+
+ if (!isMember && pWindow != this)
+ return;
+
+ const auto PCURRENT = getGroupCurrent();
+
+ const auto PWINDOWSIZE = PCURRENT->m_vRealSize.goalv();
+ const auto PWINDOWPOS = PCURRENT->m_vRealPosition.goalv();
+
+ const auto CURRENTISFOCUS = PCURRENT == g_pCompositor->m_pLastWindow;
+
+ PCURRENT->setHidden(true);
+ pWindow->setHidden(false);
+
+ g_pLayoutManager->getCurrentLayout()->replaceWindowDataWith(PCURRENT, pWindow);
+
+ if (PCURRENT->m_bIsFloating) {
+ pWindow->m_vRealPosition.setValueAndWarp(PWINDOWPOS);
+ pWindow->m_vRealSize.setValueAndWarp(PWINDOWSIZE);
+ }
+
+ g_pCompositor->updateAllWindowsAnimatedDecorationValues();
+
+ if (CURRENTISFOCUS)
+ g_pCompositor->focusWindow(pWindow);
+}
+
+void CWindow::insertWindowToGroup(CWindow* pWindow) {
+ const auto PHEAD = getGroupHead();
+ const auto PTAIL = getGroupTail();
+
+ PTAIL->m_sGroupData.pNextWindow = pWindow;
+ pWindow->m_sGroupData.pNextWindow = PHEAD;
+
+ setGroupCurrent(pWindow);
+} \ No newline at end of file