Skip to content

Commit

Permalink
Add hold begin and end support as well
Browse files Browse the repository at this point in the history
  • Loading branch information
serebit committed Oct 1, 2023
1 parent 7cb956e commit b49aeea
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/input/cursor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,20 @@ static void gesture_swipe_end_notify(wl_listener* listener, void* data) {
wlr_pointer_gestures_v1_send_swipe_end(cursor.pointer_gestures, cursor.seat.seat, event->time_msec, event->cancelled);
}

static void gesture_hold_begin_notify(wl_listener* listener, void* data) {
Cursor& cursor = magpie_container_of(listener, cursor, gesture_hold_begin);
auto* event = static_cast<wlr_pointer_hold_begin_event*>(data);

wlr_pointer_gestures_v1_send_hold_begin(cursor.pointer_gestures, cursor.seat.seat, event->time_msec, event->fingers);
}

static void gesture_hold_end_notify(wl_listener* listener, void* data) {
Cursor& cursor = magpie_container_of(listener, cursor, gesture_hold_end);
auto* event = static_cast<wlr_pointer_hold_end_event*>(data);

wlr_pointer_gestures_v1_send_hold_end(cursor.pointer_gestures, cursor.seat.seat, event->time_msec, event->cancelled);
}

Cursor::Cursor(Seat& seat) noexcept : listeners(*this), seat(seat) {
/*
* Creates a cursor, which is a wlroots utility for tracking the cursor
Expand Down Expand Up @@ -264,6 +278,10 @@ Cursor::Cursor(Seat& seat) noexcept : listeners(*this), seat(seat) {
wl_signal_add(&cursor->events.swipe_update, &listeners.gesture_swipe_update);
listeners.gesture_swipe_end.notify = gesture_swipe_end_notify;
wl_signal_add(&cursor->events.swipe_end, &listeners.gesture_swipe_end);
listeners.gesture_hold_begin.notify = gesture_hold_begin_notify;
wl_signal_add(&cursor->events.hold_begin, &listeners.gesture_swipe_update);
listeners.gesture_hold_end.notify = gesture_hold_end_notify;
wl_signal_add(&cursor->events.hold_end, &listeners.gesture_swipe_end);
}

void Cursor::attach_input_device(wlr_input_device* device) {
Expand Down
2 changes: 2 additions & 0 deletions src/input/cursor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ class Cursor {
wl_listener gesture_swipe_begin;
wl_listener gesture_swipe_update;
wl_listener gesture_swipe_end;
wl_listener gesture_hold_begin;
wl_listener gesture_hold_end;
Listeners(Cursor& parent) noexcept : parent(parent) {}
};

Expand Down

0 comments on commit b49aeea

Please sign in to comment.