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/protocols/core/DataDevice.cpp | 28 ++++++++++++---------------- 1 file changed, 12 insertions(+), 16 deletions(-) (limited to 'src/protocols/core/DataDevice.cpp') diff --git a/src/protocols/core/DataDevice.cpp b/src/protocols/core/DataDevice.cpp index 41f07273..22ccae6c 100644 --- a/src/protocols/core/DataDevice.cpp +++ b/src/protocols/core/DataDevice.cpp @@ -10,11 +10,11 @@ #include "../../xwayland/XWayland.hpp" #include "../../xwayland/Server.hpp" #include "../../managers/input/InputManager.hpp" -#include "../../managers/HookSystemManager.hpp" #include "../../managers/cursor/CursorShapeOverrideController.hpp" #include "../../helpers/Monitor.hpp" #include "../../render/Renderer.hpp" #include "../../xwayland/Dnd.hpp" +#include "../../event/EventBus.hpp" using namespace Hyprutils::OS; CWLDataOfferResource::CWLDataOfferResource(SP resource_, SP source_) : m_source(source_), m_resource(resource_) { @@ -586,29 +586,26 @@ void CWLDataDeviceProtocol::initiateDrag(WP currentSource }); } - m_dnd.mouseButton = g_pHookSystem->hookDynamic("mouseButton", [this](void* self, SCallbackInfo& info, std::any e) { - auto E = std::any_cast(e); - if (E.state == WL_POINTER_BUTTON_STATE_RELEASED) { + m_dnd.mouseButton = Event::bus()->m_events.input.mouse.button.listen([this](IPointer::SButtonEvent e, Event::SCallbackInfo&) { + if (e.state == WL_POINTER_BUTTON_STATE_RELEASED) { LOGM(Log::DEBUG, "Dropping drag on mouseUp"); dropDrag(); } }); - m_dnd.touchUp = g_pHookSystem->hookDynamic("touchUp", [this](void* self, SCallbackInfo& info, std::any e) { + m_dnd.touchUp = Event::bus()->m_events.input.touch.up.listen([this](ITouch::SUpEvent e, Event::SCallbackInfo&) { LOGM(Log::DEBUG, "Dropping drag on touchUp"); dropDrag(); }); - m_dnd.tabletTip = g_pHookSystem->hookDynamic("tabletTip", [this](void* self, SCallbackInfo& info, std::any e) { - auto E = std::any_cast(e); - if (!E.in) { + m_dnd.tabletTip = Event::bus()->m_events.input.tablet.tip.listen([this](CTablet::STipEvent e, Event::SCallbackInfo&) { + if (!e.in) { LOGM(Log::DEBUG, "Dropping drag on tablet tipUp"); dropDrag(); } }); - m_dnd.mouseMove = g_pHookSystem->hookDynamic("mouseMove", [this](void* self, SCallbackInfo& info, std::any e) { - auto V = std::any_cast(e); + m_dnd.mouseMove = Event::bus()->m_events.input.mouse.move.listen([this](Vector2D pos, Event::SCallbackInfo&) { if (m_dnd.focusedDevice && g_pSeatManager->m_state.dndPointerFocus) { auto surf = Desktop::View::CWLSurface::fromResource(g_pSeatManager->m_state.dndPointerFocus.lock()); @@ -620,13 +617,12 @@ void CWLDataDeviceProtocol::initiateDrag(WP currentSource if (!box.has_value()) return; - m_dnd.focusedDevice->sendMotion(Time::millis(Time::steadyNow()), V - box->pos()); - LOGM(Log::DEBUG, "Drag motion {}", V - box->pos()); + m_dnd.focusedDevice->sendMotion(Time::millis(Time::steadyNow()), pos - box->pos()); + LOGM(Log::DEBUG, "Drag motion {}", pos - box->pos()); } }); - m_dnd.touchMove = g_pHookSystem->hookDynamic("touchMove", [this](void* self, SCallbackInfo& info, std::any e) { - auto E = std::any_cast(e); + m_dnd.touchMove = Event::bus()->m_events.input.touch.motion.listen([this](ITouch::SMotionEvent e, Event::SCallbackInfo&) { if (m_dnd.focusedDevice && g_pSeatManager->m_state.dndPointerFocus) { auto surf = Desktop::View::CWLSurface::fromResource(g_pSeatManager->m_state.dndPointerFocus.lock()); @@ -638,8 +634,8 @@ void CWLDataDeviceProtocol::initiateDrag(WP currentSource if (!box.has_value()) return; - m_dnd.focusedDevice->sendMotion(E.timeMs, E.pos); - LOGM(Log::DEBUG, "Drag motion {}", E.pos); + m_dnd.focusedDevice->sendMotion(e.timeMs, e.pos); + LOGM(Log::DEBUG, "Drag motion {}", e.pos); } }); -- cgit v1.2.3