From e5d143b2386c3773f6fb5176752a1b381d3ee7a5 Mon Sep 17 00:00:00 2001 From: vaxerski Date: Thu, 22 Sep 2022 21:14:02 +0100 Subject: [PATCH] support more wlr_cursor events --- src/Compositor.cpp | 3 +++ src/events/Devices.cpp | 12 ++++++++++++ src/events/Events.hpp | 4 ++++ src/managers/input/InputManager.hpp | 3 +++ src/managers/input/Touch.cpp | 10 +++++++++- 5 files changed, 31 insertions(+), 1 deletion(-) diff --git a/src/Compositor.cpp b/src/Compositor.cpp index 6972875e..42f1267a 100644 --- a/src/Compositor.cpp +++ b/src/Compositor.cpp @@ -198,6 +198,9 @@ void CCompositor::initAllSignals() { addWLSignal(&m_sWLRCursor->events.touch_down, &Events::listen_touchBegin, m_sWLRCursor, "WLRCursor"); addWLSignal(&m_sWLRCursor->events.touch_up, &Events::listen_touchEnd, m_sWLRCursor, "WLRCursor"); addWLSignal(&m_sWLRCursor->events.touch_motion, &Events::listen_touchUpdate, m_sWLRCursor, "WLRCursor"); + addWLSignal(&m_sWLRCursor->events.touch_frame, &Events::listen_touchFrame, m_sWLRCursor, "WLRCursor"); + addWLSignal(&m_sWLRCursor->events.hold_begin, &Events::listen_holdBegin, m_sWLRCursor, "WLRCursor"); + addWLSignal(&m_sWLRCursor->events.hold_end, &Events::listen_holdEnd, m_sWLRCursor, "WLRCursor"); addWLSignal(&m_sWLRBackend->events.new_input, &Events::listen_newInput, m_sWLRBackend, "Backend"); addWLSignal(&m_sSeat.seat->events.request_set_cursor, &Events::listen_requestMouse, &m_sSeat, "Seat"); addWLSignal(&m_sSeat.seat->events.request_set_selection, &Events::listen_requestSetSel, &m_sSeat, "Seat"); diff --git a/src/events/Devices.cpp b/src/events/Devices.cpp index b8aeae39..8dea879f 100644 --- a/src/events/Devices.cpp +++ b/src/events/Devices.cpp @@ -206,4 +206,16 @@ void Events::listener_touchEnd(wl_listener* listener, void* data) { void Events::listener_touchUpdate(wl_listener* listener, void* data) { g_pInputManager->onTouchMove((wlr_touch_motion_event*)data); +} + +void Events::listener_touchFrame(wl_listener* listener, void* data) { + wlr_seat_touch_notify_frame(g_pCompositor->m_sSeat.seat); +} + +void Events::listener_holdBegin(wl_listener* listener, void* data) { + g_pInputManager->onPointerHoldBegin((wlr_pointer_hold_begin_event*)data); +} + +void Events::listener_holdEnd(wl_listener* listener, void* data) { + g_pInputManager->onPointerHoldEnd((wlr_pointer_hold_end_event*)data); } \ No newline at end of file diff --git a/src/events/Events.hpp b/src/events/Events.hpp index a7c8c5bc..8ccf3f13 100644 --- a/src/events/Events.hpp +++ b/src/events/Events.hpp @@ -152,4 +152,8 @@ namespace Events { LISTENER(touchBegin); LISTENER(touchEnd); LISTENER(touchUpdate); + LISTENER(touchFrame); + + LISTENER(holdBegin); + LISTENER(holdEnd); }; \ No newline at end of file diff --git a/src/managers/input/InputManager.hpp b/src/managers/input/InputManager.hpp index f212e610..17fd6271 100644 --- a/src/managers/input/InputManager.hpp +++ b/src/managers/input/InputManager.hpp @@ -63,6 +63,9 @@ public: void onTouchUp(wlr_touch_up_event*); void onTouchMove(wlr_touch_motion_event*); + void onPointerHoldBegin(wlr_pointer_hold_begin_event*); + void onPointerHoldEnd(wlr_pointer_hold_end_event*); + STouchData m_sTouchData; // for dragging floating windows diff --git a/src/managers/input/Touch.cpp b/src/managers/input/Touch.cpp index 5d97369f..c48f7473 100644 --- a/src/managers/input/Touch.cpp +++ b/src/managers/input/Touch.cpp @@ -40,4 +40,12 @@ void CInputManager::onTouchMove(wlr_touch_motion_event* e){ wlr_seat_touch_notify_motion(g_pCompositor->m_sSeat.seat, e->time_msec, e->touch_id, local.x, local.y); } -} \ No newline at end of file +} + +void CInputManager::onPointerHoldBegin(wlr_pointer_hold_begin_event* e) { + wlr_pointer_gestures_v1_send_hold_begin(g_pCompositor->m_sWLRPointerGestures, g_pCompositor->m_sSeat.seat, e->time_msec, e->fingers); +} + +void CInputManager::onPointerHoldEnd(wlr_pointer_hold_end_event* e) { + wlr_pointer_gestures_v1_send_hold_end(g_pCompositor->m_sWLRPointerGestures, g_pCompositor->m_sSeat.seat, e->time_msec, e->cancelled); +}