mirror of
https://github.com/virtcode/hypr-dynamic-cursors
synced 2025-09-19 16:13:21 +02:00
fix: only update if hyprland is done initializing
We check whether the most hz monitor is non-null, as a measure to whether hyprland is intialized. This is nessecary as plugins loaded with `plugin =` otherwise cause a ton of weird crashes.
This commit is contained in:
parent
d8248f5a1a
commit
1ae25556a1
4 changed files with 11 additions and 8 deletions
|
@ -1,10 +1,17 @@
|
||||||
#include "../globals.hpp"
|
#include "../globals.hpp"
|
||||||
|
#include "../cursor.hpp"
|
||||||
|
#include "src/render/Renderer.hpp"
|
||||||
#include "config.hpp"
|
#include "config.hpp"
|
||||||
#include <hyprland/src/plugins/PluginAPI.hpp>
|
#include <hyprland/src/plugins/PluginAPI.hpp>
|
||||||
#include <hyprlang.hpp>
|
#include <hyprlang.hpp>
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
#include <variant>
|
#include <variant>
|
||||||
|
|
||||||
|
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<std::string, float, int> value) {
|
Hyprlang::CConfigValue toHyprlang(std::variant<std::string, float, int> value) {
|
||||||
|
|
||||||
if (std::holds_alternative<std::string>(value))
|
if (std::holds_alternative<std::string>(value))
|
||||||
|
|
|
@ -33,6 +33,9 @@
|
||||||
|
|
||||||
#define CONFIG_SHAPERULE "shaperule"
|
#define CONFIG_SHAPERULE "shaperule"
|
||||||
|
|
||||||
|
/* is the plugin enabled */
|
||||||
|
bool isEnabled();
|
||||||
|
|
||||||
/* initializes stuff so config can be set up */
|
/* initializes stuff so config can be set up */
|
||||||
void startConfig();
|
void startConfig();
|
||||||
/* finishes config setup */
|
/* finishes config setup */
|
||||||
|
|
|
@ -24,9 +24,7 @@
|
||||||
#include "renderer.hpp"
|
#include "renderer.hpp"
|
||||||
|
|
||||||
void tickRaw(SP<CEventLoopTimer> self, void* data) {
|
void tickRaw(SP<CEventLoopTimer> self, void* data) {
|
||||||
static auto* const* PENABLED = (Hyprlang::INT* const*) getConfig(CONFIG_ENABLED);
|
if (isEnabled())
|
||||||
|
|
||||||
if (**PENABLED && g_pDynamicCursors)
|
|
||||||
g_pDynamicCursors->onTick(g_pPointerManager.get());
|
g_pDynamicCursors->onTick(g_pPointerManager.get());
|
||||||
|
|
||||||
const int TIMEOUT = g_pHyprRenderer->m_pMostHzMonitor ? 1000.0 / g_pHyprRenderer->m_pMostHzMonitor->refreshRate : 16;
|
const int TIMEOUT = g_pHyprRenderer->m_pMostHzMonitor ? 1000.0 / g_pHyprRenderer->m_pMostHzMonitor->refreshRate : 16;
|
||||||
|
|
|
@ -13,11 +13,6 @@
|
||||||
#include "src/managers/PointerManager.hpp"
|
#include "src/managers/PointerManager.hpp"
|
||||||
#include "src/version.h"
|
#include "src/version.h"
|
||||||
|
|
||||||
bool isEnabled() {
|
|
||||||
static auto* const* PENABLED = (Hyprlang::INT* const*) getConfig(CONFIG_ENABLED);
|
|
||||||
return **PENABLED;
|
|
||||||
}
|
|
||||||
|
|
||||||
typedef void (*origRenderSofwareCursorsFor)(void*, SP<CMonitor>, timespec*, CRegion&, std::optional<Vector2D>);
|
typedef void (*origRenderSofwareCursorsFor)(void*, SP<CMonitor>, timespec*, CRegion&, std::optional<Vector2D>);
|
||||||
inline CFunctionHook* g_pRenderSoftwareCursorsForHook = nullptr;
|
inline CFunctionHook* g_pRenderSoftwareCursorsForHook = nullptr;
|
||||||
void hkRenderSoftwareCursorsFor(void* thisptr, SP<CMonitor> pMonitor, timespec* now, CRegion& damage, std::optional<Vector2D> overridePos) {
|
void hkRenderSoftwareCursorsFor(void* thisptr, SP<CMonitor> pMonitor, timespec* now, CRegion& damage, std::optional<Vector2D> overridePos) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue