diff options
author | Vaxry <[email protected]> | 2024-03-25 16:08:55 +0000 |
---|---|---|
committer | Vaxry <[email protected]> | 2024-03-25 16:09:02 +0000 |
commit | ca17a89d86b73f37019c4cc0c7087303adbcc1f9 (patch) | |
tree | edbaabbc0a73109465228f7d5270e5163c6b6ca6 | |
parent | 356414639fc06ace7045236ec41d673342981057 (diff) | |
download | Hyprland-ca17a89d86b73f37019c4cc0c7087303adbcc1f9.tar.gz Hyprland-ca17a89d86b73f37019c4cc0c7087303adbcc1f9.zip |
renderer: allow blurring ls popups
-rw-r--r-- | src/config/ConfigManager.cpp | 3 | ||||
-rw-r--r-- | src/desktop/Popup.cpp | 9 | ||||
-rw-r--r-- | src/desktop/Window.cpp | 10 | ||||
-rw-r--r-- | src/desktop/Window.hpp | 1 | ||||
-rw-r--r-- | src/helpers/WLClasses.cpp | 9 | ||||
-rw-r--r-- | src/helpers/WLClasses.hpp | 2 | ||||
-rw-r--r-- | src/render/OpenGL.cpp | 21 | ||||
-rw-r--r-- | src/render/Renderer.cpp | 52 |
8 files changed, 85 insertions, 22 deletions
diff --git a/src/config/ConfigManager.cpp b/src/config/ConfigManager.cpp index 11159131..d13b871d 100644 --- a/src/config/ConfigManager.cpp +++ b/src/config/ConfigManager.cpp @@ -1906,7 +1906,8 @@ bool windowRuleValid(const std::string& RULE) { } bool layerRuleValid(const std::string& RULE) { - return RULE == "noanim" || RULE == "blur" || RULE.starts_with("ignorealpha") || RULE.starts_with("ignorezero") || RULE.starts_with("xray") || RULE.starts_with("animation"); + return RULE == "noanim" || RULE == "blur" || RULE == "blurpopups" || RULE.starts_with("ignorealpha") || RULE.starts_with("ignorezero") || RULE.starts_with("xray") || + RULE.starts_with("animation"); } std::optional<std::string> CConfigManager::handleWindowRule(const std::string& command, const std::string& value) { diff --git a/src/desktop/Popup.cpp b/src/desktop/Popup.cpp index 98d5881a..77e486fd 100644 --- a/src/desktop/Popup.cpp +++ b/src/desktop/Popup.cpp @@ -117,6 +117,9 @@ void CPopup::onMap() { unconstrain(); sendScale(); + + if (m_pLayerOwner && m_pLayerOwner->layer < ZWLR_LAYER_SHELL_V1_LAYER_TOP) + g_pHyprOpenGL->markBlurDirtyForMonitor(g_pCompositor->getMonitorFromID(m_pLayerOwner->layer)); } void CPopup::onUnmap() { @@ -131,6 +134,9 @@ void CPopup::onUnmap() { m_pSubsurfaceHead.reset(); g_pInputManager->simulateMouseMovement(); + + if (m_pLayerOwner && m_pLayerOwner->layer < ZWLR_LAYER_SHELL_V1_LAYER_TOP) + g_pHyprOpenGL->markBlurDirtyForMonitor(g_pCompositor->getMonitorFromID(m_pLayerOwner->layer)); } void CPopup::onCommit(bool ignoreSiblings) { @@ -158,6 +164,9 @@ void CPopup::onCommit(bool ignoreSiblings) { g_pHyprRenderer->damageSurface(m_sWLSurface.wlr(), COORDS.x, COORDS.y); m_bRequestedReposition = false; + + if (m_pLayerOwner && m_pLayerOwner->layer < ZWLR_LAYER_SHELL_V1_LAYER_TOP) + g_pHyprOpenGL->markBlurDirtyForMonitor(g_pCompositor->getMonitorFromID(m_pLayerOwner->layer)); } void CPopup::onReposition() { diff --git a/src/desktop/Window.cpp b/src/desktop/Window.cpp index 3145000c..9151d57e 100644 --- a/src/desktop/Window.cpp +++ b/src/desktop/Window.cpp @@ -1151,3 +1151,13 @@ void CWindow::setAnimationsToMove() { m_vRealSize.setConfig(PANIMCFG); m_bAnimatingIn = false; } + +int CWindow::popupsCount() { + if (m_bIsX11) + return 1; + + int no = 0; + wlr_xdg_surface_for_each_popup_surface( + m_uSurface.xdg, [](wlr_surface* s, int x, int y, void* data) { *(int*)data += 1; }, &no); + return no; +} diff --git a/src/desktop/Window.hpp b/src/desktop/Window.hpp index 3ec8a54c..d8b4012d 100644 --- a/src/desktop/Window.hpp +++ b/src/desktop/Window.hpp @@ -404,6 +404,7 @@ class CWindow { void onBorderAngleAnimEnd(void* ptr); bool isInCurvedCorner(double x, double y); bool hasPopupAt(const Vector2D& pos); + int popupsCount(); void applyGroupRules(); void createGroup(); diff --git a/src/helpers/WLClasses.cpp b/src/helpers/WLClasses.cpp index d46f7e40..e7ae69c0 100644 --- a/src/helpers/WLClasses.cpp +++ b/src/helpers/WLClasses.cpp @@ -37,6 +37,8 @@ void SLayerSurface::applyRules() { noAnimations = true; else if (rule.rule == "blur") forceBlur = true; + else if (rule.rule == "blurpopups") + forceBlurPopups = true; else if (rule.rule.starts_with("ignorealpha") || rule.rule.starts_with("ignorezero")) { const auto FIRST_SPACE_POS = rule.rule.find_first_of(' '); std::string alphaValue = ""; @@ -168,6 +170,13 @@ bool SLayerSurface::isFadedOut() { return !realPosition.isBeingAnimated() && !realSize.isBeingAnimated() && !alpha.isBeingAnimated(); } +int SLayerSurface::popupsCount() { + int no = 0; + wlr_layer_surface_v1_for_each_popup_surface( + layerSurface, [](wlr_surface* s, int x, int y, void* data) { *(int*)data += 1; }, &no); + return no; +} + void SKeyboard::updateXKBTranslationState(xkb_keymap* const keymap) { xkb_state_unref(xkbTranslationState); diff --git a/src/helpers/WLClasses.hpp b/src/helpers/WLClasses.hpp index 7db656d8..f1311e42 100644 --- a/src/helpers/WLClasses.hpp +++ b/src/helpers/WLClasses.hpp @@ -22,6 +22,7 @@ struct SLayerSurface { void applyRules(); void startAnimation(bool in, bool instant = false); bool isFadedOut(); + int popupsCount(); CAnimatedVariable<Vector2D> realPosition; CAnimatedVariable<Vector2D> realSize; @@ -58,6 +59,7 @@ struct SLayerSurface { bool noAnimations = false; bool forceBlur = false; + bool forceBlurPopups = false; int xray = -1; bool ignoreAlpha = false; float ignoreAlphaValue = 0.f; diff --git a/src/render/OpenGL.cpp b/src/render/OpenGL.cpp index df03e8e9..f5cf2624 100644 --- a/src/render/OpenGL.cpp +++ b/src/render/OpenGL.cpp @@ -147,6 +147,7 @@ bool CHyprOpenGLImpl::passRequiresIntrospection(CMonitor* pMonitor) { static auto PXRAY = CConfigValue<Hyprlang::INT>("decoration:blur:xray"); static auto POPTIM = CConfigValue<Hyprlang::INT>("decoration:blur:new_optimizations"); static auto PBLURSPECIAL = CConfigValue<Hyprlang::INT>("decoration:blur:special"); + static auto PBLURPOPUPS = CConfigValue<Hyprlang::INT>("decoration:blur:popups"); if (m_RenderData.mouseZoomFactor != 1.0 || g_pHyprRenderer->m_bCrashingInProgress) return true; @@ -167,23 +168,35 @@ bool CHyprOpenGLImpl::passRequiresIntrospection(CMonitor* pMonitor) { const auto XRAYMODE = ls->xray == -1 ? *PXRAY : ls->xray; if (ls->forceBlur && !XRAYMODE) return true; + + if (ls->popupsCount() > 0 && ls->forceBlurPopups) + return true; } for (auto& ls : pMonitor->m_aLayerSurfaceLayers[ZWLR_LAYER_SHELL_V1_LAYER_TOP]) { const auto XRAYMODE = ls->xray == -1 ? *PXRAY : ls->xray; if (ls->forceBlur && !XRAYMODE) return true; + + if (ls->popupsCount() > 0 && ls->forceBlurPopups) + return true; } // these two block optimization for (auto& ls : pMonitor->m_aLayerSurfaceLayers[ZWLR_LAYER_SHELL_V1_LAYER_BACKGROUND]) { if (ls->forceBlur) return true; + + if (ls->popupsCount() > 0 && ls->forceBlurPopups) + return true; } for (auto& ls : pMonitor->m_aLayerSurfaceLayers[ZWLR_LAYER_SHELL_V1_LAYER_BOTTOM]) { if (ls->forceBlur) return true; + + if (ls->popupsCount() > 0 && ls->forceBlurPopups) + return true; } if (*PBLURSPECIAL) { @@ -202,12 +215,18 @@ bool CHyprOpenGLImpl::passRequiresIntrospection(CMonitor* pMonitor) { return false; for (auto& w : g_pCompositor->m_vWindows) { - if (!w->m_bIsMapped || w->isHidden() || (!w->m_bIsFloating && *POPTIM && !g_pCompositor->isWorkspaceSpecial(w->m_iWorkspaceID))) + if (!w->m_bIsMapped || w->isHidden()) continue; if (!g_pHyprRenderer->shouldRenderWindow(w.get())) continue; + if (w->popupsCount() > 0 && *PBLURPOPUPS) + return true; + + if (!w->m_bIsFloating && *POPTIM && !g_pCompositor->isWorkspaceSpecial(w->m_iWorkspaceID)) + continue; + if (w->m_sAdditionalConfigData.forceNoBlur.toUnderlying() == true || w->m_sAdditionalConfigData.xray.toUnderlying() == true) continue; diff --git a/src/render/Renderer.cpp b/src/render/Renderer.cpp index 2059be0a..3e8b277f 100644 --- a/src/render/Renderer.cpp +++ b/src/render/Renderer.cpp @@ -55,12 +55,9 @@ CHyprRenderer::CHyprRenderer() { } static void renderSurface(struct wlr_surface* surface, int x, int y, void* data) { - static auto PBLURPOPUPS = CConfigValue<Hyprlang::INT>("decoration:blur:popups"); - static auto PBLURPOPUPSIGNOREALPHA = CConfigValue<Hyprlang::FLOAT>("decoration:blur:popups_ignorealpha"); - - const auto TEXTURE = wlr_surface_get_texture(surface); - const auto RDATA = (SRenderData*)data; - const auto INTERACTIVERESIZEINPROGRESS = RDATA->pWindow && g_pInputManager->currentlyDraggedWindow == RDATA->pWindow && g_pInputManager->dragMode == MBIND_RESIZE; + const auto TEXTURE = wlr_surface_get_texture(surface); + const auto RDATA = (SRenderData*)data; + const auto INTERACTIVERESIZEINPROGRESS = RDATA->pWindow && g_pInputManager->currentlyDraggedWindow == RDATA->pWindow && g_pInputManager->dragMode == MBIND_RESIZE; if (!TEXTURE) return; @@ -168,16 +165,9 @@ static void renderSurface(struct wlr_surface* surface, int x, int y, void* data) g_pHyprOpenGL->renderTexture(TEXTURE, &windowBox, RDATA->fadeAlpha * RDATA->alpha, rounding, true); } } else { - if (RDATA->blur && RDATA->popup && *PBLURPOPUPS) { - - if (*PBLURPOPUPSIGNOREALPHA != 1.f) { - g_pHyprOpenGL->m_RenderData.discardMode |= DISCARD_ALPHA; - g_pHyprOpenGL->m_RenderData.discardOpacity = *PBLURPOPUPSIGNOREALPHA; - } - - g_pHyprOpenGL->renderTextureWithBlur(TEXTURE, &windowBox, RDATA->fadeAlpha * RDATA->alpha, surface, rounding, true); - g_pHyprOpenGL->m_RenderData.discardMode &= ~DISCARD_ALPHA; - } else + if (RDATA->blur && RDATA->popup) + g_pHyprOpenGL->renderTextureWithBlur(TEXTURE, &windowBox, RDATA->fadeAlpha * RDATA->alpha, surface, rounding, true, RDATA->fadeAlpha); + else g_pHyprOpenGL->renderTexture(TEXTURE, &windowBox, RDATA->fadeAlpha * RDATA->alpha, rounding, true); } @@ -616,12 +606,28 @@ void CHyprRenderer::renderWindow(CWindow* pWindow, CMonitor* pMonitor, timespec* renderdata.squishOversized = false; // don't squish popups renderdata.popup = true; + static CConfigValue PBLURPOPUPS = CConfigValue<Hyprlang::INT>("decoration:blur:popups"); + static CConfigValue PBLURIGNOREA = CConfigValue<Hyprlang::FLOAT>("decoration:blur:popups_ignorealpha"); + + renderdata.blur = *PBLURPOPUPS; + + const auto DM = g_pHyprOpenGL->m_RenderData.discardMode; + const auto DA = g_pHyprOpenGL->m_RenderData.discardOpacity; + + if (renderdata.blur) { + g_pHyprOpenGL->m_RenderData.discardMode |= DISCARD_ALPHA; + g_pHyprOpenGL->m_RenderData.discardOpacity = *PBLURIGNOREA; + } + if (pWindow->m_sAdditionalConfigData.nearestNeighbor.toUnderlying()) g_pHyprOpenGL->m_RenderData.useNearestNeighbor = true; wlr_xdg_surface_for_each_popup_surface(pWindow->m_uSurface.xdg, renderSurface, &renderdata); g_pHyprOpenGL->m_RenderData.useNearestNeighbor = false; + + g_pHyprOpenGL->m_RenderData.discardMode = DM; + g_pHyprOpenGL->m_RenderData.discardOpacity = DA; } if (decorate) { @@ -664,20 +670,26 @@ void CHyprRenderer::renderLayer(SLayerSurface* pLayer, CMonitor* pMonitor, times g_pHyprOpenGL->m_pCurrentLayer = pLayer; - if (pLayer->ignoreAlpha) { + const auto DM = g_pHyprOpenGL->m_RenderData.discardMode; + const auto DA = g_pHyprOpenGL->m_RenderData.discardOpacity; + + if (renderdata.blur && pLayer->ignoreAlpha) { g_pHyprOpenGL->m_RenderData.discardMode |= DISCARD_ALPHA; g_pHyprOpenGL->m_RenderData.discardOpacity = pLayer->ignoreAlphaValue; } + wlr_surface_for_each_surface(pLayer->layerSurface->surface, renderSurface, &renderdata); - g_pHyprOpenGL->m_RenderData.discardMode &= ~DISCARD_ALPHA; renderdata.squishOversized = false; // don't squish popups renderdata.dontRound = true; renderdata.popup = true; + renderdata.blur = pLayer->forceBlurPopups; wlr_layer_surface_v1_for_each_popup_surface(pLayer->layerSurface, renderSurface, &renderdata); - g_pHyprOpenGL->m_pCurrentLayer = nullptr; - g_pHyprOpenGL->m_RenderData.clipBox = {}; + g_pHyprOpenGL->m_pCurrentLayer = nullptr; + g_pHyprOpenGL->m_RenderData.clipBox = {}; + g_pHyprOpenGL->m_RenderData.discardMode = DM; + g_pHyprOpenGL->m_RenderData.discardOpacity = DA; } void CHyprRenderer::renderIMEPopup(CInputPopup* pPopup, CMonitor* pMonitor, timespec* time) { |