From 25add26881d7b98d2b80eb7a95d3aee0449b72b9 Mon Sep 17 00:00:00 2001 From: vaxerski Date: Tue, 14 Jan 2025 17:52:19 +0100 Subject: [PATCH] renderer: unload background texture if it's disabled ref #9031 --- src/config/ConfigManager.cpp | 5 +++-- src/render/OpenGL.cpp | 21 ++++++++++++++------- src/render/OpenGL.hpp | 4 +++- 3 files changed, 20 insertions(+), 10 deletions(-) diff --git a/src/config/ConfigManager.cpp b/src/config/ConfigManager.cpp index 60723220..17957899 100644 --- a/src/config/ConfigManager.cpp +++ b/src/config/ConfigManager.cpp @@ -899,11 +899,12 @@ void CConfigManager::postConfigReload(const Hyprlang::CParseResult& result) { g_pInputManager->setPointerConfigs(); g_pInputManager->setTouchDeviceConfigs(); g_pInputManager->setTabletConfigs(); - } - if (!isFirstLaunch) g_pHyprOpenGL->m_bReloadScreenShader = true; + g_pHyprOpenGL->ensureBackgroundTexturePresence(); + } + // parseError will be displayed next frame if (result.error) diff --git a/src/render/OpenGL.cpp b/src/render/OpenGL.cpp index 3a4781e7..b68448ae 100644 --- a/src/render/OpenGL.cpp +++ b/src/render/OpenGL.cpp @@ -2699,10 +2699,6 @@ void CHyprOpenGLImpl::initMissingAssetTexture() { void CHyprOpenGLImpl::initAssets() { initMissingAssetTexture(); - static auto PFORCEWALLPAPER = CConfigValue("misc:force_default_wallpaper"); - - const auto FORCEWALLPAPER = std::clamp(*PFORCEWALLPAPER, static_cast(-1L), static_cast(2L)); - m_pLockDeadTexture = loadAsset("lockdead.png"); m_pLockDead2Texture = loadAsset("lockdead2.png"); @@ -2712,9 +2708,20 @@ void CHyprOpenGLImpl::initAssets() { "unknown"), CHyprColor{0.9F, 0.9F, 0.9F, 0.7F}, 20, true); - // create the default background texture - { - std::string texPath = std::format("{}", "wall"); + ensureBackgroundTexturePresence(); +} + +void CHyprOpenGLImpl::ensureBackgroundTexturePresence() { + static auto PNOWALLPAPER = CConfigValue("misc:disable_hyprland_logo"); + static auto PFORCEWALLPAPER = CConfigValue("misc:force_default_wallpaper"); + + const auto FORCEWALLPAPER = std::clamp(*PFORCEWALLPAPER, static_cast(-1L), static_cast(2L)); + + if (*PNOWALLPAPER) + m_pBackgroundTexture.reset(); + else if (!m_pBackgroundTexture) { + // create the default background texture + std::string texPath = "wall"; // get the adequate tex if (FORCEWALLPAPER == -1) { diff --git a/src/render/OpenGL.hpp b/src/render/OpenGL.hpp index 3f117a5a..2b600a03 100644 --- a/src/render/OpenGL.hpp +++ b/src/render/OpenGL.hpp @@ -223,6 +223,8 @@ class CHyprOpenGLImpl { void setDamage(const CRegion& damage, std::optional finalDamage = {}); + void ensureBackgroundTexturePresence(); + uint32_t getPreferredReadFormat(PHLMONITOR pMonitor); std::vector getDRMFormats(); EGLImageKHR createEGLImage(const Aquamarine::SDMABUFAttrs& attrs); @@ -293,7 +295,7 @@ class CHyprOpenGLImpl { CShader m_sFinalScreenShader; CTimer m_tGlobalTimer; - SP m_pMissingAssetTexture, m_pBackgroundTexture, m_pLockDeadTexture, m_pLockDead2Texture, m_pLockTtyTextTexture; + SP m_pMissingAssetTexture, m_pBackgroundTexture, m_pLockDeadTexture, m_pLockDead2Texture, m_pLockTtyTextTexture; // TODO: don't always load lock void logShaderError(const GLuint&, bool program = false); GLuint createProgram(const std::string&, const std::string&, bool dynamic = false);