mirror of
https://github.com/virtcode/hypr-dynamic-cursors
synced 2025-09-19 16:13:21 +02:00
chore: basic plugin project setup
This commit is contained in:
commit
85b89bc389
4 changed files with 67 additions and 0 deletions
5
src/globals.hpp
Normal file
5
src/globals.hpp
Normal file
|
@ -0,0 +1,5 @@
|
|||
#pragma once
|
||||
|
||||
#include <hyprland/src/plugins/PluginAPI.hpp>
|
||||
|
||||
inline HANDLE PHANDLE = nullptr;
|
41
src/main.cpp
Normal file
41
src/main.cpp
Normal file
|
@ -0,0 +1,41 @@
|
|||
#include <hyprland/src/helpers/memory/Memory.hpp>
|
||||
#include <hyprland/src/plugins/HookSystem.hpp>
|
||||
#include <hyprland/src/plugins/PluginAPI.hpp>
|
||||
#include <hyprland/src/helpers/Monitor.hpp>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "globals.hpp"
|
||||
|
||||
typedef void (*origRenderSofwareCursorsFor)(void*, SP<CMonitor>, timespec*, CRegion&, std::optional<Vector2D>);
|
||||
inline CFunctionHook* g_pRenderSoftwareCursorsForHook = nullptr;
|
||||
|
||||
void hkRenderSoftwareCursorsFor(void* thisptr, SP<CMonitor> pMonitor, timespec* now, CRegion& damage, std::optional<Vector2D> overridePos) {
|
||||
//(*(origRenderSofwareCursorsFor)g_pRenderSoftwareCursorsForHook->m_pOriginal)(thisptr, pMonitor, now, damage, overridePos);
|
||||
}
|
||||
|
||||
APICALL EXPORT PLUGIN_DESCRIPTION_INFO PLUGIN_INIT(HANDLE handle) {
|
||||
PHANDLE = handle;
|
||||
|
||||
const std::string HASH = __hyprland_api_get_hash();
|
||||
|
||||
// check that header version aligns with running version
|
||||
if (HASH != GIT_COMMIT_HASH) {
|
||||
HyprlandAPI::addNotification(PHANDLE, "[dynamic-cursors] Mismatched headers! Can't proceed.", CColor{1.0, 0.2, 0.2, 1.0}, 5000);
|
||||
throw std::runtime_error("[dynamic-cursors] Version mismatch");
|
||||
}
|
||||
|
||||
static const auto METHODS = HyprlandAPI::findFunctionsByName(PHANDLE, "renderSoftwareCursorsFor");
|
||||
g_pRenderSoftwareCursorsForHook = HyprlandAPI::createFunctionHook(PHANDLE, METHODS[0].address, (void*) &hkRenderSoftwareCursorsFor);
|
||||
g_pRenderSoftwareCursorsForHook->hook();
|
||||
|
||||
return {"dynamic-cursors", "The most stupid cursor plugin.", "Virt", "1.1"};
|
||||
}
|
||||
|
||||
APICALL EXPORT void PLUGIN_EXIT() {
|
||||
// ...
|
||||
}
|
||||
|
||||
// Do NOT change this function.
|
||||
APICALL EXPORT std::string PLUGIN_API_VERSION() {
|
||||
return HYPRLAND_API_VERSION;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue