diff options
| author | vaxerski <43317083+vaxerski@users.noreply.github.com> | 2022-04-23 14:16:02 +0200 |
|---|---|---|
| committer | vaxerski <43317083+vaxerski@users.noreply.github.com> | 2022-04-23 14:16:02 +0200 |
| commit | 0147975faf939db389bebaa95e3a12e5e5a8753f (patch) | |
| tree | c6933763435812460ebdc9609ed90eae21110753 /src/layout/DwindleLayout.cpp | |
| parent | fa38dfd416b664033a96bb4af764fd54f7257d7b (diff) | |
New animation system
Diffstat (limited to 'src/layout/DwindleLayout.cpp')
| -rw-r--r-- | src/layout/DwindleLayout.cpp | 78 |
1 files changed, 48 insertions, 30 deletions
diff --git a/src/layout/DwindleLayout.cpp b/src/layout/DwindleLayout.cpp index e7f4b87a..f5cf454c 100644 --- a/src/layout/DwindleLayout.cpp +++ b/src/layout/DwindleLayout.cpp @@ -155,6 +155,9 @@ void CHyprDwindleLayout::applyNodeDataToWindow(SDwindleNodeData* pNode) { } } + PWINDOW->m_vRealSize = PWINDOW->m_vEffectiveSize; + PWINDOW->m_vRealPosition = PWINDOW->m_vEffectivePosition; + g_pXWaylandManager->setWindowSize(PWINDOW, PWINDOW->m_vEffectiveSize); } @@ -190,8 +193,8 @@ void CHyprDwindleLayout::onWindowCreated(CWindow* pWindow) { applyNodeDataToWindow(PNODE); - pWindow->m_vRealPosition = PNODE->position + PNODE->size / 2.f; - pWindow->m_vRealSize = Vector2D(5, 5); + pWindow->m_vRealPosition.setValue(PNODE->position + PNODE->size / 2.f); + pWindow->m_vRealSize.setValue(Vector2D(5, 5)); return; } @@ -265,8 +268,8 @@ void CHyprDwindleLayout::onWindowCreated(CWindow* pWindow) { applyNodeDataToWindow(OPENINGON); } - pWindow->m_vRealPosition = PNODE->position + PNODE->size / 2.f; - pWindow->m_vRealSize = Vector2D(5,5); + pWindow->m_vRealPosition.setValue(PNODE->position + PNODE->size / 2.f); + pWindow->m_vRealSize.setValue(Vector2D(5,5)); } void CHyprDwindleLayout::onWindowRemoved(CWindow* pWindow) { @@ -364,16 +367,16 @@ void CHyprDwindleLayout::changeWindowFloatingMode(CWindow* pWindow) { if (!PNODE) { // save real pos cuz the func applies the default 5,5 mid - const auto PSAVEDPOS = pWindow->m_vRealPosition; - const auto PSAVEDSIZE = pWindow->m_vRealSize; + const auto PSAVEDPOS = pWindow->m_vRealPosition.vec(); + const auto PSAVEDSIZE = pWindow->m_vRealSize.vec(); // if the window is pseudo, update its size - pWindow->m_vPseudoSize = pWindow->m_vRealSize; + pWindow->m_vPseudoSize = pWindow->m_vRealSize.vec(); onWindowCreated(pWindow); - pWindow->m_vRealPosition = PSAVEDPOS; - pWindow->m_vRealSize = PSAVEDSIZE; + pWindow->m_vRealPosition.setValue(PSAVEDPOS); + pWindow->m_vRealSize.setValue(PSAVEDSIZE); } else { onWindowRemoved(pWindow); @@ -409,8 +412,8 @@ void CHyprDwindleLayout::onBeginDragWindow() { } m_vBeginDragXY = g_pInputManager->getMouseCoordsInternal(); - m_vBeginDragPositionXY = DRAGGINGWINDOW->m_vRealPosition; - m_vBeginDragSizeXY = DRAGGINGWINDOW->m_vRealSize; + m_vBeginDragPositionXY = DRAGGINGWINDOW->m_vRealPosition.vec(); + m_vBeginDragSizeXY = DRAGGINGWINDOW->m_vRealSize.vec(); m_vLastDragXY = m_vBeginDragXY; g_pHyprRenderer->damageWindow(DRAGGINGWINDOW); @@ -445,16 +448,16 @@ void CHyprDwindleLayout::onMouseMove(const Vector2D& mousePos) { g_pHyprRenderer->damageWindow(DRAGGINGWINDOW); if (g_pInputManager->dragButton == BTN_LEFT) { - DRAGGINGWINDOW->m_vRealPosition = m_vBeginDragPositionXY + DELTA; - DRAGGINGWINDOW->m_vEffectivePosition = DRAGGINGWINDOW->m_vRealPosition; + DRAGGINGWINDOW->m_vRealPosition.setValueAndWarp(m_vBeginDragPositionXY + DELTA); + DRAGGINGWINDOW->m_vEffectivePosition = DRAGGINGWINDOW->m_vRealPosition.vec(); } else { if (DRAGGINGWINDOW->m_bIsFloating) { - DRAGGINGWINDOW->m_vRealSize = m_vBeginDragSizeXY + DELTA; - DRAGGINGWINDOW->m_vRealSize = Vector2D(std::clamp(DRAGGINGWINDOW->m_vRealSize.x, (double)20, (double)999999), std::clamp(DRAGGINGWINDOW->m_vRealSize.y, (double)20, (double)999999)); + DRAGGINGWINDOW->m_vRealSize.setValueAndWarp(m_vBeginDragSizeXY + DELTA); + DRAGGINGWINDOW->m_vRealSize.setValueAndWarp(Vector2D(std::clamp(DRAGGINGWINDOW->m_vRealSize.vec().x, (double)20, (double)999999), std::clamp(DRAGGINGWINDOW->m_vRealSize.vec().y, (double)20, (double)999999))); - DRAGGINGWINDOW->m_vEffectiveSize = DRAGGINGWINDOW->m_vRealSize; + DRAGGINGWINDOW->m_vEffectiveSize = DRAGGINGWINDOW->m_vRealSize.vec(); - g_pXWaylandManager->setWindowSize(DRAGGINGWINDOW, DRAGGINGWINDOW->m_vRealSize); + g_pXWaylandManager->setWindowSize(DRAGGINGWINDOW, DRAGGINGWINDOW->m_vRealSize.vec()); } else { // we need to adjust the splitratio @@ -515,7 +518,7 @@ void CHyprDwindleLayout::onMouseMove(const Vector2D& mousePos) { } // get middle point - Vector2D middle = DRAGGINGWINDOW->m_vRealPosition + DRAGGINGWINDOW->m_vRealSize / 2.f; + Vector2D middle = DRAGGINGWINDOW->m_vRealPosition.vec() + DRAGGINGWINDOW->m_vRealSize.vec() / 2.f; // and check its monitor const auto PMONITOR = g_pCompositor->getMonitorFromVector(middle); @@ -541,7 +544,7 @@ void CHyprDwindleLayout::onWindowCreatedFloating(CWindow* pWindow) { if (desiredGeometry.width <= 0 || desiredGeometry.height <= 0) { const auto PWINDOWSURFACE = g_pXWaylandManager->getWindowSurface(pWindow); pWindow->m_vEffectiveSize = Vector2D(PWINDOWSURFACE->current.width, PWINDOWSURFACE->current.height); - pWindow->m_vEffectivePosition = Vector2D(PMONITOR->vecPosition.x + (PMONITOR->vecSize.x - pWindow->m_vRealSize.x) / 2.f, PMONITOR->vecPosition.y + (PMONITOR->vecSize.y - pWindow->m_vRealSize.y) / 2.f); + pWindow->m_vEffectivePosition = Vector2D(PMONITOR->vecPosition.x + (PMONITOR->vecSize.x - pWindow->m_vRealSize.vec().x) / 2.f, PMONITOR->vecPosition.y + (PMONITOR->vecSize.y - pWindow->m_vRealSize.vec().y) / 2.f); } else { // we respect the size. @@ -562,14 +565,17 @@ void CHyprDwindleLayout::onWindowCreatedFloating(CWindow* pWindow) { } if (!pWindow->m_bX11DoesntWantBorders) { - pWindow->m_vRealPosition = pWindow->m_vEffectivePosition + pWindow->m_vEffectiveSize / 2.f; - pWindow->m_vRealSize = Vector2D(5, 5); + pWindow->m_vRealPosition.setValue(pWindow->m_vEffectivePosition + pWindow->m_vEffectiveSize / 2.f); + pWindow->m_vRealSize.setValue(Vector2D(5, 5)); } else { - pWindow->m_vRealPosition = pWindow->m_vEffectivePosition; - pWindow->m_vRealSize = pWindow->m_vEffectiveSize; + pWindow->m_vRealPosition.setValue(pWindow->m_vEffectivePosition); + pWindow->m_vRealSize.setValue(pWindow->m_vEffectiveSize); } - g_pXWaylandManager->setWindowSize(pWindow, pWindow->m_vRealSize); + pWindow->m_vRealPosition = pWindow->m_vEffectivePosition; + pWindow->m_vRealSize = pWindow->m_vEffectiveSize; + + g_pXWaylandManager->setWindowSize(pWindow, pWindow->m_vEffectiveSize); g_pCompositor->fixXWaylandWindowsOnWorkspace(PMONITOR->activeWorkspace); g_pCompositor->moveWindowToTop(pWindow); @@ -602,22 +608,22 @@ void CHyprDwindleLayout::fullscreenRequestForWindow(CWindow* pWindow) { pWindow->m_vEffectivePosition = pWindow->m_vPosition; pWindow->m_vEffectiveSize = pWindow->m_vSize; - g_pXWaylandManager->setWindowSize(pWindow, pWindow->m_vRealSize); + g_pXWaylandManager->setWindowSize(pWindow, pWindow->m_vRealSize.vec()); } } else { // if it now got fullscreen, make it fullscreen // save position and size if floating if (pWindow->m_bIsFloating) { - pWindow->m_vPosition = pWindow->m_vRealPosition; - pWindow->m_vSize = pWindow->m_vRealSize; + pWindow->m_vPosition = pWindow->m_vRealPosition.vec(); + pWindow->m_vSize = pWindow->m_vRealSize.vec(); } // apply new pos and size being monitors' box pWindow->m_vEffectivePosition = PMONITOR->vecPosition; pWindow->m_vEffectiveSize = PMONITOR->vecSize; - g_pXWaylandManager->setWindowSize(pWindow, pWindow->m_vRealSize); + g_pXWaylandManager->setWindowSize(pWindow, pWindow->m_vRealSize.vec()); } g_pCompositor->moveWindowToTop(pWindow); @@ -650,14 +656,20 @@ void CHyprDwindleLayout::toggleWindowGroup(CWindow* pWindow) { if (PGROUPPARENT) { // if there is a parent, release it - for (auto& node : PGROUPPARENT->groupMembers) + const auto INACTIVEBORDERCOL = CColor(g_pConfigManager->getInt("general:col.inactive_border")); + for (auto& node : PGROUPPARENT->groupMembers) { node->pGroupParent = nullptr; + node->pWindow->m_cRealBorderColor.setValueAndWarp(INACTIVEBORDERCOL); // no anim here because they pop in + } PGROUPPARENT->groupMembers.clear(); PGROUPPARENT->isGroup = false; PGROUPPARENT->recalcSizePosRecursive(); + + if (g_pCompositor->windowValidMapped(g_pCompositor->m_pLastWindow)) + g_pCompositor->m_pLastWindow->m_cRealBorderColor = CColor(g_pConfigManager->getInt("general:col.active_border")); } else { // if there is no parent, let's make one @@ -675,8 +687,14 @@ void CHyprDwindleLayout::toggleWindowGroup(CWindow* pWindow) { PPARENT->groupMembers = allChildren; - for (auto& c : PPARENT->groupMembers) + const auto GROUPINACTIVEBORDERCOL = CColor(g_pConfigManager->getInt("dwinle:col.group_border")); + for (auto& c : PPARENT->groupMembers) { c->pGroupParent = PPARENT; + c->pWindow->m_cRealBorderColor = GROUPINACTIVEBORDERCOL; + + if (c->pWindow == g_pCompositor->m_pLastWindow) + c->pWindow->m_cRealBorderColor = CColor(g_pConfigManager->getInt("dwindle:col.group_border_active")); + } PPARENT->groupMemberActive = 0; |
