summaryrefslogtreecommitdiff
path: root/src/plugins
diff options
context:
space:
mode:
authorVaxry <43317083+vaxerski@users.noreply.github.com>2026-02-22 23:30:10 +0000
committerGitHub <noreply@github.com>2026-02-22 23:30:10 +0000
commitb88813c7efa4b7b0c5fe01471c5fa5b67a61dc7e (patch)
tree4454e82bc033d7e28a23ee372d0e3f48341d0aaa /src/plugins
parentb4ee4674f9a74e3d602c7fb17bc09f79d221583c (diff)
event: refactor HookSystem into a typed event bus (#13333)
Refactors the old HookSystem into a typed event bus with clear separation, discovery and types.
Diffstat (limited to 'src/plugins')
-rw-r--r--src/plugins/PluginAPI.cpp11
-rw-r--r--src/plugins/PluginAPI.hpp7
-rw-r--r--src/plugins/PluginSystem.cpp9
-rw-r--r--src/plugins/PluginSystem.hpp24
4 files changed, 27 insertions, 24 deletions
diff --git a/src/plugins/PluginAPI.cpp b/src/plugins/PluginAPI.cpp
index 57081183..5f89da53 100644
--- a/src/plugins/PluginAPI.cpp
+++ b/src/plugins/PluginAPI.cpp
@@ -2,7 +2,6 @@
#include "../Compositor.hpp"
#include "../debug/HyprCtl.hpp"
#include "../plugins/PluginSystem.hpp"
-#include "../managers/HookSystemManager.hpp"
#include "../managers/eventLoop/EventLoopManager.hpp"
#include "../config/ConfigManager.hpp"
#include "../debug/HyprNotificationOverlay.hpp"
@@ -38,9 +37,9 @@ APICALL SP<HOOK_CALLBACK_FN> HyprlandAPI::registerCallbackDynamic(HANDLE handle,
if (!PLUGIN)
return nullptr;
- auto PFN = g_pHookSystem->hookDynamic(event, fn, handle);
- PLUGIN->m_registeredCallbacks.emplace_back(std::make_pair<>(event, WP<HOOK_CALLBACK_FN>(PFN)));
- return PFN;
+ //auto PFN = g_pHookSystem->hookDynamic(event, fn, handle);
+ //PLUGIN->m_registeredCallbacks.emplace_back(std::make_pair<>(event, WP<HOOK_CALLBACK_FN>(PFN)));
+ return nullptr;
}
APICALL bool HyprlandAPI::unregisterCallback(HANDLE handle, SP<HOOK_CALLBACK_FN> fn) {
@@ -49,8 +48,8 @@ APICALL bool HyprlandAPI::unregisterCallback(HANDLE handle, SP<HOOK_CALLBACK_FN>
if (!PLUGIN)
return false;
- g_pHookSystem->unhook(fn);
- std::erase_if(PLUGIN->m_registeredCallbacks, [&](const auto& other) { return other.second.lock() == fn; });
+ //g_pHookSystem->unhook(fn);
+ // std::erase_if(PLUGIN->m_registeredCallbacks, [&](const auto& other) { return other.second.lock() == fn; });
return true;
}
diff --git a/src/plugins/PluginAPI.hpp b/src/plugins/PluginAPI.hpp
index 568b2e0f..77bb9926 100644
--- a/src/plugins/PluginAPI.hpp
+++ b/src/plugins/PluginAPI.hpp
@@ -70,12 +70,15 @@ struct SVersionInfo {
class IHyprLayout;
class IHyprWindowDecoration;
struct SConfigValue;
+class Hypr_dummyClass {};
namespace Layout {
class ITiledAlgorithm;
class IFloatingAlgorithm;
};
+using HOOK_CALLBACK_FN = Hypr_dummyClass;
+
/*
These methods are for the plugin to implement
Methods marked with REQUIRED are required.
@@ -148,6 +151,8 @@ namespace HyprlandAPI {
APICALL Hyprlang::CConfigValue* getConfigValue(HANDLE handle, const std::string& name);
/*
+ Deprecated: doesn't do anything anymore, use Event::bus()
+
Register a dynamic (function) callback to a selected event.
Pointer will be free'd by Hyprland on unregisterCallback().
@@ -155,7 +160,7 @@ namespace HyprlandAPI {
WARNING: Losing this pointer will unregister the callback!
*/
- APICALL [[nodiscard]] SP<HOOK_CALLBACK_FN> registerCallbackDynamic(HANDLE handle, const std::string& event, HOOK_CALLBACK_FN fn);
+ APICALL [[deprecated]] [[nodiscard]] SP<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.
diff --git a/src/plugins/PluginSystem.cpp b/src/plugins/PluginSystem.cpp
index 7a798ac4..3bd8f473 100644
--- a/src/plugins/PluginSystem.cpp
+++ b/src/plugins/PluginSystem.cpp
@@ -4,7 +4,6 @@
#include <ranges>
#include "../config/ConfigManager.hpp"
#include "../debug/HyprCtl.hpp"
-#include "../managers/HookSystemManager.hpp"
#include "../managers/eventLoop/EventLoopManager.hpp"
#include "../managers/permissions/DynamicPermissionManager.hpp"
#include "../debug/HyprNotificationOverlay.hpp"
@@ -151,10 +150,10 @@ void CPluginSystem::unloadPlugin(const CPlugin* plugin, bool eject) {
exitFunc();
}
- for (auto const& [k, v] : plugin->m_registeredCallbacks) {
- if (const auto SHP = v.lock())
- g_pHookSystem->unhook(SHP);
- }
+ // for (auto const& [k, v] : plugin->m_registeredCallbacks) {
+ // if (const auto SHP = v.lock())
+ // g_pHookSystem->unhook(SHP);
+ // }
for (const auto& l : plugin->m_registeredAlgos) {
Layout::Supplementary::algoMatcher()->unregisterAlgo(l);
diff --git a/src/plugins/PluginSystem.hpp b/src/plugins/PluginSystem.hpp
index ca980d12..85afaefa 100644
--- a/src/plugins/PluginSystem.hpp
+++ b/src/plugins/PluginSystem.hpp
@@ -12,22 +12,22 @@ class IHyprWindowDecoration;
class CPlugin {
public:
- std::string m_name = "";
- std::string m_description = "";
- std::string m_author = "";
- std::string m_version = "";
+ std::string m_name = "";
+ std::string m_description = "";
+ std::string m_author = "";
+ std::string m_version = "";
- std::string m_path = "";
+ std::string m_path = "";
- bool m_loadedWithConfig = false;
+ bool m_loadedWithConfig = false;
- HANDLE m_handle = nullptr;
+ HANDLE m_handle = nullptr;
- std::vector<IHyprWindowDecoration*> m_registeredDecorations;
- std::vector<std::pair<std::string, WP<HOOK_CALLBACK_FN>>> m_registeredCallbacks;
- std::vector<std::string> m_registeredDispatchers;
- std::vector<WP<SHyprCtlCommand>> m_registeredHyprctlCommands;
- std::vector<std::string> m_registeredAlgos;
+ std::vector<IHyprWindowDecoration*> m_registeredDecorations;
+ //std::vector<std::pair<std::string, WP<HOOK_CALLBACK_FN>>> m_registeredCallbacks;
+ std::vector<std::string> m_registeredDispatchers;
+ std::vector<WP<SHyprCtlCommand>> m_registeredHyprctlCommands;
+ std::vector<std::string> m_registeredAlgos;
};
class CPluginSystem {