event: refactor HookSystem into a typed event bus (#13333)

Refactors the old HookSystem into a typed event bus with clear
separation,
discovery and types.
This commit is contained in:
Vaxry 2026-02-22 23:30:10 +00:00 committed by GitHub
parent b4ee4674f9
commit b88813c7ef
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
58 changed files with 493 additions and 516 deletions

View file

@ -1,9 +1,8 @@
#include "ExtWorkspace.hpp"
#include "../Compositor.hpp"
#include "../managers/HookSystemManager.hpp"
#include "../managers/eventLoop/EventLoopManager.hpp"
#include "../event/EventBus.hpp"
#include <algorithm>
#include <any>
#include <utility>
#include "core/Output.hpp"
@ -297,17 +296,13 @@ void CExtWorkspaceManagerResource::onWorkspaceCreated(const PHLWORKSPACE& worksp
}
CExtWorkspaceProtocol::CExtWorkspaceProtocol(const wl_interface* iface, const int& ver, const std::string& name) : IWaylandProtocol(iface, ver, name) {
static auto P1 = g_pHookSystem->hookDynamic("createWorkspace", [this](void* self, SCallbackInfo& info, std::any data) {
auto workspace = std::any_cast<CWorkspace*>(data)->m_self.lock();
static auto P1 = Event::bus()->m_events.workspace.created.listen([this](PHLWORKSPACEREF workspace) {
for (auto const& m : m_managers) {
m->onWorkspaceCreated(workspace);
m->onWorkspaceCreated(workspace.lock());
}
});
static auto P2 = g_pHookSystem->hookDynamic("monitorAdded", [this](void* self, SCallbackInfo& info, std::any data) {
auto monitor = std::any_cast<PHLMONITOR>(data);
static auto P2 = Event::bus()->m_events.monitor.added.listen([this](PHLMONITOR monitor) {
for (auto const& m : m_managers) {
m->onMonitorCreated(monitor);
}