From 5ba33f846129f3e6c0505b19f94634b24505e828 Mon Sep 17 00:00:00 2001 From: Vaxry <43317083+vaxerski@users.noreply.github.com> Date: Sun, 26 Apr 2026 15:16:36 +0100 Subject: config/lua: init lua config manager, use lua if available (#13817) Adds a new lua config manager, which will automatically be used if there is a lua config present. --- src/render/Renderer.cpp | 107 ++++++++++++++++++++++++------------------------ 1 file changed, 54 insertions(+), 53 deletions(-) (limited to 'src/render/Renderer.cpp') diff --git a/src/render/Renderer.cpp b/src/render/Renderer.cpp index a77e855d..fa1a8a06 100644 --- a/src/render/Renderer.cpp +++ b/src/render/Renderer.cpp @@ -178,7 +178,7 @@ IHyprRenderer::IHyprRenderer() { m_renderUnfocusedTimer = makeShared( std::nullopt, [this](SP self, void* data) { - static auto PFPS = CConfigValue("misc:render_unfocused_fps"); + static auto PFPS = CConfigValue("misc:render_unfocused_fps"); if (m_renderUnfocused.empty()) return; @@ -540,7 +540,7 @@ void IHyprRenderer::renderWindow(PHLWINDOW pWindow, PHLMONITOR pMonitor, const T const auto PWORKSPACE = pWindow->m_workspace; const auto REALPOS = pWindow->m_realPosition->value() + (pWindow->m_pinned ? Vector2D{} : PWORKSPACE->m_renderOffset->value()); - static auto PDIMAROUND = CConfigValue("decoration:dim_around"); + static auto PDIMAROUND = CConfigValue("decoration:dim_around"); CSurfacePassElement::SRenderData renderdata = {pMonitor, time}; CBox textureBox = {REALPOS.x, REALPOS.y, std::max(pWindow->m_realSize->value().x, 5.0), std::max(pWindow->m_realSize->value().y, 5.0)}; @@ -643,7 +643,7 @@ void IHyprRenderer::renderWindow(PHLWINDOW pWindow, PHLMONITOR pMonitor, const T } } - static auto PXWLUSENN = CConfigValue("xwayland:use_nearest_neighbor"); + static auto PXWLUSENN = CConfigValue("xwayland:use_nearest_neighbor"); if ((pWindow->m_isX11 && *PXWLUSENN) || pWindow->m_ruleApplicator->nearestNeighbor().valueOrDefault()) renderdata.useNearestNeighbor = true; @@ -713,7 +713,7 @@ void IHyprRenderer::renderWindow(PHLWINDOW pWindow, PHLMONITOR pMonitor, const T renderdata.squishOversized = false; // don't squish popups renderdata.popup = true; - static CConfigValue PBLURIGNOREA = CConfigValue("decoration:blur:popups_ignorealpha"); + static CConfigValue PBLURIGNOREA = CConfigValue("decoration:blur:popups_ignorealpha"); renderdata.blur = shouldBlur(pWindow->m_popupHead); @@ -837,8 +837,8 @@ UP IHyprRenderer::bindTempFB(SP fb) { } bool IHyprRenderer::preBlurQueued(PHLMONITORREF pMonitor) { - static auto PBLURNEWOPTIMIZE = CConfigValue("decoration:blur:new_optimizations"); - static auto PBLUR = CConfigValue("decoration:blur:enabled"); + static auto PBLURNEWOPTIMIZE = CConfigValue("decoration:blur:new_optimizations"); + static auto PBLUR = CConfigValue("decoration:blur:enabled"); if (!pMonitor) return false; @@ -898,7 +898,7 @@ void IHyprRenderer::renderLayer(PHLLS pLayer, PHLMONITOR pMonitor, const Time::s (lockscreen && !pLayer->m_ruleApplicator->aboveLock().valueOrDefault())) return; - static auto PDIMAROUND = CConfigValue("decoration:dim_around"); + static auto PDIMAROUND = CConfigValue("decoration:dim_around"); if (*PDIMAROUND && pLayer->m_ruleApplicator->dimAround().valueOrDefault() && !m_bRenderingSnapshot && !popups) { CRectPassElement::SRectData data; @@ -1001,9 +1001,9 @@ void IHyprRenderer::renderIMEPopup(CInputPopup* pPopup, PHLMONITOR pMonitor, con renderdata.w = SURF->m_current.size.x; renderdata.h = SURF->m_current.size.y; - static auto PBLUR = CConfigValue("decoration:blur:enabled"); - static auto PBLURIMES = CConfigValue("decoration:blur:input_methods"); - static auto PBLURIGNOREA = CConfigValue("decoration:blur:input_methods_ignorealpha"); + static auto PBLUR = CConfigValue("decoration:blur:enabled"); + static auto PBLURIMES = CConfigValue("decoration:blur:input_methods"); + static auto PBLURIGNOREA = CConfigValue("decoration:blur:input_methods_ignorealpha"); renderdata.blur = *PBLURIMES && *PBLUR; if (renderdata.blur) { @@ -1057,11 +1057,11 @@ void IHyprRenderer::renderSessionLockSurface(WP pSurface, P } void IHyprRenderer::renderAllClientsForWorkspace(PHLMONITOR pMonitor, PHLWORKSPACE pWorkspace, const Time::steady_tp& time, const Vector2D& translate, const float& scale) { - static auto PDIMSPECIAL = CConfigValue("decoration:dim_special"); - static auto PBLURSPECIAL = CConfigValue("decoration:blur:special"); - static auto PBLUR = CConfigValue("decoration:blur:enabled"); - static auto PXPMODE = CConfigValue("render:xp_mode"); - static auto PSESSIONLOCKXRAY = CConfigValue("misc:session_lock_xray"); + static auto PDIMSPECIAL = CConfigValue("decoration:dim_special"); + static auto PBLURSPECIAL = CConfigValue("decoration:blur:special"); + static auto PBLUR = CConfigValue("decoration:blur:enabled"); + static auto PXPMODE = CConfigValue("render:xp_mode"); + static auto PSESSIONLOCKXRAY = CConfigValue("misc:session_lock_xray"); if UNLIKELY (!pMonitor) return; @@ -1243,15 +1243,15 @@ SP IHyprRenderer::getBackground(PHLMONITOR pMonitor) { } void IHyprRenderer::renderBackground(PHLMONITOR pMonitor) { - static auto PRENDERTEX = CConfigValue("misc:disable_hyprland_logo"); - static auto PBACKGROUNDCOLOR = CConfigValue("misc:background_color"); - static auto PNOSPLASH = CConfigValue("misc:disable_splash_rendering"); + static auto PRENDERTEX = CConfigValue("misc:disable_hyprland_logo"); + static auto PBACKGROUNDCOLOR = CConfigValue("misc:background_color"); + static auto PNOSPLASH = CConfigValue("misc:disable_splash_rendering"); if (*PRENDERTEX /* inverted cfg flag */ || pMonitor->m_backgroundOpacity->isBeingAnimated()) m_renderPass.add(makeUnique(CClearPassElement::SClearData{CHyprColor(*PBACKGROUNDCOLOR)})); if (!*PRENDERTEX) { - static auto PBACKGROUNDCOLOR = CConfigValue("misc:background_color"); + static auto PBACKGROUNDCOLOR = CConfigValue("misc:background_color"); if (!pMonitor->m_background) pMonitor->m_background = getBackground(pMonitor); @@ -1302,8 +1302,8 @@ void IHyprRenderer::requestBackgroundResource() { if (m_backgroundResource) return; - static auto PNOWALLPAPER = CConfigValue("misc:disable_hyprland_logo"); - static auto PFORCEWALLPAPER = CConfigValue("misc:force_default_wallpaper"); + static auto PNOWALLPAPER = CConfigValue("misc:disable_hyprland_logo"); + static auto PFORCEWALLPAPER = CConfigValue("misc:force_default_wallpaper"); const auto FORCEWALLPAPER = std::clamp(*PFORCEWALLPAPER, sc(-1), sc(2)); @@ -1400,8 +1400,8 @@ SP IHyprRenderer::getBlurTexture(PHLMONITORREF pMonitor) { } bool IHyprRenderer::shouldUseNewBlurOptimizations(PHLLS pLayer, PHLWINDOW pWindow) { - static auto PBLURNEWOPTIMIZE = CConfigValue("decoration:blur:new_optimizations"); - static auto PBLURXRAY = CConfigValue("decoration:blur:xray"); + static auto PBLURNEWOPTIMIZE = CConfigValue("decoration:blur:new_optimizations"); + static auto PBLURXRAY = CConfigValue("decoration:blur:xray"); if (!getBlurTexture(m_renderData.pMonitor)) return false; @@ -1483,9 +1483,10 @@ SP IHyprRenderer::renderText(const std::string& text, CHyprColor col, pango_layout_set_ellipsize(layoutText, PANGO_ELLIPSIZE_END); } - pango_layout_get_size(layoutText, &textW, &textH); - textW /= PANGO_SCALE; - textH /= PANGO_SCALE; + PangoRectangle rectInk = {}, rectLog = {}; + pango_layout_get_pixel_extents(layoutText, &rectInk, &rectLog); + textW = std::max(rectLog.width, rectInk.x + rectInk.width); + textH = std::max(rectLog.height, rectInk.y + rectInk.height); pango_font_description_free(pangoFD); g_object_unref(layoutText); @@ -1596,7 +1597,7 @@ void IHyprRenderer::renderLockscreen(PHLMONITOR pMonitor, const Time::steady_tp& } void IHyprRenderer::renderSessionLockPrimer(PHLMONITOR pMonitor) { - static auto PSESSIONLOCKXRAY = CConfigValue("misc:session_lock_xray"); + static auto PSESSIONLOCKXRAY = CConfigValue("misc:session_lock_xray"); if (*PSESSIONLOCKXRAY) return; @@ -1904,11 +1905,11 @@ void IHyprRenderer::renderMonitor(PHLMONITOR pMonitor, bool commit) { static std::chrono::high_resolution_clock::time_point renderStartOverlay = std::chrono::high_resolution_clock::now(); static std::chrono::high_resolution_clock::time_point endRenderOverlay = std::chrono::high_resolution_clock::now(); - static auto PDEBUGOVERLAY = CConfigValue("debug:overlay"); - static auto PDAMAGETRACKINGMODE = CConfigValue("debug:damage_tracking"); - static auto PDAMAGEBLINK = CConfigValue("debug:damage_blink"); - static auto PSOLDAMAGE = CConfigValue("debug:render_solitary_wo_damage"); - static auto PVFR = CConfigValue("debug:vfr"); + static auto PDEBUGOVERLAY = CConfigValue("debug:overlay"); + static auto PDAMAGETRACKINGMODE = CConfigValue("debug:damage_tracking"); + static auto PDAMAGEBLINK = CConfigValue("debug:damage_blink"); + static auto PSOLDAMAGE = CConfigValue("debug:render_solitary_wo_damage"); + static auto PVFR = CConfigValue("debug:vfr"); static int damageBlinkCleanup = 0; // because double-buffered @@ -2210,10 +2211,10 @@ static hdr_output_metadata createHDRMetadata(SImageDescription settings, S } void IHyprRenderer::handleFullscreenSettings(PHLMONITOR pMonitor) { - static auto PCT = CConfigValue("render:send_content_type"); - static auto PAUTOHDR = CConfigValue("render:cm_auto_hdr"); - static auto PNONSHADER = CConfigValue("render:non_shader_cm"); - static auto PNSINTEROP = CConfigValue("render:non_shader_cm_interop"); + static auto PCT = CConfigValue("render:send_content_type"); + static auto PAUTOHDR = CConfigValue("render:cm_auto_hdr"); + static auto PNONSHADER = CConfigValue("render:non_shader_cm"); + static auto PNSINTEROP = CConfigValue("render:non_shader_cm_interop"); const bool configuredHDR = (pMonitor->m_cmType == NCMType::CM_HDR_EDID || pMonitor->m_cmType == NCMType::CM_HDR); bool wantHDR = configuredHDR; @@ -2628,7 +2629,7 @@ void IHyprRenderer::damageSurface(SP pSurface, double x, dou m->addDamage(damageBoxForEach); } - static auto PLOGDAMAGE = CConfigValue("debug:log_damage"); + static auto PLOGDAMAGE = CConfigValue("debug:log_damage"); if (*PLOGDAMAGE) Log::logger->log(Log::DEBUG, "Damage: Surface (extents): xy: {}, {} wh: {}, {}", damageBox.pixman()->extents.x1, damageBox.pixman()->extents.y1, @@ -2653,7 +2654,7 @@ void IHyprRenderer::damageWindow(PHLWINDOW pWindow, bool forceFull) { } } - static auto PLOGDAMAGE = CConfigValue("debug:log_damage"); + static auto PLOGDAMAGE = CConfigValue("debug:log_damage"); if (*PLOGDAMAGE) Log::logger->log(Log::DEBUG, "Damage: Window ({}): xy: {}, {} wh: {}, {}", pWindow->m_title, windowBox.x, windowBox.y, windowBox.width, windowBox.height); @@ -2666,7 +2667,7 @@ void IHyprRenderer::damageMonitor(PHLMONITOR pMonitor) { CBox damageBox = {0, 0, INT16_MAX, INT16_MAX}; pMonitor->addDamage(damageBox); - static auto PLOGDAMAGE = CConfigValue("debug:log_damage"); + static auto PLOGDAMAGE = CConfigValue("debug:log_damage"); if (*PLOGDAMAGE) Log::logger->log(Log::DEBUG, "Damage: Monitor {}", pMonitor->m_name); @@ -2686,7 +2687,7 @@ void IHyprRenderer::damageBox(const CBox& box, bool skipFrameSchedule) { } } - static auto PLOGDAMAGE = CConfigValue("debug:log_damage"); + static auto PLOGDAMAGE = CConfigValue("debug:log_damage"); if (*PLOGDAMAGE) Log::logger->log(Log::DEBUG, "Damage: Box: xy: {}, {} wh: {}, {}", box.x, box.y, box.w, box.h); @@ -2795,11 +2796,11 @@ void IHyprRenderer::setCursorFromName(const std::string& name, bool force) { } void IHyprRenderer::ensureCursorRenderingMode() { - static auto PINVISIBLE = CConfigValue("cursor:invisible"); - static auto PCURSORTIMEOUT = CConfigValue("cursor:inactive_timeout"); - static auto PHIDEONTOUCH = CConfigValue("cursor:hide_on_touch"); - static auto PHIDEONTABLET = CConfigValue("cursor:hide_on_tablet"); - static auto PHIDEONKEY = CConfigValue("cursor:hide_on_key_press"); + static auto PINVISIBLE = CConfigValue("cursor:invisible"); + static auto PCURSORTIMEOUT = CConfigValue("cursor:inactive_timeout"); + static auto PHIDEONTOUCH = CConfigValue("cursor:hide_on_touch"); + static auto PHIDEONTABLET = CConfigValue("cursor:hide_on_tablet"); + static auto PHIDEONKEY = CConfigValue("cursor:hide_on_key_press"); if (*PCURSORTIMEOUT <= 0) m_cursorHiddenConditions.hiddenOnTimeout = false; @@ -2953,7 +2954,7 @@ bool IHyprRenderer::isMgpu() { } void IHyprRenderer::addWindowToRenderUnfocused(PHLWINDOW window) { - static auto PFPS = CConfigValue("misc:render_unfocused_fps"); + static auto PFPS = CConfigValue("misc:render_unfocused_fps"); if (*PFPS <= 0) return; @@ -3114,7 +3115,7 @@ void IHyprRenderer::makeSnapshot(WP popup) { } void IHyprRenderer::renderSnapshot(PHLWINDOW pWindow) { - static auto PDIMAROUND = CConfigValue("decoration:dim_around"); + static auto PDIMAROUND = CConfigValue("decoration:dim_around"); PHLWINDOWREF ref{pWindow}; @@ -3219,7 +3220,7 @@ void IHyprRenderer::renderSnapshot(WP popup) { if (!popup->m_snapshotFB) return; - static CConfigValue PBLURIGNOREA = CConfigValue("decoration:blur:popups_ignorealpha"); + static CConfigValue PBLURIGNOREA = CConfigValue("decoration:blur:popups_ignorealpha"); const auto FBDATA = popup->m_snapshotFB; @@ -3269,7 +3270,7 @@ bool IHyprRenderer::shouldBlur(PHLLS ls) { if (m_bRenderingSnapshot) return false; - static auto PBLUR = CConfigValue("decoration:blur:enabled"); + static auto PBLUR = CConfigValue("decoration:blur:enabled"); return *PBLUR && ls->m_ruleApplicator->blur().valueOrDefault(); } @@ -3277,21 +3278,21 @@ bool IHyprRenderer::shouldBlur(PHLWINDOW w) { if (m_bRenderingSnapshot) return false; - static auto PBLUR = CConfigValue("decoration:blur:enabled"); + static auto PBLUR = CConfigValue("decoration:blur:enabled"); const bool DONT_BLUR = w->m_ruleApplicator->noBlur().valueOrDefault() || w->m_ruleApplicator->RGBX().valueOrDefault() || w->opaque(); return *PBLUR && !DONT_BLUR; } bool IHyprRenderer::shouldBlur(WP p) { - static CConfigValue PBLURPOPUPS = CConfigValue("decoration:blur:popups"); - static CConfigValue PBLUR = CConfigValue("decoration:blur:enabled"); + static CConfigValue PBLURPOPUPS = CConfigValue("decoration:blur:popups"); + static CConfigValue PBLUR = CConfigValue("decoration:blur:enabled"); return *PBLURPOPUPS && *PBLUR; } SP IHyprRenderer::renderSplash(const std::function(const int, const int, unsigned char* const)>& handleData, const int fontSize, const int maxWidth, const int maxHeight) { - static auto PSPLASHCOLOR = CConfigValue("misc:col.splash"); + static auto PSPLASHCOLOR = CConfigValue("misc:col.splash"); static auto PSPLASHFONT = CConfigValue("misc:splash_font_family"); static auto FALLBACKFONT = CConfigValue("misc:font_family"); -- cgit v1.2.3