diff options
| author | Vaxry <vaxry@vaxry.net> | 2024-12-19 20:23:32 +0000 |
|---|---|---|
| committer | Vaxry <vaxry@vaxry.net> | 2024-12-19 20:23:32 +0000 |
| commit | 71dc9f6128b8d2e382b2a574d2d5f15e2d907f3a (patch) | |
| tree | 0b677e89a5bd3ffe2942078bd91bb0933ceb8ee7 /src/plugins | |
| parent | fd67ee9ecdc7207939fe1dcea9b81050ec7d58c4 (diff) | |
pluginAPI: add register dispatcher v2
Diffstat (limited to 'src/plugins')
| -rw-r--r-- | src/plugins/PluginAPI.cpp | 13 | ||||
| -rw-r--r-- | src/plugins/PluginAPI.hpp | 11 |
2 files changed, 23 insertions, 1 deletions
diff --git a/src/plugins/PluginAPI.cpp b/src/plugins/PluginAPI.cpp index 4172a856..5e1d9e58 100644 --- a/src/plugins/PluginAPI.cpp +++ b/src/plugins/PluginAPI.cpp @@ -202,6 +202,19 @@ APICALL bool HyprlandAPI::addDispatcher(HANDLE handle, const std::string& name, return true; } +APICALL bool HyprlandAPI::addDispatcherV2(HANDLE handle, const std::string& name, std::function<SDispatchResult(std::string)> handler) { + auto* const PLUGIN = g_pPluginSystem->getPluginByHandle(handle); + + if (!PLUGIN) + return false; + + PLUGIN->registeredDispatchers.push_back(name); + + g_pKeybindManager->m_mDispatchers[name] = handler; + + return true; +} + APICALL bool HyprlandAPI::removeDispatcher(HANDLE handle, const std::string& name) { auto* const PLUGIN = g_pPluginSystem->getPluginByHandle(handle); diff --git a/src/plugins/PluginAPI.hpp b/src/plugins/PluginAPI.hpp index 6b8c35f0..96c32bf1 100644 --- a/src/plugins/PluginAPI.hpp +++ b/src/plugins/PluginAPI.hpp @@ -236,8 +236,17 @@ namespace HyprlandAPI { Adds a keybind dispatcher. returns: true on success. False otherwise. + + DEPRECATED: use addDispatcherV2 + */ + APICALL [[deprecated]] bool addDispatcher(HANDLE handle, const std::string& name, std::function<void(std::string)> handler); + + /* + Adds a keybind dispatcher. + + returns: true on success. False otherwise. */ - APICALL bool addDispatcher(HANDLE handle, const std::string& name, std::function<void(std::string)> handler); + APICALL bool addDispatcherV2(HANDLE handle, const std::string& name, std::function<SDispatchResult(std::string)> handler); /* Removes a keybind dispatcher. |
