From 3d4dc19412921864c25cd25e0cbffd6e1693c43c Mon Sep 17 00:00:00 2001 From: Vaxry <43317083+vaxerski@users.noreply.github.com> Date: Sat, 16 Aug 2025 20:02:15 +0100 Subject: [PATCH] renderer: improve zoom in anims (#11453) Removes `animations:first_launch_animation` as it's useless now --- src/config/ConfigDescriptions.hpp | 6 ------ src/config/ConfigManager.cpp | 2 +- src/helpers/Monitor.cpp | 7 +++++++ src/helpers/Monitor.hpp | 3 +++ src/render/Renderer.cpp | 29 ++--------------------------- src/render/Renderer.hpp | 2 -- 6 files changed, 13 insertions(+), 36 deletions(-) diff --git a/src/config/ConfigDescriptions.hpp b/src/config/ConfigDescriptions.hpp index 2d9582f65..23252c914 100644 --- a/src/config/ConfigDescriptions.hpp +++ b/src/config/ConfigDescriptions.hpp @@ -380,12 +380,6 @@ inline static const std::vector CONFIG_OPTIONS = { .type = CONFIG_OPTION_BOOL, .data = SConfigOptionDescription::SBoolData{true}, }, - SConfigOptionDescription{ - .value = "animations:first_launch_animation", - .description = "enable first launch animation", - .type = CONFIG_OPTION_BOOL, - .data = SConfigOptionDescription::SBoolData{true}, - }, SConfigOptionDescription{ .value = "animations:workspace_wraparound", .description = "changes the direction of slide animations between the first and last workspaces", diff --git a/src/config/ConfigManager.cpp b/src/config/ConfigManager.cpp index 4427906fd..2d817534c 100644 --- a/src/config/ConfigManager.cpp +++ b/src/config/ConfigManager.cpp @@ -619,7 +619,6 @@ CConfigManager::CConfigManager() { registerConfigVar("master:always_keep_position", Hyprlang::INT{0}); registerConfigVar("animations:enabled", Hyprlang::INT{1}); - registerConfigVar("animations:first_launch_animation", Hyprlang::INT{1}); registerConfigVar("animations:workspace_wraparound", Hyprlang::INT{0}); registerConfigVar("input:follow_mouse", Hyprlang::INT{1}); @@ -985,6 +984,7 @@ void CConfigManager::setDefaultAnimationVars() { m_animationTree.createNode("borderangle", "global"); m_animationTree.createNode("workspaces", "global"); m_animationTree.createNode("zoomFactor", "global"); + m_animationTree.createNode("monitorAdded", "global"); // layer m_animationTree.createNode("layersIn", "layers"); diff --git a/src/helpers/Monitor.cpp b/src/helpers/Monitor.cpp index fa0965b82..93a798a0f 100644 --- a/src/helpers/Monitor.cpp +++ b/src/helpers/Monitor.cpp @@ -49,6 +49,8 @@ CMonitor::CMonitor(SP output_) : m_state(this), m_output(ou static auto PZOOMFACTOR = CConfigValue("cursor:zoom_factor"); g_pAnimationManager->createAnimation(*PZOOMFACTOR, m_cursorZoom, g_pConfigManager->getAnimationPropertyConfig("zoomFactor"), AVARDAMAGE_NONE); m_cursorZoom->setUpdateCallback([this](auto) { g_pHyprRenderer->damageMonitor(m_self.lock()); }); + g_pAnimationManager->createAnimation(0.F, m_zoomAnimProgress, g_pConfigManager->getAnimationPropertyConfig("monitorAdded"), AVARDAMAGE_NONE); + m_zoomAnimProgress->setUpdateCallback([this](auto) { g_pHyprRenderer->damageMonitor(m_self.lock()); }); } CMonitor::~CMonitor() { @@ -61,6 +63,8 @@ void CMonitor::onConnect(bool noRule) { EMIT_HOOK_EVENT("preMonitorAdded", m_self.lock()); CScopeGuard x = {[]() { g_pCompositor->arrangeMonitors(); }}; + m_zoomAnimProgress->setValueAndWarp(0.F); + g_pEventLoopManager->doLater([] { g_pConfigManager->ensurePersistentWorkspacesPresent(); }); m_listeners.frame = m_output->events.frame.listen([this] { @@ -89,6 +93,9 @@ void CMonitor::onConnect(bool noRule) { else PROTO::presentation->onPresented(m_self.lock(), Time::fromTimespec(event.when), event.refresh, event.seq, event.flags); + if (m_zoomAnimProgress->goal() == 0.F) + *m_zoomAnimProgress = 1.F; + m_frameScheduler->onPresented(); }); diff --git a/src/helpers/Monitor.hpp b/src/helpers/Monitor.hpp index f2b7e1ed5..a857cd49b 100644 --- a/src/helpers/Monitor.hpp +++ b/src/helpers/Monitor.hpp @@ -183,6 +183,9 @@ class CMonitor { PHLANIMVAR m_cursorZoom; + // for initial zoom anim + PHLANIMVAR m_zoomAnimProgress; + struct { bool canTear = false; bool nextRenderTorn = false; diff --git a/src/render/Renderer.cpp b/src/render/Renderer.cpp index dfafbeade..326f71bb4 100644 --- a/src/render/Renderer.cpp +++ b/src/render/Renderer.cpp @@ -1186,8 +1186,6 @@ void CHyprRenderer::renderMonitor(PHLMONITOR pMonitor, bool commit) { static auto PDAMAGEBLINK = CConfigValue("debug:damage_blink"); static auto PDIRECTSCANOUT = CConfigValue("render:direct_scanout"); static auto PVFR = CConfigValue("misc:vfr"); - static auto PANIMENABLED = CConfigValue("animations:enabled"); - static auto PFIRSTLAUNCHANIM = CConfigValue("animations:first_launch_animation"); static auto PTEARINGENABLED = CConfigValue("general:allow_tearing"); static int damageBlinkCleanup = 0; // because double-buffered @@ -1202,28 +1200,6 @@ void CHyprRenderer::renderMonitor(PHLMONITOR pMonitor, bool commit) { if (!*PDAMAGEBLINK) damageBlinkCleanup = 0; - static bool firstLaunch = true; - static bool firstLaunchAnimActive = *PFIRSTLAUNCHANIM; - - float zoomInFactorFirstLaunch = 1.f; - - if (firstLaunch) { - firstLaunch = false; - m_renderTimer.reset(); - } - - if (m_renderTimer.getSeconds() < 1.5f && firstLaunchAnimActive) { // TODO: make the animation system more damage-flexible so that this can be migrated to there - if (!*PANIMENABLED) { - zoomInFactorFirstLaunch = 1.f; - firstLaunchAnimActive = false; - } else { - zoomInFactorFirstLaunch = 2.f - g_pAnimationManager->getBezier("default")->getYForPoint(m_renderTimer.getSeconds() / 1.5); - damageMonitor(pMonitor); - } - } else { - firstLaunchAnimActive = false; - } - if (*PDEBUGOVERLAY == 1) { renderStart = std::chrono::high_resolution_clock::now(); g_pDebugOverlay->frameData(pMonitor); @@ -1334,11 +1310,10 @@ void CHyprRenderer::renderMonitor(PHLMONITOR pMonitor, bool commit) { else g_pHyprOpenGL->m_renderData.mouseZoomFactor = 1.f; - if (zoomInFactorFirstLaunch > 1.f) { - g_pHyprOpenGL->m_renderData.mouseZoomFactor = zoomInFactorFirstLaunch; + if (pMonitor->m_zoomAnimProgress->isBeingAnimated()) { + g_pHyprOpenGL->m_renderData.mouseZoomFactor = 2.0 - pMonitor->m_zoomAnimProgress->value(); // 2x zoom -> 1x zoom g_pHyprOpenGL->m_renderData.mouseZoomUseMouse = false; g_pHyprOpenGL->m_renderData.useNearestNeighbor = false; - pMonitor->m_forceFullFrames = 10; } CRegion damage, finalDamage; diff --git a/src/render/Renderer.hpp b/src/render/Renderer.hpp index 4018fe408..b898e37c6 100644 --- a/src/render/Renderer.hpp +++ b/src/render/Renderer.hpp @@ -104,8 +104,6 @@ class CHyprRenderer { wl_event_source* m_crashingLoop = nullptr; wl_event_source* m_cursorTicker = nullptr; - CTimer m_renderTimer; - std::vector m_usedAsyncBuffers; struct {