]> git.mdlowis.com Git - proto/labwc.git/commitdiff
input: add hold-begin/-end gestures
authorJens Peters <jp7677@gmail.com>
Sun, 10 Nov 2024 18:22:22 +0000 (19:22 +0100)
committerConsolatis <35009135+Consolatis@users.noreply.github.com>
Mon, 11 Nov 2024 14:06:25 +0000 (15:06 +0100)
include/labwc.h
src/input/gestures.c

index 7d02f7ae68d3443f1dd69239b3756db0815f0529..6aa2a5b47f2d26e31bfd4e604d0a4866b7285daf 100644 (file)
@@ -179,6 +179,8 @@ struct seat {
        struct wl_listener swipe_begin;
        struct wl_listener swipe_update;
        struct wl_listener swipe_end;
+       struct wl_listener hold_begin;
+       struct wl_listener hold_end;
 
        struct wl_listener request_cursor;
        struct wl_listener request_set_shape;
index cbfd397fc77a206e676a10999547da1ce6f2d12d..4cb94c6f98614462d2aed5c730251c19cbb7df24 100644 (file)
@@ -84,6 +84,32 @@ handle_swipe_end(struct wl_listener *listener, void *data)
                seat->seat, event->time_msec, event->cancelled);
 }
 
+static void
+handle_hold_begin(struct wl_listener *listener, void *data)
+{
+       struct seat *seat = wl_container_of(listener, seat, hold_begin);
+       struct wlr_pointer_hold_begin_event *event = data;
+
+       idle_manager_notify_activity(seat->seat);
+       cursor_set_visible(seat, /* visible */ true);
+
+       wlr_pointer_gestures_v1_send_hold_begin(seat->pointer_gestures,
+               seat->seat, event->time_msec, event->fingers);
+}
+
+static void
+handle_hold_end(struct wl_listener *listener, void *data)
+{
+       struct seat *seat = wl_container_of(listener, seat, hold_end);
+       struct wlr_pointer_hold_end_event *event = data;
+
+       idle_manager_notify_activity(seat->seat);
+       cursor_set_visible(seat, /* visible */ true);
+
+       wlr_pointer_gestures_v1_send_hold_end(seat->pointer_gestures,
+               seat->seat, event->time_msec, event->cancelled);
+}
+
 void
 gestures_init(struct seat *seat)
 {
@@ -95,6 +121,8 @@ gestures_init(struct seat *seat)
        CONNECT_SIGNAL(seat->cursor, seat, swipe_begin);
        CONNECT_SIGNAL(seat->cursor, seat, swipe_update);
        CONNECT_SIGNAL(seat->cursor, seat, swipe_end);
+       CONNECT_SIGNAL(seat->cursor, seat, hold_begin);
+       CONNECT_SIGNAL(seat->cursor, seat, hold_end);
 }
 
 void
@@ -106,4 +134,6 @@ gestures_finish(struct seat *seat)
        wl_list_remove(&seat->swipe_begin.link);
        wl_list_remove(&seat->swipe_update.link);
        wl_list_remove(&seat->swipe_end.link);
+       wl_list_remove(&seat->hold_begin.link);
+       wl_list_remove(&seat->hold_end.link);
 }