From 4ad739ec63c9a11f0537a884ae2a4c56d6bab10b Mon Sep 17 00:00:00 2001 From: Vaxry Date: Sat, 20 Apr 2024 20:16:42 +0100 Subject: HookSystem: improve callback safety --- src/plugins/PluginAPI.hpp | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) (limited to 'src/plugins/PluginAPI.hpp') 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 @@ -132,28 +132,20 @@ 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 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 fn); /* Calls a hyprctl command. -- cgit v1.2.3