From b88813c7efa4b7b0c5fe01471c5fa5b67a61dc7e Mon Sep 17 00:00:00 2001 From: Vaxry <43317083+vaxerski@users.noreply.github.com> Date: Sun, 22 Feb 2026 23:30:10 +0000 Subject: event: refactor HookSystem into a typed event bus (#13333) Refactors the old HookSystem into a typed event bus with clear separation, discovery and types. --- src/event/EventBus.cpp | 8 +++ src/event/EventBus.hpp | 142 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 150 insertions(+) create mode 100644 src/event/EventBus.cpp create mode 100644 src/event/EventBus.hpp (limited to 'src/event') diff --git a/src/event/EventBus.cpp b/src/event/EventBus.cpp new file mode 100644 index 00000000..f06c3984 --- /dev/null +++ b/src/event/EventBus.cpp @@ -0,0 +1,8 @@ +#include "EventBus.hpp" + +using namespace Event; + +UP& Event::bus() { + static UP p = makeUnique(); + return p; +} diff --git a/src/event/EventBus.hpp b/src/event/EventBus.hpp new file mode 100644 index 00000000..8f59acbd --- /dev/null +++ b/src/event/EventBus.hpp @@ -0,0 +1,142 @@ +#pragma once + +#include "../helpers/memory/Memory.hpp" +#include "../helpers/signal/Signal.hpp" +#include "../helpers/math/Math.hpp" + +#include "../devices/IPointer.hpp" +#include "../devices/IKeyboard.hpp" +#include "../devices/Tablet.hpp" +#include "../devices/ITouch.hpp" + +#include "../desktop/DesktopTypes.hpp" + +#include "../SharedDefs.hpp" + +namespace Desktop { + enum eFocusReason : uint8_t; +} +namespace Event { + struct SCallbackInfo { + bool cancelled = false; /* on cancellable events, will cancel the event. */ + }; + + class CEventBus { + public: + CEventBus() = default; + ~CEventBus() = default; + + template + using Event = CSignalT; + + template + using Cancellable = CSignalT; + + struct { + Event<> ready; + Event<> tick; + + struct { + Event open; + Event openEarly; + Event destroy; + Event close; + Event active; + Event urgent; + Event title; + Event class_; + Event pin; + Event fullscreen; + Event updateRules; + Event moveToWorkspace; + } window; + + struct { + Event opened; + Event closed; + } layer; + + struct { + struct { + Cancellable move; + Cancellable button; + Cancellable axis; + } mouse; + + struct { + Cancellable key; + Event, const std::string&> layout; + Event> focus; + } keyboard; + + struct { + Cancellable axis; + Cancellable button; + Cancellable proximity; + Cancellable tip; + } tablet; + + struct { + Cancellable cancel; + Cancellable down; + Cancellable up; + Cancellable motion; + } touch; + } input; + + struct { + Event pre; + Event stage; + } render; + + struct { + Event state; + } screenshare; + + struct { + struct { + Cancellable begin; + Cancellable end; + Cancellable update; + } swipe; + + struct { + Cancellable begin; + Cancellable end; + Cancellable update; + } pinch; + } gesture; + + struct { + Event newMon; + Event preAdded; + Event added; + Event preRemoved; + Event removed; + Event preCommit; + Event focused; + + Event<> layoutChanged; + } monitor; + + struct { + Event moveToMonitor; + Event active; + Event created; + Event removed; + } workspace; + + struct { + Event<> preReload; + Event<> reloaded; + } config; + + struct { + Event submap; + } keybinds; + + } m_events; + }; + + UP& bus(); +}; \ No newline at end of file -- cgit v1.2.3