mirror of
https://codeberg.org/dwl/dwl.git
synced 2026-04-06 07:15:31 -04:00
apply gestures
This commit is contained in:
parent
6d3ae4d787
commit
7b68298e19
8 changed files with 581 additions and 0 deletions
16
patches/pointer-gestures-unstable-v1/README.md
Normal file
16
patches/pointer-gestures-unstable-v1/README.md
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
### Description
|
||||
Forward the following events to client:
|
||||
swipe_begin, swipe_update, swipe_end, pinch_begin, pinch_update and pinch_end
|
||||
|
||||
This patch allows you to pinch zoom in Chrome, for example. In combination with the following patches [gestures](https://codeberg.org/dwl/dwl-patches/wiki/gestures) and [shiftview](https://codeberg.org/dwl/dwl-patches/wiki/shiftview), it would allow you to switch workspaces by performing a 3-finger swipe on your touchpad.
|
||||
|
||||
|
||||
### Download
|
||||
- [git branch](https://codeberg.org/wochap/dwl/src/branch/v0.5/pointer-gestures-unstable-v1)
|
||||
- [2024-07-12](https://codeberg.org/dwl/dwl-patches/raw/commit/05dbce217b676e989b0fc9e0eecf83b386ac9e07/patches/pointer-gestures-unstable-v1/pointer-gestures-unstable-v1.patch)
|
||||
- [2024-07-09](https://codeberg.org/dwl/dwl-patches/raw/commit/2322f3efeae8da44227e0acc760ffd3dea153716/patches/pointer-gestures-unstable-v1/pointer-gestures-unstable-v1.patch)
|
||||
- [2024-04-11](https://codeberg.org/dwl/dwl-patches/raw/commit/c676de59d51e613bd52ac46c77a24b1cac9a61a1/pointer-gestures-unstable-v1/pointer-gestures-unstable-v1.patch)
|
||||
- [v0.5](https://codeberg.org/dwl/dwl-patches/raw/commit/fc4146f3068dcd46035a2a11fe9d6109a97ae6d6/pointer-gestures-unstable-v1/pointer-gestures-unstable-v1.patch)
|
||||
|
||||
### Authors
|
||||
- [wochap](https://codeberg.org/wochap)
|
||||
|
|
@ -0,0 +1,186 @@
|
|||
From be7e98d28fc59aab67026e7d5efdcaeb26029713 Mon Sep 17 00:00:00 2001
|
||||
From: wochap <gean.marroquin@gmail.com>
|
||||
Date: Fri, 12 Jul 2024 11:30:17 -0500
|
||||
Subject: [PATCH] implement pointer-gestures-unstable-v1
|
||||
|
||||
---
|
||||
dwl.c | 136 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
1 file changed, 136 insertions(+)
|
||||
|
||||
diff --git a/dwl.c b/dwl.c
|
||||
index dc0437e..e5805b1 100644
|
||||
--- a/dwl.c
|
||||
+++ b/dwl.c
|
||||
@@ -38,6 +38,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>
|
||||
@@ -250,6 +251,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);
|
||||
@@ -383,6 +392,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;
|
||||
@@ -644,6 +654,122 @@ buttonpress(struct wl_listener *listener, void *data)
|
||||
event->time_msec, event->button, event->state);
|
||||
}
|
||||
|
||||
+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)
|
||||
{
|
||||
@@ -2556,6 +2682,16 @@ setup(void)
|
||||
virtual_pointer_mgr = wlr_virtual_pointer_manager_v1_create(dpy);
|
||||
LISTEN_STATIC(&virtual_pointer_mgr->events.new_virtual_pointer, virtualpointer);
|
||||
|
||||
+ 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");
|
||||
LISTEN_STATIC(&seat->events.request_set_cursor, setcursor);
|
||||
LISTEN_STATIC(&seat->events.request_set_selection, setsel);
|
||||
--
|
||||
2.45.1
|
||||
Loading…
Add table
Add a link
Reference in a new issue