summaryrefslogtreecommitdiff
path: root/src/plugins/PluginAPI.hpp
diff options
context:
space:
mode:
authorVaxry <vaxry@vaxry.net>2024-04-20 20:16:42 +0100
committerVaxry <vaxry@vaxry.net>2024-04-20 20:16:42 +0100
commit4ad739ec63c9a11f0537a884ae2a4c56d6bab10b (patch)
tree0842db7489691fc6e7cbb3cd6d3321dd0d4790b6 /src/plugins/PluginAPI.hpp
parent1055e6bee677ef9c4ab4d09e43155e00a98a3b49 (diff)
HookSystem: improve callback safety
Diffstat (limited to 'src/plugins/PluginAPI.hpp')
-rw-r--r--src/plugins/PluginAPI.hpp12
1 files changed, 2 insertions, 10 deletions
diff --git a/src/plugins/PluginAPI.hpp b/src/plugins/PluginAPI.hpp
index 75dca24e..62db8e3b 100644
--- a/src/plugins/PluginAPI.hpp
+++ b/src/plugins/PluginAPI.hpp
@@ -133,27 +133,19 @@ namespace HyprlandAPI {
APICALL Hyprlang::CConfigValue* getConfigValue(HANDLE handle, const std::string& name);
/*
- Register a static (pointer) callback to a selected event.
- Pointer must be kept valid until unregisterCallback() is called.
-
- returns: true on success, false on fail
- */
- APICALL bool registerCallbackStatic(HANDLE handle, const std::string& event, HOOK_CALLBACK_FN* fn);
-
- /*
Register a dynamic (function) callback to a selected event.
Pointer will be free'd by Hyprland on unregisterCallback().
returns: a pointer to the newly allocated function. nullptr on fail.
*/
- APICALL HOOK_CALLBACK_FN* registerCallbackDynamic(HANDLE handle, const std::string& event, HOOK_CALLBACK_FN fn);
+ APICALL std::shared_ptr<HOOK_CALLBACK_FN> registerCallbackDynamic(HANDLE handle, const std::string& event, HOOK_CALLBACK_FN fn);
/*
Unregisters a callback. If the callback was dynamic, frees the memory.
returns: true on success, false on fail
*/
- APICALL bool unregisterCallback(HANDLE handle, HOOK_CALLBACK_FN* fn);
+ APICALL bool unregisterCallback(HANDLE handle, std::shared_ptr<HOOK_CALLBACK_FN> fn);
/*
Calls a hyprctl command.