diff --git a/src/config/config.cpp b/src/config/config.cpp index 664e128..1c3403b 100644 --- a/src/config/config.cpp +++ b/src/config/config.cpp @@ -1,10 +1,17 @@ #include "../globals.hpp" +#include "../cursor.hpp" +#include "src/render/Renderer.hpp" #include "config.hpp" #include #include #include #include +bool isEnabled() { + static auto* const* PENABLED = (Hyprlang::INT* const*) getConfig(CONFIG_ENABLED); + return **PENABLED && g_pHyprRenderer->m_pMostHzMonitor && g_pDynamicCursors; // make sure the compositor is properly initialized +} + Hyprlang::CConfigValue toHyprlang(std::variant value) { if (std::holds_alternative(value)) diff --git a/src/config/config.hpp b/src/config/config.hpp index 95f07ad..e9e955e 100644 --- a/src/config/config.hpp +++ b/src/config/config.hpp @@ -33,6 +33,9 @@ #define CONFIG_SHAPERULE "shaperule" +/* is the plugin enabled */ +bool isEnabled(); + /* initializes stuff so config can be set up */ void startConfig(); /* finishes config setup */ diff --git a/src/cursor.cpp b/src/cursor.cpp index dc9ac61..c853c2f 100644 --- a/src/cursor.cpp +++ b/src/cursor.cpp @@ -24,9 +24,7 @@ #include "renderer.hpp" void tickRaw(SP self, void* data) { - static auto* const* PENABLED = (Hyprlang::INT* const*) getConfig(CONFIG_ENABLED); - - if (**PENABLED && g_pDynamicCursors) + if (isEnabled()) g_pDynamicCursors->onTick(g_pPointerManager.get()); const int TIMEOUT = g_pHyprRenderer->m_pMostHzMonitor ? 1000.0 / g_pHyprRenderer->m_pMostHzMonitor->refreshRate : 16; diff --git a/src/main.cpp b/src/main.cpp index 593f480..97dc886 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -13,11 +13,6 @@ #include "src/managers/PointerManager.hpp" #include "src/version.h" -bool isEnabled() { - static auto* const* PENABLED = (Hyprlang::INT* const*) getConfig(CONFIG_ENABLED); - return **PENABLED; -} - typedef void (*origRenderSofwareCursorsFor)(void*, SP, timespec*, CRegion&, std::optional); inline CFunctionHook* g_pRenderSoftwareCursorsForHook = nullptr; void hkRenderSoftwareCursorsFor(void* thisptr, SP pMonitor, timespec* now, CRegion& damage, std::optional overridePos) {