HookSystem: improve callback safety
This commit is contained in:
parent
1055e6bee6
commit
4ad739ec63
18 changed files with 89 additions and 105 deletions
|
|
@ -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<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.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue