mirror of
https://codeberg.org/dwl/dwl-patches.git
synced 2025-09-07 11:44:51 +00:00
tablet-input: 2024-07-31
This commit is contained in:
parent
ca3e6cbdac
commit
570cf3bc31
@ -5,7 +5,8 @@ inspired by @guyuming76's [branch](https://codeberg.org/guyuming76/dwl/commits/b
|
||||
|
||||
### Download
|
||||
- [git branch](https://codeberg.org/notchoc/dwl/src/branch/tablet-input)
|
||||
- [2024-06-21](https://codeberg.org/dwl/dwl-patches/raw/branch/main/patches/tablet-input/tablet-input.patch)
|
||||
- [2024-07-31](https://codeberg.org/dwl/dwl-patches/raw/branch/main/patches/tablet-input/tablet-input.patch) fixes pen not working after lifting up
|
||||
- [2024-06-21](https://codeberg.org/dwl/dwl-patches/raw/commit/18d283d3746ecbc3cd7650358c5769e03b346425/patches/tablet-input/tablet-input.patch)
|
||||
- [2024-06-19](https://codeberg.org/dwl/dwl-patches/raw/commit/fee4da5cb6470ca5349fa2102765705e19d3bfa3/patches/tablet-input/tablet-input.patch)
|
||||
- [2024-05-04](https://codeberg.org/dwl/dwl-patches/raw/commit/748b4bc6a73828f3e74b210862bebcda4c9dfb3c/patches/tablet-input/tablet-input.patch)
|
||||
|
||||
|
@ -1,39 +1,40 @@
|
||||
From 3923f6f56cdbcad04b0aab601db99e17d4e50de0 Mon Sep 17 00:00:00 2001
|
||||
From e504dc0fccfc3994962f03dc824d8907c6afc64f Mon Sep 17 00:00:00 2001
|
||||
From: choc <notchoc@proton.me>
|
||||
Date: Sat, 4 May 2024 01:16:12 +0800
|
||||
Subject: [PATCH] implement wlr-tablet-v2
|
||||
|
||||
---
|
||||
Makefile | 5 +-
|
||||
Makefile | 6 +-
|
||||
config.def.h | 1 +
|
||||
dwl.c | 225 +++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
dwl.c | 224 +++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
3 files changed, 230 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/Makefile b/Makefile
|
||||
index fdc581a..72e75ab 100644
|
||||
index f955e7b..ce1b556 100644
|
||||
--- a/Makefile
|
||||
+++ b/Makefile
|
||||
@@ -16,7 +16,7 @@ LDLIBS = `$(PKG_CONFIG) --libs $(PKGS)` $(LIBS)
|
||||
all: dwl
|
||||
dwl: dwl.o util.o
|
||||
@@ -21,7 +21,8 @@ dwl: dwl.o util.o
|
||||
$(CC) dwl.o util.o $(DWLCFLAGS) $(LDFLAGS) $(LDLIBS) -o $@
|
||||
-dwl.o: dwl.c client.h config.h config.mk cursor-shape-v1-protocol.h pointer-constraints-unstable-v1-protocol.h wlr-layer-shell-unstable-v1-protocol.h wlr-output-power-management-unstable-v1-protocol.h xdg-shell-protocol.h
|
||||
+dwl.o: dwl.c client.h config.h config.mk cursor-shape-v1-protocol.h pointer-constraints-unstable-v1-protocol.h wlr-layer-shell-unstable-v1-protocol.h wlr-output-power-management-unstable-v1-protocol.h xdg-shell-protocol.h tablet-unstable-v2-protocol.h
|
||||
dwl.o: dwl.c client.h config.h config.mk cursor-shape-v1-protocol.h \
|
||||
pointer-constraints-unstable-v1-protocol.h wlr-layer-shell-unstable-v1-protocol.h \
|
||||
- wlr-output-power-management-unstable-v1-protocol.h xdg-shell-protocol.h
|
||||
+ wlr-output-power-management-unstable-v1-protocol.h xdg-shell-protocol.h \
|
||||
+ tablet-v2-protocol.h
|
||||
util.o: util.c util.h
|
||||
|
||||
# wayland-scanner is a tool which generates C headers and rigging for Wayland
|
||||
@@ -40,6 +40,9 @@ wlr-output-power-management-unstable-v1-protocol.h:
|
||||
@@ -45,6 +46,9 @@ wlr-output-power-management-unstable-v1-protocol.h:
|
||||
xdg-shell-protocol.h:
|
||||
$(WAYLAND_SCANNER) server-header \
|
||||
$(WAYLAND_PROTOCOLS)/stable/xdg-shell/xdg-shell.xml $@
|
||||
+tablet-unstable-v2-protocol.h:
|
||||
+tablet-v2-protocol.h:
|
||||
+ $(WAYLAND_SCANNER) server-header \
|
||||
+ $(WAYLAND_PROTOCOLS)/unstable/tablet/tablet-unstable-v2.xml $@
|
||||
|
||||
config.h:
|
||||
cp config.def.h $@
|
||||
diff --git a/config.def.h b/config.def.h
|
||||
index a784eb4..246356a 100644
|
||||
index 22d2171..3ad98ef 100644
|
||||
--- a/config.def.h
|
||||
+++ b/config.def.h
|
||||
@@ -4,6 +4,7 @@
|
||||
@ -45,10 +46,10 @@ index a784eb4..246356a 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 unsigned int borderpx = 1; /* border pixel of windows */
|
||||
diff --git a/dwl.c b/dwl.c
|
||||
index 2cdc819..788b2b8 100644
|
||||
index ac9c36b..b8d129f 100644
|
||||
--- a/dwl.c
|
||||
+++ b/dwl.c
|
||||
@@ -48,6 +48,9 @@
|
||||
@@ -50,6 +50,9 @@
|
||||
#include <wlr/types/wlr_session_lock_v1.h>
|
||||
#include <wlr/types/wlr_single_pixel_buffer_v1.h>
|
||||
#include <wlr/types/wlr_subcompositor.h>
|
||||
@ -58,15 +59,15 @@ index 2cdc819..788b2b8 100644
|
||||
#include <wlr/types/wlr_viewporter.h>
|
||||
#include <wlr/types/wlr_virtual_keyboard_v1.h>
|
||||
#include <wlr/types/wlr_virtual_pointer_v1.h>
|
||||
@@ -268,6 +271,7 @@ static void createmon(struct wl_listener *listener, void *data);
|
||||
static void createnotify(struct wl_listener *listener, void *data);
|
||||
@@ -270,6 +273,7 @@ static void createnotify(struct wl_listener *listener, void *data);
|
||||
static void createpointer(struct wlr_pointer *pointer);
|
||||
static void createpointerconstraint(struct wl_listener *listener, void *data);
|
||||
static void createpopup(struct wl_listener *listener, void *data);
|
||||
+static void createtablet(struct wlr_input_device *device);
|
||||
static void cursorconstrain(struct wlr_pointer_constraint_v1 *constraint);
|
||||
static void cursorframe(struct wl_listener *listener, void *data);
|
||||
static void cursorwarptohint(void);
|
||||
@@ -282,6 +286,9 @@ static void destroypointerconstraint(struct wl_listener *listener, void *data);
|
||||
@@ -284,6 +288,9 @@ static void destroypointerconstraint(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);
|
||||
@ -76,7 +77,7 @@ index 2cdc819..788b2b8 100644
|
||||
static Monitor *dirtomon(enum wlr_direction dir);
|
||||
static void focusclient(Client *c, int lift);
|
||||
static void focusmon(const Arg *arg);
|
||||
@@ -335,6 +342,11 @@ static void spawn(const Arg *arg);
|
||||
@@ -337,6 +344,11 @@ static void spawn(const Arg *arg);
|
||||
static void startdrag(struct wl_listener *listener, void *data);
|
||||
static void tag(const Arg *arg);
|
||||
static void tagmon(const Arg *arg);
|
||||
@ -88,7 +89,7 @@ index 2cdc819..788b2b8 100644
|
||||
static void tile(Monitor *m);
|
||||
static void togglefloating(const Arg *arg);
|
||||
static void togglefullscreen(const Arg *arg);
|
||||
@@ -393,6 +405,13 @@ static struct wlr_pointer_constraint_v1 *active_constraint;
|
||||
@@ -396,6 +408,13 @@ static struct wlr_pointer_constraint_v1 *active_constraint;
|
||||
static struct wlr_cursor *cursor;
|
||||
static struct wlr_xcursor_manager *cursor_mgr;
|
||||
|
||||
@ -102,8 +103,8 @@ index 2cdc819..788b2b8 100644
|
||||
static struct wlr_scene_rect *root_bg;
|
||||
static struct wlr_session_lock_manager_v1 *session_lock_mgr;
|
||||
static struct wlr_scene_rect *locked_bg;
|
||||
@@ -1096,6 +1115,28 @@ createpointerconstraint(struct wl_listener *listener, void *data)
|
||||
&pointer_constraint->destroy, destroypointerconstraint);
|
||||
@@ -1133,6 +1152,28 @@ createpopup(struct wl_listener *listener, void *data)
|
||||
LISTEN_STATIC(&popup->base->surface->events.commit, commitpopup);
|
||||
}
|
||||
|
||||
+void
|
||||
@ -131,7 +132,7 @@ index 2cdc819..788b2b8 100644
|
||||
void
|
||||
cursorconstrain(struct wlr_pointer_constraint_v1 *constraint)
|
||||
{
|
||||
@@ -1284,6 +1325,29 @@ destroykeyboardgroup(struct wl_listener *listener, void *data)
|
||||
@@ -1321,6 +1362,27 @@ destroykeyboardgroup(struct wl_listener *listener, void *data)
|
||||
free(group);
|
||||
}
|
||||
|
||||
@ -152,20 +153,18 @@ index 2cdc819..788b2b8 100644
|
||||
+void
|
||||
+destroytablettool(struct wl_listener *listener, void *data)
|
||||
+{
|
||||
+ if (tablet_curr_surface)
|
||||
+ wl_list_remove(&destroy_tablet_surface_listener.link);
|
||||
+ tablet_curr_surface = NULL;
|
||||
+ destroytabletsurfacenotify(NULL, NULL);
|
||||
+ tablet_tool = NULL;
|
||||
+}
|
||||
+
|
||||
Monitor *
|
||||
dirtomon(enum wlr_direction dir)
|
||||
{
|
||||
@@ -1479,6 +1543,12 @@ inputdevice(struct wl_listener *listener, void *data)
|
||||
@@ -1540,6 +1602,12 @@ inputdevice(struct wl_listener *listener, void *data)
|
||||
case WLR_INPUT_DEVICE_POINTER:
|
||||
createpointer(wlr_pointer_from_input_device(device));
|
||||
break;
|
||||
+ case WLR_INPUT_DEVICE_TABLET_TOOL:
|
||||
+ case WLR_INPUT_DEVICE_TABLET:
|
||||
+ createtablet(device);
|
||||
+ break;
|
||||
+ case WLR_INPUT_DEVICE_TABLET_PAD:
|
||||
@ -174,7 +173,7 @@ index 2cdc819..788b2b8 100644
|
||||
default:
|
||||
/* TODO handle other input device types */
|
||||
break;
|
||||
@@ -2498,6 +2568,8 @@ setup(void)
|
||||
@@ -2567,6 +2635,8 @@ setup(void)
|
||||
|
||||
relative_pointer_mgr = wlr_relative_pointer_manager_v1_create(dpy);
|
||||
|
||||
@ -183,7 +182,7 @@ index 2cdc819..788b2b8 100644
|
||||
/*
|
||||
* Creates a cursor, which is a wlroots utility for tracking the cursor
|
||||
* image shown on screen.
|
||||
@@ -2527,6 +2599,10 @@ setup(void)
|
||||
@@ -2596,6 +2666,10 @@ setup(void)
|
||||
LISTEN_STATIC(&cursor->events.button, buttonpress);
|
||||
LISTEN_STATIC(&cursor->events.axis, axisnotify);
|
||||
LISTEN_STATIC(&cursor->events.frame, cursorframe);
|
||||
@ -194,7 +193,7 @@ index 2cdc819..788b2b8 100644
|
||||
|
||||
cursor_shape_mgr = wlr_cursor_shape_manager_v1_create(dpy, 1);
|
||||
LISTEN_STATIC(&cursor_shape_mgr->events.request_set_shape, setcursorshape);
|
||||
@@ -2622,6 +2698,155 @@ tagmon(const Arg *arg)
|
||||
@@ -2689,6 +2763,156 @@ tagmon(const Arg *arg)
|
||||
setmon(sel, dirtomon(arg->i), 0);
|
||||
}
|
||||
|
||||
@ -243,7 +242,7 @@ index 2cdc819..788b2b8 100644
|
||||
+ motionnotify(0, NULL, 0, 0, 0, 0);
|
||||
+
|
||||
+ xytonode(cursor->x, cursor->y, &surface, NULL, NULL, &sx, &sy);
|
||||
+ if (surface && !wlr_surface_accepts_tablet_v2(tablet, surface))
|
||||
+ if (surface && !wlr_surface_accepts_tablet_v2(surface, tablet))
|
||||
+ surface = NULL;
|
||||
+
|
||||
+ if (surface != tablet_curr_surface) {
|
||||
@ -284,6 +283,7 @@ index 2cdc819..788b2b8 100644
|
||||
+ switch (event->state) {
|
||||
+ case WLR_TABLET_TOOL_PROXIMITY_OUT:
|
||||
+ wlr_tablet_v2_tablet_tool_notify_proximity_out(tablet_tool);
|
||||
+ destroytabletsurfacenotify(NULL, NULL);
|
||||
+ break;
|
||||
+ case WLR_TABLET_TOOL_PROXIMITY_IN:
|
||||
+ tablettoolmotion(tablet_tool, true, true, event->x, event->y, 0, 0);
|
||||
@ -332,7 +332,7 @@ index 2cdc819..788b2b8 100644
|
||||
+ struct wlr_pointer_button_event fakeptrbtnevent = {
|
||||
+ .button = BTN_LEFT,
|
||||
+ .state = event->state == WLR_TABLET_TOOL_TIP_UP ?
|
||||
+ WLR_BUTTON_RELEASED : WLR_BUTTON_PRESSED,
|
||||
+ WL_POINTER_BUTTON_STATE_RELEASED : WL_POINTER_BUTTON_STATE_PRESSED,
|
||||
+ .time_msec = event->time_msec,
|
||||
+ };
|
||||
+ buttonpress(NULL, (void *)&fakeptrbtnevent);
|
||||
|
Loading…
x
Reference in New Issue
Block a user