renderer: improve zoom in anims (#11453)

Removes `animations:first_launch_animation` as it's useless now
This commit is contained in:
Vaxry
2025-08-16 20:02:15 +01:00
committed by GitHub
parent 78c9e2080c
commit 3d4dc19412
6 changed files with 13 additions and 36 deletions

View File

@@ -380,12 +380,6 @@ inline static const std::vector<SConfigOptionDescription> CONFIG_OPTIONS = {
.type = CONFIG_OPTION_BOOL, .type = CONFIG_OPTION_BOOL,
.data = SConfigOptionDescription::SBoolData{true}, .data = SConfigOptionDescription::SBoolData{true},
}, },
SConfigOptionDescription{
.value = "animations:first_launch_animation",
.description = "enable first launch animation",
.type = CONFIG_OPTION_BOOL,
.data = SConfigOptionDescription::SBoolData{true},
},
SConfigOptionDescription{ SConfigOptionDescription{
.value = "animations:workspace_wraparound", .value = "animations:workspace_wraparound",
.description = "changes the direction of slide animations between the first and last workspaces", .description = "changes the direction of slide animations between the first and last workspaces",

View File

@@ -619,7 +619,6 @@ CConfigManager::CConfigManager() {
registerConfigVar("master:always_keep_position", Hyprlang::INT{0}); registerConfigVar("master:always_keep_position", Hyprlang::INT{0});
registerConfigVar("animations:enabled", Hyprlang::INT{1}); registerConfigVar("animations:enabled", Hyprlang::INT{1});
registerConfigVar("animations:first_launch_animation", Hyprlang::INT{1});
registerConfigVar("animations:workspace_wraparound", Hyprlang::INT{0}); registerConfigVar("animations:workspace_wraparound", Hyprlang::INT{0});
registerConfigVar("input:follow_mouse", Hyprlang::INT{1}); registerConfigVar("input:follow_mouse", Hyprlang::INT{1});
@@ -985,6 +984,7 @@ void CConfigManager::setDefaultAnimationVars() {
m_animationTree.createNode("borderangle", "global"); m_animationTree.createNode("borderangle", "global");
m_animationTree.createNode("workspaces", "global"); m_animationTree.createNode("workspaces", "global");
m_animationTree.createNode("zoomFactor", "global"); m_animationTree.createNode("zoomFactor", "global");
m_animationTree.createNode("monitorAdded", "global");
// layer // layer
m_animationTree.createNode("layersIn", "layers"); m_animationTree.createNode("layersIn", "layers");

View File

@@ -49,6 +49,8 @@ CMonitor::CMonitor(SP<Aquamarine::IOutput> output_) : m_state(this), m_output(ou
static auto PZOOMFACTOR = CConfigValue<Hyprlang::FLOAT>("cursor:zoom_factor"); static auto PZOOMFACTOR = CConfigValue<Hyprlang::FLOAT>("cursor:zoom_factor");
g_pAnimationManager->createAnimation(*PZOOMFACTOR, m_cursorZoom, g_pConfigManager->getAnimationPropertyConfig("zoomFactor"), AVARDAMAGE_NONE); g_pAnimationManager->createAnimation(*PZOOMFACTOR, m_cursorZoom, g_pConfigManager->getAnimationPropertyConfig("zoomFactor"), AVARDAMAGE_NONE);
m_cursorZoom->setUpdateCallback([this](auto) { g_pHyprRenderer->damageMonitor(m_self.lock()); }); 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() { CMonitor::~CMonitor() {
@@ -61,6 +63,8 @@ void CMonitor::onConnect(bool noRule) {
EMIT_HOOK_EVENT("preMonitorAdded", m_self.lock()); EMIT_HOOK_EVENT("preMonitorAdded", m_self.lock());
CScopeGuard x = {[]() { g_pCompositor->arrangeMonitors(); }}; CScopeGuard x = {[]() { g_pCompositor->arrangeMonitors(); }};
m_zoomAnimProgress->setValueAndWarp(0.F);
g_pEventLoopManager->doLater([] { g_pConfigManager->ensurePersistentWorkspacesPresent(); }); g_pEventLoopManager->doLater([] { g_pConfigManager->ensurePersistentWorkspacesPresent(); });
m_listeners.frame = m_output->events.frame.listen([this] { m_listeners.frame = m_output->events.frame.listen([this] {
@@ -89,6 +93,9 @@ void CMonitor::onConnect(bool noRule) {
else else
PROTO::presentation->onPresented(m_self.lock(), Time::fromTimespec(event.when), event.refresh, event.seq, event.flags); 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(); m_frameScheduler->onPresented();
}); });

View File

@@ -183,6 +183,9 @@ class CMonitor {
PHLANIMVAR<float> m_cursorZoom; PHLANIMVAR<float> m_cursorZoom;
// for initial zoom anim
PHLANIMVAR<float> m_zoomAnimProgress;
struct { struct {
bool canTear = false; bool canTear = false;
bool nextRenderTorn = false; bool nextRenderTorn = false;

View File

@@ -1186,8 +1186,6 @@ void CHyprRenderer::renderMonitor(PHLMONITOR pMonitor, bool commit) {
static auto PDAMAGEBLINK = CConfigValue<Hyprlang::INT>("debug:damage_blink"); static auto PDAMAGEBLINK = CConfigValue<Hyprlang::INT>("debug:damage_blink");
static auto PDIRECTSCANOUT = CConfigValue<Hyprlang::INT>("render:direct_scanout"); static auto PDIRECTSCANOUT = CConfigValue<Hyprlang::INT>("render:direct_scanout");
static auto PVFR = CConfigValue<Hyprlang::INT>("misc:vfr"); static auto PVFR = CConfigValue<Hyprlang::INT>("misc:vfr");
static auto PANIMENABLED = CConfigValue<Hyprlang::INT>("animations:enabled");
static auto PFIRSTLAUNCHANIM = CConfigValue<Hyprlang::INT>("animations:first_launch_animation");
static auto PTEARINGENABLED = CConfigValue<Hyprlang::INT>("general:allow_tearing"); static auto PTEARINGENABLED = CConfigValue<Hyprlang::INT>("general:allow_tearing");
static int damageBlinkCleanup = 0; // because double-buffered static int damageBlinkCleanup = 0; // because double-buffered
@@ -1202,28 +1200,6 @@ void CHyprRenderer::renderMonitor(PHLMONITOR pMonitor, bool commit) {
if (!*PDAMAGEBLINK) if (!*PDAMAGEBLINK)
damageBlinkCleanup = 0; 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) { if (*PDEBUGOVERLAY == 1) {
renderStart = std::chrono::high_resolution_clock::now(); renderStart = std::chrono::high_resolution_clock::now();
g_pDebugOverlay->frameData(pMonitor); g_pDebugOverlay->frameData(pMonitor);
@@ -1334,11 +1310,10 @@ void CHyprRenderer::renderMonitor(PHLMONITOR pMonitor, bool commit) {
else else
g_pHyprOpenGL->m_renderData.mouseZoomFactor = 1.f; g_pHyprOpenGL->m_renderData.mouseZoomFactor = 1.f;
if (zoomInFactorFirstLaunch > 1.f) { if (pMonitor->m_zoomAnimProgress->isBeingAnimated()) {
g_pHyprOpenGL->m_renderData.mouseZoomFactor = zoomInFactorFirstLaunch; 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.mouseZoomUseMouse = false;
g_pHyprOpenGL->m_renderData.useNearestNeighbor = false; g_pHyprOpenGL->m_renderData.useNearestNeighbor = false;
pMonitor->m_forceFullFrames = 10;
} }
CRegion damage, finalDamage; CRegion damage, finalDamage;

View File

@@ -104,8 +104,6 @@ class CHyprRenderer {
wl_event_source* m_crashingLoop = nullptr; wl_event_source* m_crashingLoop = nullptr;
wl_event_source* m_cursorTicker = nullptr; wl_event_source* m_cursorTicker = nullptr;
CTimer m_renderTimer;
std::vector<CHLBufferReference> m_usedAsyncBuffers; std::vector<CHLBufferReference> m_usedAsyncBuffers;
struct { struct {