summaryrefslogtreecommitdiff
path: root/src/helpers
diff options
context:
space:
mode:
authorVaxry <vaxry@vaxry.net>2024-03-03 18:39:20 +0000
committerVaxry <vaxry@vaxry.net>2024-03-03 18:41:38 +0000
commit063708df26e8b930f492200e1907eb47950f50e6 (patch)
tree31648b7148213ecb9c6d469148ac1c5061835d5a /src/helpers
parent8ccbd272cc5f3a98280d4e050f456d25aee47ee5 (diff)
config: improve config value infrastructure
Diffstat (limited to 'src/helpers')
-rw-r--r--src/helpers/Monitor.cpp16
-rw-r--r--src/helpers/Watchdog.cpp9
2 files changed, 14 insertions, 11 deletions
diff --git a/src/helpers/Monitor.cpp b/src/helpers/Monitor.cpp
index 7f36ccd4..12857969 100644
--- a/src/helpers/Monitor.cpp
+++ b/src/helpers/Monitor.cpp
@@ -4,6 +4,8 @@
#include "../Compositor.hpp"
+#include "../config/ConfigValue.hpp"
+
int ratHandler(void* data) {
g_pHyprRenderer->renderMonitor((CMonitor*)data);
@@ -330,8 +332,8 @@ void CMonitor::onDisconnect(bool destroy) {
}
void CMonitor::addDamage(const pixman_region32_t* rg) {
- static auto* const PZOOMFACTOR = (Hyprlang::FLOAT* const*)g_pConfigManager->getConfigValuePtr("misc:cursor_zoom_factor");
- if (**PZOOMFACTOR != 1.f && g_pCompositor->getMonitorFromCursor() == this) {
+ static auto PZOOMFACTOR = CConfigValue<Hyprlang::FLOAT>("misc:cursor_zoom_factor");
+ if (*PZOOMFACTOR != 1.f && g_pCompositor->getMonitorFromCursor() == this) {
wlr_damage_ring_add_whole(&damage);
g_pCompositor->scheduleFrameForMonitor(this);
} else if (wlr_damage_ring_add(&damage, rg))
@@ -343,8 +345,8 @@ void CMonitor::addDamage(const CRegion* rg) {
}
void CMonitor::addDamage(const CBox* box) {
- static auto* const PZOOMFACTOR = (Hyprlang::FLOAT* const*)g_pConfigManager->getConfigValuePtr("misc:cursor_zoom_factor");
- if (**PZOOMFACTOR != 1.f && g_pCompositor->getMonitorFromCursor() == this) {
+ static auto PZOOMFACTOR = CConfigValue<Hyprlang::FLOAT>("misc:cursor_zoom_factor");
+ if (*PZOOMFACTOR != 1.f && g_pCompositor->getMonitorFromCursor() == this) {
wlr_damage_ring_add_whole(&damage);
g_pCompositor->scheduleFrameForMonitor(this);
}
@@ -568,11 +570,11 @@ void CMonitor::changeWorkspace(CWorkspace* const pWorkspace, bool internal, bool
}
if (!noFocus && !g_pCompositor->m_pLastMonitor->specialWorkspaceID) {
- static auto* const PFOLLOWMOUSE = (Hyprlang::INT* const*)g_pConfigManager->getConfigValuePtr("input:follow_mouse");
- CWindow* pWindow = pWorkspace->getLastFocusedWindow();
+ static auto PFOLLOWMOUSE = CConfigValue<Hyprlang::INT>("input:follow_mouse");
+ CWindow* pWindow = pWorkspace->getLastFocusedWindow();
if (!pWindow) {
- if (**PFOLLOWMOUSE == 1)
+ if (*PFOLLOWMOUSE == 1)
pWindow = g_pCompositor->vectorToWindowUnified(g_pInputManager->getMouseCoordsInternal(), RESERVED_EXTENTS | INPUT_EXTENTS | ALLOW_FLOATING);
if (!pWindow)
diff --git a/src/helpers/Watchdog.cpp b/src/helpers/Watchdog.cpp
index ce4d2707..afb8a946 100644
--- a/src/helpers/Watchdog.cpp
+++ b/src/helpers/Watchdog.cpp
@@ -1,6 +1,7 @@
#include "Watchdog.hpp"
#include <signal.h>
#include "config/ConfigManager.hpp"
+#include "../config/ConfigValue.hpp"
CWatchdog::~CWatchdog() {
m_bExitThread = true;
@@ -13,7 +14,7 @@ CWatchdog::CWatchdog() {
m_iMainThreadPID = pthread_self();
m_pWatchdog = std::make_unique<std::thread>([this] {
- static auto* const PTIMEOUT = (Hyprlang::INT* const*)g_pConfigManager->getConfigValuePtr("debug:watchdog_timeout");
+ static auto PTIMEOUT = CConfigValue<Hyprlang::INT>("debug:watchdog_timeout");
while (1337) {
std::unique_lock lk(m_mWatchdogMutex);
@@ -21,7 +22,7 @@ CWatchdog::CWatchdog() {
if (!m_bWillWatch)
m_cvWatchdogCondition.wait(lk, [this] { return m_bNotified; });
else {
- if (m_cvWatchdogCondition.wait_for(lk, std::chrono::milliseconds((int)(**PTIMEOUT * 1000.0)), [this] { return m_bNotified; }) == false)
+ if (m_cvWatchdogCondition.wait_for(lk, std::chrono::milliseconds((int)(*PTIMEOUT * 1000.0)), [this] { return m_bNotified; }) == false)
pthread_kill(m_iMainThreadPID, SIGUSR1);
}
@@ -37,9 +38,9 @@ CWatchdog::CWatchdog() {
}
void CWatchdog::startWatching() {
- static auto* const PTIMEOUT = (Hyprlang::INT* const*)g_pConfigManager->getConfigValuePtr("debug:watchdog_timeout");
+ static auto PTIMEOUT = CConfigValue<Hyprlang::INT>("debug:watchdog_timeout");
- if (**PTIMEOUT == 0)
+ if (*PTIMEOUT == 0)
return;
m_tTriggered = std::chrono::high_resolution_clock::now();