diff options
| author | Vaxry <43317083+vaxerski@users.noreply.github.com> | 2026-02-22 23:30:10 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-02-22 23:30:10 +0000 |
| commit | b88813c7efa4b7b0c5fe01471c5fa5b67a61dc7e (patch) | |
| tree | 4454e82bc033d7e28a23ee372d0e3f48341d0aaa /src/protocols/core/DataDevice.cpp | |
| parent | b4ee4674f9a74e3d602c7fb17bc09f79d221583c (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/protocols/core/DataDevice.cpp')
| -rw-r--r-- | src/protocols/core/DataDevice.cpp | 28 |
1 files changed, 12 insertions, 16 deletions
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<CWlDataOffer> resource_, SP<IDataSource> source_) : m_source(source_), m_resource(resource_) { @@ -586,29 +586,26 @@ void CWLDataDeviceProtocol::initiateDrag(WP<CWLDataSourceResource> currentSource }); } - m_dnd.mouseButton = g_pHookSystem->hookDynamic("mouseButton", [this](void* self, SCallbackInfo& info, std::any e) { - auto E = std::any_cast<IPointer::SButtonEvent>(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<CTablet::STipEvent>(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<const Vector2D>(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<CWLDataSourceResource> 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<ITouch::SMotionEvent>(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<CWLDataSourceResource> 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); } }); |
