Update tablet-input patch

This commit is contained in:
A Frederick Christensen 2025-05-17 23:46:46 -05:00
parent 38d814e1b0
commit fd664f946d
No known key found for this signature in database
GPG Key ID: 6183FA655784FC36
2 changed files with 47 additions and 33 deletions

View File

@ -16,7 +16,7 @@ There was discussion of this matter in [Issue #141](https://codeberg.org/dwl/dwl
### Download ### Download
- [git branch](https://codeberg.org/fauxmight/dwl/src/branch/tablet-input) - [git branch](https://codeberg.org/fauxmight/dwl/src/branch/tablet-input)
- [main 2025-01-01](https://codeberg.org/dwl/dwl-patches/raw/branch/main/patches/tablet-input/tablet-input.patch) - [main 2025-05-18](https://codeberg.org/dwl/dwl-patches/raw/branch/main/patches/tablet-input/tablet-input.patch)
- [0.7](https://codeberg.org/dwl/dwl-patches/raw/branch/main/patches/tablet-input/tablet-input-0.7.patch) - [0.7](https://codeberg.org/dwl/dwl-patches/raw/branch/main/patches/tablet-input/tablet-input-0.7.patch)
### Authors ### Authors

View File

@ -1,16 +1,16 @@
From e504dc0fccfc3994962f03dc824d8907c6afc64f Mon Sep 17 00:00:00 2001 From 0659663b7eb9cafbd4f86779084765aa838e29cd Mon Sep 17 00:00:00 2001
From: choc <notchoc@proton.me> From: A Frederick Christensen <dwl@ivories.org>
Date: Sat, 4 May 2024 01:16:12 +0800 Date: Sat, 17 May 2025 23:26:15 -0500
Subject: [PATCH] implement wlr-tablet-v2 Subject: [PATCH] Add tablet input
--- ---
Makefile | 6 +- Makefile | 6 +-
config.def.h | 1 + config.def.h | 1 +
dwl.c | 224 +++++++++++++++++++++++++++++++++++++++++++++++++++ dwl.c | 231 +++++++++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 230 insertions(+), 1 deletion(-) 3 files changed, 237 insertions(+), 1 deletion(-)
diff --git a/Makefile b/Makefile diff --git a/Makefile b/Makefile
index f955e7b..ce1b556 100644 index 578194f..e0d1835 100644
--- a/Makefile --- a/Makefile
+++ b/Makefile +++ b/Makefile
@@ -21,7 +21,8 @@ dwl: dwl.o util.o @@ -21,7 +21,8 @@ dwl: dwl.o util.o
@ -46,10 +46,10 @@ index 22d2171..3ad98ef 100644
static const int bypass_surface_visibility = 0; /* 1 means idle inhibitors will disable idle tracking even if it's surface isn't visible */ static const int bypass_surface_visibility = 0; /* 1 means idle inhibitors will disable idle tracking even if it's surface isn't visible */
static const unsigned int borderpx = 1; /* border pixel of windows */ static const unsigned int borderpx = 1; /* border pixel of windows */
diff --git a/dwl.c b/dwl.c diff --git a/dwl.c b/dwl.c
index ac9c36b..b8d129f 100644 index 4816159..e8d36ac 100644
--- a/dwl.c --- a/dwl.c
+++ b/dwl.c +++ b/dwl.c
@@ -50,6 +50,9 @@ @@ -51,6 +51,9 @@
#include <wlr/types/wlr_session_lock_v1.h> #include <wlr/types/wlr_session_lock_v1.h>
#include <wlr/types/wlr_single_pixel_buffer_v1.h> #include <wlr/types/wlr_single_pixel_buffer_v1.h>
#include <wlr/types/wlr_subcompositor.h> #include <wlr/types/wlr_subcompositor.h>
@ -59,7 +59,7 @@ index ac9c36b..b8d129f 100644
#include <wlr/types/wlr_viewporter.h> #include <wlr/types/wlr_viewporter.h>
#include <wlr/types/wlr_virtual_keyboard_v1.h> #include <wlr/types/wlr_virtual_keyboard_v1.h>
#include <wlr/types/wlr_virtual_pointer_v1.h> #include <wlr/types/wlr_virtual_pointer_v1.h>
@@ -270,6 +273,7 @@ static void createnotify(struct wl_listener *listener, void *data); @@ -268,6 +271,7 @@ static void createnotify(struct wl_listener *listener, void *data);
static void createpointer(struct wlr_pointer *pointer); static void createpointer(struct wlr_pointer *pointer);
static void createpointerconstraint(struct wl_listener *listener, void *data); static void createpointerconstraint(struct wl_listener *listener, void *data);
static void createpopup(struct wl_listener *listener, void *data); static void createpopup(struct wl_listener *listener, void *data);
@ -67,9 +67,9 @@ index ac9c36b..b8d129f 100644
static void cursorconstrain(struct wlr_pointer_constraint_v1 *constraint); static void cursorconstrain(struct wlr_pointer_constraint_v1 *constraint);
static void cursorframe(struct wl_listener *listener, void *data); static void cursorframe(struct wl_listener *listener, void *data);
static void cursorwarptohint(void); static void cursorwarptohint(void);
@@ -284,6 +288,9 @@ static void destroypointerconstraint(struct wl_listener *listener, void *data); @@ -281,6 +285,9 @@ static void destroynotify(struct wl_listener *listener, void *data);
static void destroypointerconstraint(struct wl_listener *listener, void *data);
static void destroysessionlock(struct wl_listener *listener, void *data); static void destroysessionlock(struct wl_listener *listener, void *data);
static void destroysessionmgr(struct wl_listener *listener, void *data);
static void destroykeyboardgroup(struct wl_listener *listener, void *data); static void destroykeyboardgroup(struct wl_listener *listener, void *data);
+static void destroytablet(struct wl_listener *listener, void *data); +static void destroytablet(struct wl_listener *listener, void *data);
+static void destroytabletsurfacenotify(struct wl_listener *listener, void *data); +static void destroytabletsurfacenotify(struct wl_listener *listener, void *data);
@ -77,7 +77,7 @@ index ac9c36b..b8d129f 100644
static Monitor *dirtomon(enum wlr_direction dir); static Monitor *dirtomon(enum wlr_direction dir);
static void focusclient(Client *c, int lift); static void focusclient(Client *c, int lift);
static void focusmon(const Arg *arg); static void focusmon(const Arg *arg);
@@ -337,6 +344,11 @@ static void spawn(const Arg *arg); @@ -333,6 +340,11 @@ static void spawn(const Arg *arg);
static void startdrag(struct wl_listener *listener, void *data); static void startdrag(struct wl_listener *listener, void *data);
static void tag(const Arg *arg); static void tag(const Arg *arg);
static void tagmon(const Arg *arg); static void tagmon(const Arg *arg);
@ -89,7 +89,7 @@ index ac9c36b..b8d129f 100644
static void tile(Monitor *m); static void tile(Monitor *m);
static void togglefloating(const Arg *arg); static void togglefloating(const Arg *arg);
static void togglefullscreen(const Arg *arg); static void togglefullscreen(const Arg *arg);
@@ -396,6 +408,13 @@ static struct wlr_pointer_constraint_v1 *active_constraint; @@ -390,6 +402,13 @@ static struct wlr_pointer_constraint_v1 *active_constraint;
static struct wlr_cursor *cursor; static struct wlr_cursor *cursor;
static struct wlr_xcursor_manager *cursor_mgr; static struct wlr_xcursor_manager *cursor_mgr;
@ -103,7 +103,20 @@ index ac9c36b..b8d129f 100644
static struct wlr_scene_rect *root_bg; static struct wlr_scene_rect *root_bg;
static struct wlr_session_lock_manager_v1 *session_lock_mgr; static struct wlr_session_lock_manager_v1 *session_lock_mgr;
static struct wlr_scene_rect *locked_bg; static struct wlr_scene_rect *locked_bg;
@@ -1133,6 +1152,28 @@ createpopup(struct wl_listener *listener, void *data) @@ -412,6 +431,12 @@ static struct wl_listener cursor_button = {.notify = buttonpress};
static struct wl_listener cursor_frame = {.notify = cursorframe};
static struct wl_listener cursor_motion = {.notify = motionrelative};
static struct wl_listener cursor_motion_absolute = {.notify = motionabsolute};
+static struct wl_listener tablet_device_destroy = {.notify = destroytablet};
+static struct wl_listener tablet_tool_axis = {.notify = tablettoolaxis};
+static struct wl_listener tablet_tool_button = {.notify = tablettoolbutton};
+static struct wl_listener tablet_tool_destroy = {.notify = destroytablettool};
+static struct wl_listener tablet_tool_proximity = {.notify = tablettoolproximity};
+static struct wl_listener tablet_tool_tip = {.notify = tablettooltip};
static struct wl_listener gpu_reset = {.notify = gpureset};
static struct wl_listener layout_change = {.notify = updatemons};
static struct wl_listener new_idle_inhibitor = {.notify = createidleinhibitor};
@@ -1196,6 +1221,28 @@ createpopup(struct wl_listener *listener, void *data)
LISTEN_STATIC(&popup->base->surface->events.commit, commitpopup); LISTEN_STATIC(&popup->base->surface->events.commit, commitpopup);
} }
@ -117,7 +130,7 @@ index ac9c36b..b8d129f 100644
+ return; + return;
+ +
+ tablet = wlr_tablet_create(tablet_mgr, seat, device); + tablet = wlr_tablet_create(tablet_mgr, seat, device);
+ LISTEN_STATIC(&tablet->wlr_device->events.destroy, destroytablet); + wl_signal_add(&tablet->wlr_device->events.destroy, &tablet_device_destroy);
+ if (libinput_device_config_send_events_get_modes(device_handle)) { + if (libinput_device_config_send_events_get_modes(device_handle)) {
+ libinput_device_config_send_events_set_mode(device_handle, send_events_mode); + libinput_device_config_send_events_set_mode(device_handle, send_events_mode);
+ wlr_cursor_attach_input_device(cursor, device); + wlr_cursor_attach_input_device(cursor, device);
@ -132,7 +145,7 @@ index ac9c36b..b8d129f 100644
void void
cursorconstrain(struct wlr_pointer_constraint_v1 *constraint) cursorconstrain(struct wlr_pointer_constraint_v1 *constraint)
{ {
@@ -1321,6 +1362,27 @@ destroykeyboardgroup(struct wl_listener *listener, void *data) @@ -1380,6 +1427,27 @@ destroykeyboardgroup(struct wl_listener *listener, void *data)
free(group); free(group);
} }
@ -160,7 +173,7 @@ index ac9c36b..b8d129f 100644
Monitor * Monitor *
dirtomon(enum wlr_direction dir) dirtomon(enum wlr_direction dir)
{ {
@@ -1540,6 +1602,12 @@ inputdevice(struct wl_listener *listener, void *data) @@ -1587,6 +1655,12 @@ inputdevice(struct wl_listener *listener, void *data)
case WLR_INPUT_DEVICE_POINTER: case WLR_INPUT_DEVICE_POINTER:
createpointer(wlr_pointer_from_input_device(device)); createpointer(wlr_pointer_from_input_device(device));
break; break;
@ -173,7 +186,7 @@ index ac9c36b..b8d129f 100644
default: default:
/* TODO handle other input device types */ /* TODO handle other input device types */
break; break;
@@ -2567,6 +2635,8 @@ setup(void) @@ -2580,6 +2654,8 @@ setup(void)
relative_pointer_mgr = wlr_relative_pointer_manager_v1_create(dpy); relative_pointer_mgr = wlr_relative_pointer_manager_v1_create(dpy);
@ -182,18 +195,19 @@ index ac9c36b..b8d129f 100644
/* /*
* Creates a cursor, which is a wlroots utility for tracking the cursor * Creates a cursor, which is a wlroots utility for tracking the cursor
* image shown on screen. * image shown on screen.
@@ -2596,6 +2666,10 @@ setup(void) @@ -2609,6 +2685,11 @@ setup(void)
LISTEN_STATIC(&cursor->events.button, buttonpress); wl_signal_add(&cursor->events.button, &cursor_button);
LISTEN_STATIC(&cursor->events.axis, axisnotify); wl_signal_add(&cursor->events.axis, &cursor_axis);
LISTEN_STATIC(&cursor->events.frame, cursorframe); wl_signal_add(&cursor->events.frame, &cursor_frame);
+ LISTEN_STATIC(&cursor->events.tablet_tool_proximity, tablettoolproximity); + wl_signal_add(&cursor->events.tablet_tool_proximity, &tablet_tool_proximity);
+ LISTEN_STATIC(&cursor->events.tablet_tool_axis, tablettoolaxis); + wl_signal_add(&cursor->events.tablet_tool_axis, &tablet_tool_axis);
+ LISTEN_STATIC(&cursor->events.tablet_tool_button, tablettoolbutton); + wl_signal_add(&cursor->events.tablet_tool_button, &tablet_tool_button);
+ LISTEN_STATIC(&cursor->events.tablet_tool_tip, tablettooltip); + wl_signal_add(&cursor->events.tablet_tool_tip, &tablet_tool_tip);
+
cursor_shape_mgr = wlr_cursor_shape_manager_v1_create(dpy, 1); cursor_shape_mgr = wlr_cursor_shape_manager_v1_create(dpy, 1);
LISTEN_STATIC(&cursor_shape_mgr->events.request_set_shape, setcursorshape); wl_signal_add(&cursor_shape_mgr->events.request_set_shape, &request_set_cursor_shape);
@@ -2689,6 +2763,156 @@ tagmon(const Arg *arg) @@ -2704,6 +2785,156 @@ tagmon(const Arg *arg)
setmon(sel, dirtomon(arg->i), 0); setmon(sel, dirtomon(arg->i), 0);
} }
@ -276,8 +290,8 @@ index ac9c36b..b8d129f 100644
+ +
+ if (!tablet_tool) { + if (!tablet_tool) {
+ tablet_tool = wlr_tablet_tool_create(tablet_mgr, seat, tool); + tablet_tool = wlr_tablet_tool_create(tablet_mgr, seat, tool);
+ LISTEN_STATIC(&tablet_tool->wlr_tool->events.destroy, destroytablettool); + wl_signal_add(&tablet_tool->wlr_tool->events.destroy, &tablet_tool_destroy);
+ LISTEN_STATIC(&tablet_tool->events.set_cursor, setcursor); + wl_signal_add(&tablet_tool->events.set_cursor, &request_cursor);
+ } + }
+ +
+ switch (event->state) { + switch (event->state) {
@ -351,5 +365,5 @@ index ac9c36b..b8d129f 100644
tile(Monitor *m) tile(Monitor *m)
{ {
-- --
2.43.0 2.49.0