diff options
| author | Vaxry <vaxry@vaxry.net> | 2024-04-22 15:50:01 +0100 |
|---|---|---|
| committer | Vaxry <vaxry@vaxry.net> | 2024-04-22 15:50:23 +0100 |
| commit | e91513a5e8953cfbb69320d94e495ccf2d4d58f3 (patch) | |
| tree | bf6d71e992e7b84b22e1c5c689169fb0393027be /src/plugins/PluginAPI.hpp | |
| parent | 450343b7b83ba659f6a932092aff922cc1cddd2b (diff) | |
pluginapi: unregister callbacks on lost ptrs
Diffstat (limited to 'src/plugins/PluginAPI.hpp')
| -rw-r--r-- | src/plugins/PluginAPI.hpp | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/plugins/PluginAPI.hpp b/src/plugins/PluginAPI.hpp index 62db8e3b..78f88c21 100644 --- a/src/plugins/PluginAPI.hpp +++ b/src/plugins/PluginAPI.hpp @@ -137,15 +137,19 @@ namespace HyprlandAPI { Pointer will be free'd by Hyprland on unregisterCallback(). returns: a pointer to the newly allocated function. nullptr on fail. + + WARNING: Losing this pointer will unregister the callback! */ - APICALL std::shared_ptr<HOOK_CALLBACK_FN> registerCallbackDynamic(HANDLE handle, const std::string& event, HOOK_CALLBACK_FN fn); + APICALL [[nodiscard]] 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 + + Deprecated: just reset the pointer you received with registerCallbackDynamic */ - APICALL bool unregisterCallback(HANDLE handle, std::shared_ptr<HOOK_CALLBACK_FN> fn); + APICALL [[deprecated]] bool unregisterCallback(HANDLE handle, std::shared_ptr<HOOK_CALLBACK_FN> fn); /* Calls a hyprctl command. |
