diff --git a/CMakeLists.txt b/CMakeLists.txt index 2545b02..2412e68 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -65,7 +65,7 @@ pkg_check_modules( wayland-client wayland-protocols wayland-egl - hyprlang>=0.4.0 + hyprlang>=0.6.0 egl xkbcommon libjpeg diff --git a/flake.lock b/flake.lock index 77ed622..6944460 100644 --- a/flake.lock +++ b/flake.lock @@ -62,11 +62,11 @@ ] }, "locked": { - "lastModified": 1737632363, - "narHash": "sha256-X9I8POSlHxBVjD0fiX1O2j7U9Zi1+4rIkrsyHP0uHXY=", + "lastModified": 1737978343, + "narHash": "sha256-TfFS0HCEJh63Kahrkp1h9hVDMdLU8a37Zz+IFucxyfA=", "owner": "hyprwm", "repo": "hyprutils", - "rev": "006620eb29d54ea9086538891404c78563d1bae1", + "rev": "6a8bc9d2a4451df12f5179dc0b1d2d46518a90ab", "type": "github" }, "original": { diff --git a/src/auth/Auth.cpp b/src/auth/Auth.cpp index c5a8f46..f9eacce 100644 --- a/src/auth/Auth.cpp +++ b/src/auth/Auth.cpp @@ -9,11 +9,11 @@ #include CAuth::CAuth() { - static auto* const PENABLEPAM = (Hyprlang::INT* const*)g_pConfigManager->getValuePtr("auth:pam:enabled"); - if (**PENABLEPAM) + static const auto ENABLEPAM = g_pConfigManager->getValue("auth:pam:enabled"); + if (*ENABLEPAM) m_vImpls.push_back(std::make_shared()); - static auto* const PENABLEFINGERPRINT = (Hyprlang::INT* const*)g_pConfigManager->getValuePtr("auth:fingerprint:enabled"); - if (**PENABLEFINGERPRINT) + static const auto ENABLEFINGERPRINT = g_pConfigManager->getValue("auth:fingerprint:enabled"); + if (*ENABLEFINGERPRINT) m_vImpls.push_back(std::make_shared()); RASSERT(!m_vImpls.empty(), "At least one authentication method must be enabled!"); diff --git a/src/auth/Fingerprint.cpp b/src/auth/Fingerprint.cpp index 5f03c39..4f8ce2c 100644 --- a/src/auth/Fingerprint.cpp +++ b/src/auth/Fingerprint.cpp @@ -36,10 +36,10 @@ static std::map s_mapStringToTestType = {{"verify-no-m {"verify-unknown-error", MATCH_UNKNOWN_ERROR}}; CFingerprint::CFingerprint() { - static auto* const PFINGERPRINTREADY = (Hyprlang::STRING*)(g_pConfigManager->getValuePtr("auth:fingerprint:ready_message")); - m_sFingerprintReady = *PFINGERPRINTREADY; - static auto* const PFINGERPRINTPRESENT = (Hyprlang::STRING*)(g_pConfigManager->getValuePtr("auth:fingerprint:present_message")); - m_sFingerprintPresent = *PFINGERPRINTPRESENT; + static const auto FINGERPRINTREADY = g_pConfigManager->getValue("auth:fingerprint:ready_message"); + m_sFingerprintReady = *FINGERPRINTREADY; + static const auto FINGERPRINTPRESENT = g_pConfigManager->getValue("auth:fingerprint:present_message"); + m_sFingerprintPresent = *FINGERPRINTPRESENT; } CFingerprint::~CFingerprint() { @@ -166,8 +166,8 @@ void CFingerprint::handleVerifyStatus(const std::string& result, bool done) { m_sFailureReason = "Fingerprint auth disabled (too many failed attempts)"; } else { done = false; - static const auto RETRYDELAY = **(Hyprlang::INT* const*)(g_pConfigManager->getValuePtr("auth:fingerprint:retry_delay")); - g_pHyprlock->addTimer(std::chrono::milliseconds(RETRYDELAY), [](std::shared_ptr self, void* data) { ((CFingerprint*)data)->startVerify(true); }, this); + static const auto RETRYDELAY = g_pConfigManager->getValue("auth:fingerprint:retry_delay"); + g_pHyprlock->addTimer(std::chrono::milliseconds(*RETRYDELAY), [](std::shared_ptr self, void* data) { ((CFingerprint*)data)->startVerify(true); }, this); m_sFailureReason = "Fingerprint did not match"; } break; diff --git a/src/auth/Pam.cpp b/src/auth/Pam.cpp index b7ed5bc..0e63f38 100644 --- a/src/auth/Pam.cpp +++ b/src/auth/Pam.cpp @@ -61,8 +61,8 @@ int conv(int num_msg, const struct pam_message** msg, struct pam_response** resp } CPam::CPam() { - static auto* const PPAMMODULE = (Hyprlang::STRING*)(g_pConfigManager->getValuePtr("auth:pam:module")); - m_sPamModule = *PPAMMODULE; + static const auto PAMMODULE = g_pConfigManager->getValue("auth:pam:module"); + m_sPamModule = *PAMMODULE; if (!std::filesystem::exists(std::filesystem::path("/etc/pam.d/") / m_sPamModule)) { Debug::log(ERR, "Pam module \"/etc/pam.d/{}\" does not exist! Falling back to \"/etc/pam.d/su\"", m_sPamModule); diff --git a/src/config/ConfigManager.cpp b/src/config/ConfigManager.cpp index 2ce133a..528801b 100644 --- a/src/config/ConfigManager.cpp +++ b/src/config/ConfigManager.cpp @@ -358,13 +358,6 @@ void CConfigManager::init() { #undef SHADOWABLE } -std::mutex configMtx; - -void* const* CConfigManager::getValuePtr(const std::string& name) { - std::lock_guard lg(configMtx); - return m_config.getConfigValuePtr(name.c_str())->getDataStaticPtr(); -} - std::vector CConfigManager::getWidgetConfigs() { std::vector result; diff --git a/src/config/ConfigManager.hpp b/src/config/ConfigManager.hpp index c6db06d..11d960d 100644 --- a/src/config/ConfigManager.hpp +++ b/src/config/ConfigManager.hpp @@ -13,8 +13,12 @@ class CConfigManager { public: CConfigManager(std::string configPath); - void init(); - void* const* getValuePtr(const std::string& name); + void init(); + + template + Hyprlang::CSimpleConfigValue getValue(const std::string& name) { + return Hyprlang::CSimpleConfigValue(&m_config, name.c_str()); + } struct SWidgetConfig { std::string type; diff --git a/src/core/AnimationManager.cpp b/src/core/AnimationManager.cpp index 30d38b2..a1dc903 100644 --- a/src/core/AnimationManager.cpp +++ b/src/core/AnimationManager.cpp @@ -77,7 +77,7 @@ void updateGradientVariable(CAnimatedVariable& av, const flo } void CHyprlockAnimationManager::tick() { - static auto* const PANIMATIONSENABLED = (Hyprlang::INT* const*)g_pConfigManager->getValuePtr("animations:enabled"); + static const auto ANIMATIONSENABLED = g_pConfigManager->getValue("animations:enabled"); for (size_t i = 0; i < m_vActiveAnimatedVariables.size(); i++) { const auto PAV = m_vActiveAnimatedVariables[i].lock(); if (!PAV || !PAV->ok()) @@ -86,7 +86,7 @@ void CHyprlockAnimationManager::tick() { const auto SPENT = PAV->getPercent(); const auto PBEZIER = getBezier(PAV->getBezierName()); const auto POINTY = PBEZIER->getYForPoint(SPENT); - const bool WARP = !**PANIMATIONSENABLED || SPENT >= 1.f; + const bool WARP = !*ANIMATIONSENABLED || SPENT >= 1.f; switch (PAV->m_Type) { case AVARTYPE_FLOAT: { diff --git a/src/core/LockSurface.cpp b/src/core/LockSurface.cpp index 1625272..b00074a 100644 --- a/src/core/LockSurface.cpp +++ b/src/core/LockSurface.cpp @@ -19,10 +19,10 @@ CSessionLockSurface::CSessionLockSurface(COutput* output) : output(output) { exit(1); } - const auto PFRACTIONALSCALING = (Hyprlang::INT* const*)g_pConfigManager->getValuePtr("general:fractional_scaling"); - const auto ENABLE_FSV1 = **PFRACTIONALSCALING == 1 || /* auto enable */ (**PFRACTIONALSCALING == 2); - const auto PFRACTIONALMGR = g_pHyprlock->getFractionalMgr(); - const auto PVIEWPORTER = g_pHyprlock->getViewporter(); + static const auto FRACTIONALSCALING = g_pConfigManager->getValue("general:fractional_scaling"); + const auto ENABLE_FSV1 = *FRACTIONALSCALING == 1 || /* auto enable */ (*FRACTIONALSCALING == 2); + const auto PFRACTIONALMGR = g_pHyprlock->getFractionalMgr(); + const auto PVIEWPORTER = g_pHyprlock->getViewporter(); if (ENABLE_FSV1 && PFRACTIONALMGR && PVIEWPORTER) { fractional = makeShared(PFRACTIONALMGR->sendGetFractionalScale(surface->resource())); diff --git a/src/core/Seat.cpp b/src/core/Seat.cpp index 46b5605..7e2ebcb 100644 --- a/src/core/Seat.cpp +++ b/src/core/Seat.cpp @@ -40,11 +40,11 @@ void CSeatManager::registerSeat(SP seat) { if (!m_pCursorShape) return; - static auto* const PHIDE = (Hyprlang::INT* const*)g_pConfigManager->getValuePtr("general:hide_cursor"); + static const auto HIDE = g_pConfigManager->getValue("general:hide_cursor"); m_pCursorShape->lastCursorSerial = serial; - if (**PHIDE) + if (*HIDE) m_pCursorShape->hideCursor(); else m_pCursorShape->setShape(wpCursorShapeDeviceV1Shape::WP_CURSOR_SHAPE_DEVICE_V1_SHAPE_DEFAULT); diff --git a/src/core/hyprlock.cpp b/src/core/hyprlock.cpp index 3a75ea6..22f64c7 100644 --- a/src/core/hyprlock.cpp +++ b/src/core/hyprlock.cpp @@ -33,13 +33,13 @@ CHyprlock::CHyprlock(const std::string& wlDisplay, const bool immediate, const b g_pEGL = std::make_unique(m_sWaylandState.display); if (!immediate) { - const auto PGRACE = (Hyprlang::INT* const*)g_pConfigManager->getValuePtr("general:grace"); - m_tGraceEnds = **PGRACE ? std::chrono::system_clock::now() + std::chrono::seconds(**PGRACE) : std::chrono::system_clock::from_time_t(0); + static const auto GRACE = g_pConfigManager->getValue("general:grace"); + m_tGraceEnds = *GRACE ? std::chrono::system_clock::now() + std::chrono::seconds(*GRACE) : std::chrono::system_clock::from_time_t(0); } else m_tGraceEnds = std::chrono::system_clock::from_time_t(0); - const auto PIMMEDIATERENDER = (Hyprlang::INT* const*)g_pConfigManager->getValuePtr("general:immediate_render"); - m_bImmediateRender = immediateRender || **PIMMEDIATERENDER; + static const auto IMMEDIATERENDER = g_pConfigManager->getValue("general:immediate_render"); + m_bImmediateRender = immediateRender || *IMMEDIATERENDER; const auto CURRENTDESKTOP = getenv("XDG_CURRENT_DESKTOP"); const auto SZCURRENTD = std::string{CURRENTDESKTOP ? CURRENTDESKTOP : ""}; @@ -661,9 +661,9 @@ void CHyprlock::handleKeySym(xkb_keysym_t sym, bool composed) { } else if (SYM == XKB_KEY_Return || SYM == XKB_KEY_KP_Enter) { Debug::log(LOG, "Authenticating"); - static auto* const PIGNOREEMPTY = (Hyprlang::INT* const*)g_pConfigManager->getValuePtr("general:ignore_empty_input"); + static const auto IGNOREEMPTY = g_pConfigManager->getValue("general:ignore_empty_input"); - if (m_sPasswordState.passBuffer.empty() && **PIGNOREEMPTY) { + if (m_sPasswordState.passBuffer.empty() && *IGNOREEMPTY) { Debug::log(LOG, "Ignoring empty input"); return; } diff --git a/src/renderer/AsyncResourceGatherer.cpp b/src/renderer/AsyncResourceGatherer.cpp index a8d1515..0034d06 100644 --- a/src/renderer/AsyncResourceGatherer.cpp +++ b/src/renderer/AsyncResourceGatherer.cpp @@ -215,15 +215,15 @@ void CAsyncResourceGatherer::renderText(const SPreloadRequest& rq) { target.type = TARGET_IMAGE; /* text is just an image lol */ target.id = rq.id; - const int FONTSIZE = rq.props.contains("font_size") ? std::any_cast(rq.props.at("font_size")) : 16; - const CHyprColor FONTCOLOR = rq.props.contains("color") ? std::any_cast(rq.props.at("color")) : CHyprColor(1.0, 1.0, 1.0, 1.0); - const std::string FONTFAMILY = rq.props.contains("font_family") ? std::any_cast(rq.props.at("font_family")) : "Sans"; - const bool ISCMD = rq.props.contains("cmd") ? std::any_cast(rq.props.at("cmd")) : false; + const int FONTSIZE = rq.props.contains("font_size") ? std::any_cast(rq.props.at("font_size")) : 16; + const CHyprColor FONTCOLOR = rq.props.contains("color") ? std::any_cast(rq.props.at("color")) : CHyprColor(1.0, 1.0, 1.0, 1.0); + const std::string FONTFAMILY = rq.props.contains("font_family") ? std::any_cast(rq.props.at("font_family")) : "Sans"; + const bool ISCMD = rq.props.contains("cmd") ? std::any_cast(rq.props.at("cmd")) : false; - static auto* const TRIM = (Hyprlang::INT* const*)g_pConfigManager->getValuePtr("general:text_trim"); - std::string text = ISCMD ? g_pHyprlock->spawnSync(rq.asset) : rq.asset; + static const auto TRIM = g_pConfigManager->getValue("general:text_trim"); + std::string text = ISCMD ? g_pHyprlock->spawnSync(rq.asset) : rq.asset; - if (**TRIM) { + if (*TRIM) { text.erase(0, text.find_first_not_of(" \n\r\t")); text.erase(text.find_last_not_of(" \n\r\t") + 1); } diff --git a/src/renderer/Renderer.cpp b/src/renderer/Renderer.cpp index d6261b5..c6f50d7 100644 --- a/src/renderer/Renderer.cpp +++ b/src/renderer/Renderer.cpp @@ -201,7 +201,7 @@ CRenderer::CRenderer() { // CRenderer::SRenderFeedback CRenderer::renderLock(const CSessionLockSurface& surf) { - static auto* const PDISABLEBAR = (Hyprlang::INT* const*)g_pConfigManager->getValuePtr("general:disable_loading_bar"); + static const auto DISABLEBAR = g_pConfigManager->getValue("general:disable_loading_bar"); projection = Mat3x3::outputProjection(surf.size, HYPRUTILS_TRANSFORM_NORMAL); @@ -224,7 +224,7 @@ CRenderer::SRenderFeedback CRenderer::renderLock(const CSessionLockSurface& surf if (WAITFORASSETS) { // render status - if (!**PDISABLEBAR) { + if (!*DISABLEBAR) { CBox progress = {0, 0, asyncResourceGatherer->progress * surf.size.x, 2}; renderRect(progress, CHyprColor{0.2f, 0.1f, 0.1f, 1.f}, 0); } diff --git a/src/renderer/Screencopy.cpp b/src/renderer/Screencopy.cpp index db9b415..7e1c458 100644 --- a/src/renderer/Screencopy.cpp +++ b/src/renderer/Screencopy.cpp @@ -31,8 +31,8 @@ CScreencopyFrame::CScreencopyFrame(COutput* output) : m_output(output) { captureOutput(); - static auto* const PSCMODE = (Hyprlang::INT* const*)g_pConfigManager->getValuePtr("general:screencopy_mode"); - if (**PSCMODE == 1) + static const auto SCMODE = g_pConfigManager->getValue("general:screencopy_mode"); + if (*SCMODE == 1) m_frame = std::make_unique(m_sc); else m_frame = std::make_unique(m_sc);