From 44aeb1fc909ec9cb3e6b82a5397e9eec8839192b Mon Sep 17 00:00:00 2001 From: vaxerski <43317083+vaxerski@users.noreply.github.com> Date: Sun, 26 Jun 2022 22:15:06 +0200 Subject: added decoration:shadow_offset --- src/managers/AnimationManager.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/managers/AnimationManager.cpp') diff --git a/src/managers/AnimationManager.cpp b/src/managers/AnimationManager.cpp index 2ceefdd4..e8f1a1f1 100644 --- a/src/managers/AnimationManager.cpp +++ b/src/managers/AnimationManager.cpp @@ -47,7 +47,7 @@ void CAnimationManager::tick() { wlr_box WLRBOXPREV = {0,0,0,0}; if (PWINDOW) { - WLRBOXPREV = {(int)PWINDOW->m_vRealPosition.vec().x - (int)*PBORDERSIZE - 1, (int)PWINDOW->m_vRealPosition.vec().y - (int)*PBORDERSIZE - 1, (int)PWINDOW->m_vRealSize.vec().x + 2 * (int)*PBORDERSIZE + 2, (int)PWINDOW->m_vRealSize.vec().y + 2 * (int)*PBORDERSIZE + 2}; + WLRBOXPREV = PWINDOW->getFullWindowBoundingBox(); } else if (PWORKSPACE) { const auto PMONITOR = g_pCompositor->getMonitorFromID(PWORKSPACE->m_iMonitorID); WLRBOXPREV = {(int)PMONITOR->vecPosition.x, (int)PMONITOR->vecPosition.y, (int)PMONITOR->vecSize.x, (int)PMONITOR->vecSize.y}; -- cgit v1.2.3 From 3d48469cb43ac0609b112aea4e233276e04c4118 Mon Sep 17 00:00:00 2001 From: vaxerski <43317083+vaxerski@users.noreply.github.com> Date: Mon, 27 Jun 2022 00:25:37 +0200 Subject: fix decos with workspace offset --- src/managers/AnimationManager.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'src/managers/AnimationManager.cpp') diff --git a/src/managers/AnimationManager.cpp b/src/managers/AnimationManager.cpp index e8f1a1f1..61221938 100644 --- a/src/managers/AnimationManager.cpp +++ b/src/managers/AnimationManager.cpp @@ -150,8 +150,16 @@ void CAnimationManager::tick() { if (PWINDOW) { g_pHyprRenderer->damageWindow(PWINDOW); - for (auto& wd : PWINDOW->m_dWindowDecorations) { - wd->updateWindow(PWINDOW); + PWINDOW->updateWindowDecos(); + } else if (PWORKSPACE) { + for (auto& w : g_pCompositor->m_lWindows) { + if (!w.m_bIsMapped || w.m_bHidden) + continue; + + if (w.m_iWorkspaceID != PWORKSPACE->m_iID) + continue; + + w.updateWindowDecos(); } } break; -- cgit v1.2.3 From 13acfb1c306f863b695f1aa2f678445bb39f4239 Mon Sep 17 00:00:00 2001 From: vaxerski <43317083+vaxerski@users.noreply.github.com> Date: Wed, 29 Jun 2022 12:06:09 +0200 Subject: fix disabling in animationmanager --- src/managers/AnimationManager.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/managers/AnimationManager.cpp') diff --git a/src/managers/AnimationManager.cpp b/src/managers/AnimationManager.cpp index 61221938..2774ee85 100644 --- a/src/managers/AnimationManager.cpp +++ b/src/managers/AnimationManager.cpp @@ -67,7 +67,7 @@ void CAnimationManager::tick() { if (!deltazero(av->m_fValue, av->m_fGoal)) { // for disabled anims just warp - if (av->m_pEnabled == 0 || animationsDisabled) { + if (*av->m_pEnabled == 0 || animationsDisabled) { av->warp(); break; } @@ -92,7 +92,7 @@ void CAnimationManager::tick() { if (!deltazero(av->m_vValue, av->m_vGoal)) { // for disabled anims just warp - if (av->m_pEnabled == 0 || animationsDisabled) { + if (*av->m_pEnabled == 0 || animationsDisabled) { av->warp(); break; } @@ -117,7 +117,7 @@ void CAnimationManager::tick() { if (!deltazero(av->m_cValue, av->m_cGoal)) { // for disabled anims just warp - if (av->m_pEnabled == 0 || animationsDisabled) { + if (*av->m_pEnabled == 0 || animationsDisabled) { av->warp(); break; } -- cgit v1.2.3 From cfc1f6c211b055dc54b91e1ed94aef120c9c143c Mon Sep 17 00:00:00 2001 From: vaxerski <43317083+vaxerski@users.noreply.github.com> Date: Thu, 30 Jun 2022 12:54:58 +0200 Subject: optimize animationmanager --- src/managers/AnimationManager.cpp | 107 +++++++++++++++----------------------- 1 file changed, 43 insertions(+), 64 deletions(-) (limited to 'src/managers/AnimationManager.cpp') diff --git a/src/managers/AnimationManager.cpp b/src/managers/AnimationManager.cpp index 2774ee85..c26ea5f2 100644 --- a/src/managers/AnimationManager.cpp +++ b/src/managers/AnimationManager.cpp @@ -40,6 +40,16 @@ void CAnimationManager::tick() { // get speed const auto SPEED = *av->m_pSpeed == 0 ? *PANIMSPEED : *av->m_pSpeed; + // get the spent % (0 - 1) + const auto DURATIONPASSED = std::chrono::duration_cast(std::chrono::system_clock::now() - av->animationBegin).count(); + const float SPENT = std::clamp((DURATIONPASSED / 100.f) / SPEED, 0.f, 1.f); + + // first of all, check if we need to update it at all + if (SPENT >= 1.f) { + av->warp(); + continue; + } + // window stuff const auto PWINDOW = (CWindow*)av->m_pWindow; const auto PWORKSPACE = (CWorkspace*)av->m_pWorkspace; @@ -58,84 +68,53 @@ void CAnimationManager::tick() { // beziers are with a switch unforto // TODO: maybe do something cleaner - // get the spent % (0 - 1) - const auto DURATIONPASSED = std::chrono::duration_cast(std::chrono::system_clock::now() - av->animationBegin).count(); - const float SPENT = std::clamp((DURATIONPASSED / 100.f) / SPEED, 0.f, 1.f); - switch (av->m_eVarType) { case AVARTYPE_FLOAT: { - if (!deltazero(av->m_fValue, av->m_fGoal)) { - - // for disabled anims just warp - if (*av->m_pEnabled == 0 || animationsDisabled) { - av->warp(); - break; - } - - const auto DELTA = av->m_fGoal - av->m_fBegun; - const auto BEZIER = m_mBezierCurves.find(*av->m_pBezier); + // for disabled anims just warp + if (*av->m_pEnabled == 0 || animationsDisabled) { + av->warp(); + break; + } - if (BEZIER != m_mBezierCurves.end()) - av->m_fValue = av->m_fBegun + BEZIER->second.getYForPoint(SPENT) * DELTA; - else - av->m_fValue = av->m_fBegun + DEFAULTBEZIER->second.getYForPoint(SPENT) * DELTA; + const auto DELTA = av->m_fGoal - av->m_fBegun; + const auto BEZIER = m_mBezierCurves.find(*av->m_pBezier); - if (SPENT >= 1.f) { - av->warp(); - } - } else { - continue; // dont process - } + if (BEZIER != m_mBezierCurves.end()) + av->m_fValue = av->m_fBegun + BEZIER->second.getYForPoint(SPENT) * DELTA; + else + av->m_fValue = av->m_fBegun + DEFAULTBEZIER->second.getYForPoint(SPENT) * DELTA; break; } case AVARTYPE_VECTOR: { - if (!deltazero(av->m_vValue, av->m_vGoal)) { - - // for disabled anims just warp - if (*av->m_pEnabled == 0 || animationsDisabled) { - av->warp(); - break; - } - - const auto DELTA = av->m_vGoal - av->m_vBegun; - const auto BEZIER = m_mBezierCurves.find(*av->m_pBezier); + // for disabled anims just warp + if (*av->m_pEnabled == 0 || animationsDisabled) { + av->warp(); + break; + } - if (BEZIER != m_mBezierCurves.end()) - av->m_vValue = av->m_vBegun + DELTA * BEZIER->second.getYForPoint(SPENT); - else - av->m_vValue = av->m_vBegun + DELTA * DEFAULTBEZIER->second.getYForPoint(SPENT); + const auto DELTA = av->m_vGoal - av->m_vBegun; + const auto BEZIER = m_mBezierCurves.find(*av->m_pBezier); - if (SPENT >= 1.f) { - av->warp(); - } - } else { - continue; // dont process - } + if (BEZIER != m_mBezierCurves.end()) + av->m_vValue = av->m_vBegun + DELTA * BEZIER->second.getYForPoint(SPENT); + else + av->m_vValue = av->m_vBegun + DELTA * DEFAULTBEZIER->second.getYForPoint(SPENT); break; } case AVARTYPE_COLOR: { - if (!deltazero(av->m_cValue, av->m_cGoal)) { - - // for disabled anims just warp - if (*av->m_pEnabled == 0 || animationsDisabled) { - av->warp(); - break; - } - - const auto DELTA = av->m_cGoal - av->m_cBegun; - const auto BEZIER = m_mBezierCurves.find(*av->m_pBezier); + // for disabled anims just warp + if (*av->m_pEnabled == 0 || animationsDisabled) { + av->warp(); + break; + } - if (BEZIER != m_mBezierCurves.end()) - av->m_cValue = av->m_cBegun + DELTA * BEZIER->second.getYForPoint(SPENT); - else - av->m_cValue = av->m_cBegun + DELTA * DEFAULTBEZIER->second.getYForPoint(SPENT); + const auto DELTA = av->m_cGoal - av->m_cBegun; + const auto BEZIER = m_mBezierCurves.find(*av->m_pBezier); - if (SPENT >= 1.f) { - av->warp(); - } - } else { - continue; // dont process - } + if (BEZIER != m_mBezierCurves.end()) + av->m_cValue = av->m_cBegun + DELTA * BEZIER->second.getYForPoint(SPENT); + else + av->m_cValue = av->m_cBegun + DELTA * DEFAULTBEZIER->second.getYForPoint(SPENT); break; } default: { -- cgit v1.2.3 From d1564299d23b52e6297fa4542ce42e4a54c28cbc Mon Sep 17 00:00:00 2001 From: vaxerski <43317083+vaxerski@users.noreply.github.com> Date: Thu, 30 Jun 2022 13:11:10 +0200 Subject: fix minor bug with new anim optimization --- src/managers/AnimationManager.cpp | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) (limited to 'src/managers/AnimationManager.cpp') diff --git a/src/managers/AnimationManager.cpp b/src/managers/AnimationManager.cpp index c26ea5f2..5e3df81f 100644 --- a/src/managers/AnimationManager.cpp +++ b/src/managers/AnimationManager.cpp @@ -37,6 +37,11 @@ void CAnimationManager::tick() { DEFAULTBEZIER = m_mBezierCurves.find("default"); for (auto& av : m_lAnimatedVariables) { + + // first of all, check if we need to update it at all + if (!av->isBeingAnimated()) + continue; + // get speed const auto SPEED = *av->m_pSpeed == 0 ? *PANIMSPEED : *av->m_pSpeed; @@ -44,12 +49,6 @@ void CAnimationManager::tick() { const auto DURATIONPASSED = std::chrono::duration_cast(std::chrono::system_clock::now() - av->animationBegin).count(); const float SPENT = std::clamp((DURATIONPASSED / 100.f) / SPEED, 0.f, 1.f); - // first of all, check if we need to update it at all - if (SPENT >= 1.f) { - av->warp(); - continue; - } - // window stuff const auto PWINDOW = (CWindow*)av->m_pWindow; const auto PWORKSPACE = (CWorkspace*)av->m_pWorkspace; @@ -76,6 +75,11 @@ void CAnimationManager::tick() { break; } + if (SPENT >= 1.f) { + av->warp(); + break; + } + const auto DELTA = av->m_fGoal - av->m_fBegun; const auto BEZIER = m_mBezierCurves.find(*av->m_pBezier); @@ -92,6 +96,11 @@ void CAnimationManager::tick() { break; } + if (SPENT >= 1.f) { + av->warp(); + break; + } + const auto DELTA = av->m_vGoal - av->m_vBegun; const auto BEZIER = m_mBezierCurves.find(*av->m_pBezier); @@ -108,6 +117,11 @@ void CAnimationManager::tick() { break; } + if (SPENT >= 1.f) { + av->warp(); + break; + } + const auto DELTA = av->m_cGoal - av->m_cBegun; const auto BEZIER = m_mBezierCurves.find(*av->m_pBezier); -- cgit v1.2.3 From 328b3fa4bc4f3776f2128f84709556569c4824d9 Mon Sep 17 00:00:00 2001 From: vaxerski <43317083+vaxerski@users.noreply.github.com> Date: Thu, 30 Jun 2022 15:44:26 +0200 Subject: mordernize pointers --- src/managers/AnimationManager.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/managers/AnimationManager.cpp') diff --git a/src/managers/AnimationManager.cpp b/src/managers/AnimationManager.cpp index 5e3df81f..e48b4d1e 100644 --- a/src/managers/AnimationManager.cpp +++ b/src/managers/AnimationManager.cpp @@ -145,14 +145,14 @@ void CAnimationManager::tick() { g_pHyprRenderer->damageWindow(PWINDOW); PWINDOW->updateWindowDecos(); } else if (PWORKSPACE) { - for (auto& w : g_pCompositor->m_lWindows) { - if (!w.m_bIsMapped || w.m_bHidden) + for (auto& w : g_pCompositor->m_vWindows) { + if (!w->m_bIsMapped || w->m_bHidden) continue; - if (w.m_iWorkspaceID != PWORKSPACE->m_iID) + if (w->m_iWorkspaceID != PWORKSPACE->m_iID) continue; - w.updateWindowDecos(); + w->updateWindowDecos(); } } break; -- cgit v1.2.3