From 72cbb7906a0c65eb62b1d5ddb0769dc0391f37e6 Mon Sep 17 00:00:00 2001 From: Virt <41426325+VirtCode@users.noreply.github.com> Date: Sat, 25 Oct 2025 19:53:01 +0200 Subject: [PATCH] layer-shell: fix fullscreen alpha when changing layers (#12124) * layer-shell: fix fullscreen alpha when changing layers * this is intended * ooops * ooops #2 --- src/desktop/LayerSurface.cpp | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/src/desktop/LayerSurface.cpp b/src/desktop/LayerSurface.cpp index 5d2ab9a8..6278078d 100644 --- a/src/desktop/LayerSurface.cpp +++ b/src/desktop/LayerSurface.cpp @@ -289,18 +289,32 @@ void CLayerSurface::onCommit() { g_pHyprRenderer->damageBox(geomFixed); if (m_layerSurface->m_current.committed != 0) { - if (m_layerSurface->m_current.committed & CLayerShellResource::eCommittedState::STATE_LAYER) { + if (m_layerSurface->m_current.committed & CLayerShellResource::eCommittedState::STATE_LAYER && m_layerSurface->m_current.layer != m_layer) { for (auto it = PMONITOR->m_layerSurfaceLayers[m_layer].begin(); it != PMONITOR->m_layerSurfaceLayers[m_layer].end(); it++) { if (*it == m_self) { - if (m_layerSurface->m_current.layer == m_layer) - break; PMONITOR->m_layerSurfaceLayers[m_layerSurface->m_current.layer].emplace_back(*it); PMONITOR->m_layerSurfaceLayers[m_layer].erase(it); break; } } + // update alpha when window is in fullscreen + auto PWORKSPACE = PMONITOR->m_activeSpecialWorkspace ? PMONITOR->m_activeSpecialWorkspace : PMONITOR->m_activeWorkspace; + if (PWORKSPACE && PWORKSPACE->m_fullscreenMode == FSMODE_FULLSCREEN) { + // warp if switching render layer so we don't see glitches and have clean fade + if ((m_layer == ZWLR_LAYER_SHELL_V1_LAYER_BACKGROUND || m_layer == ZWLR_LAYER_SHELL_V1_LAYER_BOTTOM) && + (m_layerSurface->m_current.layer == ZWLR_LAYER_SHELL_V1_LAYER_TOP || m_layerSurface->m_current.layer == ZWLR_LAYER_SHELL_V1_LAYER_OVERLAY)) + m_alpha->setValueAndWarp(0.f); + + // from overlay to top + if (m_layer == ZWLR_LAYER_SHELL_V1_LAYER_OVERLAY && m_layerSurface->m_current.layer == ZWLR_LAYER_SHELL_V1_LAYER_TOP) + *m_alpha = 0.f; + // to overlay + if (m_layerSurface->m_current.layer == ZWLR_LAYER_SHELL_V1_LAYER_OVERLAY) + *m_alpha = 1.f; + } + m_layer = m_layerSurface->m_current.layer; if (m_layer == ZWLR_LAYER_SHELL_V1_LAYER_BACKGROUND || m_layer == ZWLR_LAYER_SHELL_V1_LAYER_BOTTOM)