From dad8ffd5768b38601b2ea9fa124af4a990011be4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hiram=20Mu=C3=B1oz?= Date: Wed, 21 Feb 2024 18:31:29 +0000 Subject: [PATCH] renderer: Update splash text properties to be configurable (#4707) * Update splash text properties to be configurable The splash text's font and color properties have been updated to be configurable. This change includes adding new configuration values for the splash screen color and font. The rendering of the splash screen is also adjusted to use these new config values, allowing for easy customization of the splash text appearance. * Updated to use Hyprlang config manager --- src/config/ConfigManager.cpp | 2 ++ src/render/OpenGL.cpp | 12 +++++++++--- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/config/ConfigManager.cpp b/src/config/ConfigManager.cpp index 6b54e984..cf16f52c 100644 --- a/src/config/ConfigManager.cpp +++ b/src/config/ConfigManager.cpp @@ -320,6 +320,8 @@ CConfigManager::CConfigManager() { m_pConfig->addConfigValue("misc:disable_hyprland_logo", {0L}); m_pConfig->addConfigValue("misc:disable_splash_rendering", {0L}); + m_pConfig->addConfigValue("misc:col.splash", {0xffffffffL}); + m_pConfig->addConfigValue("misc:splash_font_family", {"Sans"}); m_pConfig->addConfigValue("misc:force_default_wallpaper", {-1L}); m_pConfig->addConfigValue("misc:vfr", {1L}); m_pConfig->addConfigValue("misc:vrr", {0L}); diff --git a/src/render/OpenGL.cpp b/src/render/OpenGL.cpp index a73cfd5b..ffcd13d4 100644 --- a/src/render/OpenGL.cpp +++ b/src/render/OpenGL.cpp @@ -1912,12 +1912,18 @@ void CHyprOpenGLImpl::renderMirrored() { } void CHyprOpenGLImpl::renderSplash(cairo_t* const CAIRO, cairo_surface_t* const CAIROSURFACE, double offsetY, const Vector2D& size) { - cairo_select_font_face(CAIRO, "Sans", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL); + static auto* const PSPLASHCOLOR = (Hyprlang::INT* const*)g_pConfigManager->getConfigValuePtr("misc:col.splash"); + + static auto* const PSPLASHFONT = (Hyprlang::STRING const*)g_pConfigManager->getConfigValuePtr("misc:splash_font_family"); + + cairo_select_font_face(CAIRO, *PSPLASHFONT, CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL); const auto FONTSIZE = (int)(size.y / 76); cairo_set_font_size(CAIRO, FONTSIZE); - cairo_set_source_rgba(CAIRO, 1.0, 1.0, 1.0, 0.32); + const auto COLOR = CColor(**PSPLASHCOLOR); + + cairo_set_source_rgba(CAIRO, COLOR.r, COLOR.g, COLOR.b, COLOR.a); cairo_text_extents_t textExtents; cairo_text_extents(CAIRO, g_pCompositor->m_szCurrentSplash.c_str(), &textExtents); @@ -2013,7 +2019,7 @@ void CHyprOpenGLImpl::createBGTextureForMonitor(CMonitor* pMonitor) { cairo_set_source_surface(CAIRO, CAIROISURFACE, 0, 0); cairo_paint(CAIRO); - if (!*PNOSPLASH) + if (!**PNOSPLASH) renderSplash(CAIRO, CAIROSURFACE, origin.y * WPRATIO / MONRATIO * scale, IMAGESIZE); cairo_surface_flush(CAIROSURFACE);