From 1cc1a46c2e154a27750b81307040d3bf7ff0f64f Mon Sep 17 00:00:00 2001 From: Vaxry Date: Sun, 22 Dec 2024 16:04:10 +0000 Subject: [PATCH] core: fade in windows when they are brought from invisible workspaces --- src/Compositor.cpp | 6 ++++++ src/desktop/Window.cpp | 7 +++++++ src/desktop/Window.hpp | 1 + src/render/Renderer.cpp | 2 +- 4 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/Compositor.cpp b/src/Compositor.cpp index 5e8c80481..9bcbdb0f7 100644 --- a/src/Compositor.cpp +++ b/src/Compositor.cpp @@ -2649,6 +2649,7 @@ void CCompositor::moveWindowToWorkspaceSafe(PHLWINDOW pWindow, PHLWORKSPACE pWor const bool FULLSCREEN = pWindow->isFullscreen(); const auto FULLSCREENMODE = pWindow->m_sFullscreenState.internal; + const bool WASVISIBLE = pWindow->m_pWorkspace && pWindow->m_pWorkspace->isVisible(); if (FULLSCREEN) setWindowFullscreenInternal(pWindow, FSMODE_NONE); @@ -2716,6 +2717,11 @@ void CCompositor::moveWindowToWorkspaceSafe(PHLWINDOW pWindow, PHLWORKSPACE pWor if (pWindow->m_pWorkspace) pWindow->m_pWorkspace->updateWindows(); g_pCompositor->updateSuspendedStates(); + + if (!WASVISIBLE && pWindow->m_pWorkspace && pWindow->m_pWorkspace->isVisible()) { + pWindow->m_fMovingFromWorkspaceAlpha.setValueAndWarp(0.F); + pWindow->m_fMovingFromWorkspaceAlpha = 1.F; + } } PHLWINDOW CCompositor::getForceFocus() { diff --git a/src/desktop/Window.cpp b/src/desktop/Window.cpp index 696bfc5b0..871e73ed8 100644 --- a/src/desktop/Window.cpp +++ b/src/desktop/Window.cpp @@ -33,6 +33,7 @@ PHLWINDOW CWindow::create(SP surface) { pWindow->m_cRealShadowColor.create(g_pConfigManager->getAnimationPropertyConfig("fadeShadow"), pWindow, AVARDAMAGE_SHADOW); pWindow->m_fDimPercent.create(g_pConfigManager->getAnimationPropertyConfig("fadeDim"), pWindow, AVARDAMAGE_ENTIRE); pWindow->m_fMovingToWorkspaceAlpha.create(g_pConfigManager->getAnimationPropertyConfig("fadeOut"), pWindow, AVARDAMAGE_ENTIRE); + pWindow->m_fMovingFromWorkspaceAlpha.create(g_pConfigManager->getAnimationPropertyConfig("fadeIn"), pWindow, AVARDAMAGE_ENTIRE); pWindow->addWindowDeco(std::make_unique(pWindow)); pWindow->addWindowDeco(std::make_unique(pWindow)); @@ -55,6 +56,7 @@ PHLWINDOW CWindow::create(SP resource) { pWindow->m_cRealShadowColor.create(g_pConfigManager->getAnimationPropertyConfig("fadeShadow"), pWindow, AVARDAMAGE_SHADOW); pWindow->m_fDimPercent.create(g_pConfigManager->getAnimationPropertyConfig("fadeDim"), pWindow, AVARDAMAGE_ENTIRE); pWindow->m_fMovingToWorkspaceAlpha.create(g_pConfigManager->getAnimationPropertyConfig("fadeOut"), pWindow, AVARDAMAGE_ENTIRE); + pWindow->m_fMovingFromWorkspaceAlpha.create(g_pConfigManager->getAnimationPropertyConfig("fadeIn"), pWindow, AVARDAMAGE_ENTIRE); pWindow->addWindowDeco(std::make_unique(pWindow)); pWindow->addWindowDeco(std::make_unique(pWindow)); @@ -504,6 +506,7 @@ void CWindow::onUnmap() { m_cRealShadowColor.setCallbackOnEnd(unregisterVar); m_fDimPercent.setCallbackOnEnd(unregisterVar); m_fMovingToWorkspaceAlpha.setCallbackOnEnd(unregisterVar); + m_fMovingFromWorkspaceAlpha.setCallbackOnEnd(unregisterVar); m_vRealSize.setCallbackOnBegin(nullptr); @@ -547,6 +550,7 @@ void CWindow::onMap() { m_cRealShadowColor.resetAllCallbacks(); m_fDimPercent.resetAllCallbacks(); m_fMovingToWorkspaceAlpha.resetAllCallbacks(); + m_fMovingFromWorkspaceAlpha.resetAllCallbacks(); m_vRealPosition.registerVar(); m_vRealSize.registerVar(); @@ -557,12 +561,15 @@ void CWindow::onMap() { m_cRealShadowColor.registerVar(); m_fDimPercent.registerVar(); m_fMovingToWorkspaceAlpha.registerVar(); + m_fMovingFromWorkspaceAlpha.registerVar(); m_fBorderAngleAnimationProgress.setCallbackOnEnd([&](void* ptr) { onBorderAngleAnimEnd(ptr); }, false); m_fBorderAngleAnimationProgress.setValueAndWarp(0.f); m_fBorderAngleAnimationProgress = 1.f; + m_fMovingFromWorkspaceAlpha.setValueAndWarp(1.F); + g_pCompositor->m_vWindowFocusHistory.push_back(m_pSelf); m_vReportedSize = m_vPendingReportedSize; diff --git a/src/desktop/Window.hpp b/src/desktop/Window.hpp index 7b2cfbdfd..6ed9a5253 100644 --- a/src/desktop/Window.hpp +++ b/src/desktop/Window.hpp @@ -336,6 +336,7 @@ class CWindow { // for alpha CAnimatedVariable m_fActiveInactiveAlpha; + CAnimatedVariable m_fMovingFromWorkspaceAlpha; // animated shadow color CAnimatedVariable m_cRealShadowColor; diff --git a/src/render/Renderer.cpp b/src/render/Renderer.cpp index 4edd5a0ce..c873842b0 100644 --- a/src/render/Renderer.cpp +++ b/src/render/Renderer.cpp @@ -597,7 +597,7 @@ void CHyprRenderer::renderWindow(PHLWINDOW pWindow, PHLMONITOR pMonitor, timespe renderdata.surface = pWindow->m_pWLSurface->resource(); renderdata.dontRound = pWindow->isEffectiveInternalFSMode(FSMODE_FULLSCREEN) || pWindow->m_sWindowData.noRounding.valueOrDefault(); renderdata.fadeAlpha = pWindow->m_fAlpha.value() * (pWindow->m_bPinned || USE_WORKSPACE_FADE_ALPHA ? 1.f : PWORKSPACE->m_fAlpha.value()) * - (USE_WORKSPACE_FADE_ALPHA ? pWindow->m_fMovingToWorkspaceAlpha.value() : 1.F); + (USE_WORKSPACE_FADE_ALPHA ? pWindow->m_fMovingToWorkspaceAlpha.value() : 1.F) * pWindow->m_fMovingFromWorkspaceAlpha.value(); renderdata.alpha = pWindow->m_fActiveInactiveAlpha.value(); renderdata.decorate = decorate && !pWindow->m_bX11DoesntWantBorders && !pWindow->isEffectiveInternalFSMode(FSMODE_FULLSCREEN); renderdata.rounding = ignoreAllGeometry || renderdata.dontRound ? 0 : pWindow->rounding() * pMonitor->scale;