summaryrefslogtreecommitdiffstats
path: root/dwl.c
diff options
context:
space:
mode:
authorwochap <gean.marroquin@gmail.com>2024-07-12 11:30:17 -0500
committerSquibid <me@zacharyscheiman.com>2025-02-12 12:16:15 -0600
commitb5c3e1bb7654a00375bb2bc5b24388c2393d7db8 (patch)
tree20aea82716f507cad168b3ad6b823eef7b4909b2 /dwl.c
parent676596030c2c525cae703c2a5d853d11bbe1dded (diff)
downloaddwl-b5c3e1bb7654a00375bb2bc5b24388c2393d7db8.tar.gz
dwl-b5c3e1bb7654a00375bb2bc5b24388c2393d7db8.tar.bz2
dwl-b5c3e1bb7654a00375bb2bc5b24388c2393d7db8.zip
implement pointer-gestures-unstable-v1
Diffstat (limited to 'dwl.c')
-rw-r--r--dwl.c136
1 files changed, 136 insertions, 0 deletions
diff --git a/dwl.c b/dwl.c
index e34f41c..0f069ad 100644
--- a/dwl.c
+++ b/dwl.c
@@ -41,6 +41,7 @@
#include <wlr/types/wlr_output_power_management_v1.h>
#include <wlr/types/wlr_pointer.h>
#include <wlr/types/wlr_pointer_constraints_v1.h>
+#include <wlr/types/wlr_pointer_gestures_v1.h>
#include <wlr/types/wlr_presentation_time.h>
#include <wlr/types/wlr_primary_selection.h>
#include <wlr/types/wlr_primary_selection_v1.h>
@@ -280,6 +281,14 @@ static void arrangelayer(Monitor *m, struct wl_list *list,
static void arrangelayers(Monitor *m);
static void axisnotify(struct wl_listener *listener, void *data);
static void buttonpress(struct wl_listener *listener, void *data);
+static void swipe_begin(struct wl_listener *listener, void *data);
+static void swipe_update(struct wl_listener *listener, void *data);
+static void swipe_end(struct wl_listener *listener, void *data);
+static void pinch_begin(struct wl_listener *listener, void *data);
+static void pinch_update(struct wl_listener *listener, void *data);
+static void pinch_end(struct wl_listener *listener, void *data);
+static void hold_begin(struct wl_listener *listener, void *data);
+static void hold_end(struct wl_listener *listener, void *data);
static void chvt(const Arg *arg);
static void checkidleinhibitor(struct wlr_surface *exclude);
static void cleanup(void);
@@ -436,6 +445,7 @@ static struct wlr_virtual_keyboard_manager_v1 *virtual_keyboard_mgr;
static struct wlr_virtual_pointer_manager_v1 *virtual_pointer_mgr;
static struct wlr_cursor_shape_manager_v1 *cursor_shape_mgr;
static struct wlr_output_power_manager_v1 *power_mgr;
+static struct wlr_pointer_gestures_v1 *pointer_gestures;
static struct wlr_pointer_constraints_v1 *pointer_constraints;
static struct wlr_relative_pointer_manager_v1 *relative_pointer_mgr;
@@ -740,6 +750,122 @@ buttonpress(struct wl_listener *listener, void *data)
}
void
+swipe_begin(struct wl_listener *listener, void *data)
+{
+ struct wlr_pointer_swipe_begin_event *event = data;
+
+ // Forward swipe begin event to client
+ wlr_pointer_gestures_v1_send_swipe_begin(
+ pointer_gestures,
+ seat,
+ event->time_msec,
+ event->fingers
+ );
+}
+
+void
+swipe_update(struct wl_listener *listener, void *data)
+{
+ struct wlr_pointer_swipe_update_event *event = data;
+
+ // Forward swipe update event to client
+ wlr_pointer_gestures_v1_send_swipe_update(
+ pointer_gestures,
+ seat,
+ event->time_msec,
+ event->dx,
+ event->dy
+ );
+}
+
+void
+swipe_end(struct wl_listener *listener, void *data)
+{
+ struct wlr_pointer_swipe_end_event *event = data;
+
+ // Forward swipe end event to client
+ wlr_pointer_gestures_v1_send_swipe_end(
+ pointer_gestures,
+ seat,
+ event->time_msec,
+ event->cancelled
+ );
+}
+
+void
+pinch_begin(struct wl_listener *listener, void *data)
+{
+ struct wlr_pointer_pinch_begin_event *event = data;
+
+ // Forward pinch begin event to client
+ wlr_pointer_gestures_v1_send_pinch_begin(
+ pointer_gestures,
+ seat,
+ event->time_msec,
+ event->fingers
+ );
+}
+
+void
+pinch_update(struct wl_listener *listener, void *data)
+{
+ struct wlr_pointer_pinch_update_event *event = data;
+
+ // Forward pinch update event to client
+ wlr_pointer_gestures_v1_send_pinch_update(
+ pointer_gestures,
+ seat,
+ event->time_msec,
+ event->dx,
+ event->dy,
+ event->scale,
+ event->rotation
+ );
+}
+
+void
+pinch_end(struct wl_listener *listener, void *data)
+{
+ struct wlr_pointer_pinch_end_event *event = data;
+
+ // Forward pinch end event to client
+ wlr_pointer_gestures_v1_send_pinch_end(
+ pointer_gestures,
+ seat,
+ event->time_msec,
+ event->cancelled
+ );
+}
+
+void
+hold_begin(struct wl_listener *listener, void *data)
+{
+ struct wlr_pointer_hold_begin_event *event = data;
+
+ // Forward hold begin event to client
+ wlr_pointer_gestures_v1_send_hold_begin(
+ pointer_gestures,
+ seat,
+ event->time_msec,
+ event->fingers
+ );
+}
+
+void
+hold_end(struct wl_listener *listener, void *data)
+{
+ struct wlr_pointer_hold_end_event *event = data;
+
+ // Forward hold end event to client
+ wlr_pointer_gestures_v1_send_hold_end(
+ pointer_gestures,
+ seat,
+ event->time_msec,
+ event->cancelled
+ );
+}
+
+void
chvt(const Arg *arg)
{
wlr_session_change_vt(session, arg->ui);
@@ -3056,6 +3182,16 @@ setup(void)
wl_signal_add(&virtual_pointer_mgr->events.new_virtual_pointer,
&new_virtual_pointer);
+ pointer_gestures = wlr_pointer_gestures_v1_create(dpy);
+ LISTEN_STATIC(&cursor->events.swipe_begin, swipe_begin);
+ LISTEN_STATIC(&cursor->events.swipe_update, swipe_update);
+ LISTEN_STATIC(&cursor->events.swipe_end, swipe_end);
+ LISTEN_STATIC(&cursor->events.pinch_begin, pinch_begin);
+ LISTEN_STATIC(&cursor->events.pinch_update, pinch_update);
+ LISTEN_STATIC(&cursor->events.pinch_end, pinch_end);
+ LISTEN_STATIC(&cursor->events.hold_begin, hold_begin);
+ LISTEN_STATIC(&cursor->events.hold_end, hold_end);
+
seat = wlr_seat_create(dpy, "seat0");
wl_signal_add(&seat->events.request_set_cursor, &request_cursor);
wl_signal_add(&seat->events.request_set_selection, &request_set_sel);