mirror of
https://codeberg.org/dwl/dwl-patches.git
synced 2025-10-26 17:54:17 +00:00
Compare commits
2 Commits
800647a85b
...
d36c11db0c
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d36c11db0c | ||
|
|
c9e48802a5 |
@ -1,4 +1,5 @@
|
||||
### Description
|
||||
|
||||
Input device rules implemented using custom device create functions for
|
||||
keyboards and pointing devices.
|
||||
|
||||
@ -10,7 +11,8 @@ Examples provided:
|
||||
|
||||
### Download
|
||||
- [git branch](https://codeberg.org/bencc/dwl/src/branch/inputdevicerules)
|
||||
- [2024-06-21](https://codeberg.org/dwl/dwl-patches/raw/branch/main/patches/inputdevicerules/inputdevicerules.patch)
|
||||
- [v0.7](https://codeberg.org/dwl/dwl-patches/raw/branch/main/patches/inputdevicerules/inputdevicerules-v0.7.patch)
|
||||
- [v0.6](https://codeberg.org/dwl/dwl-patches/raw/branch/main/patches/inputdevicerules/inputdevicerules-v0.6.patch)
|
||||
|
||||
### Authors
|
||||
- [Ben Collerson](https://codeberg.org/bencc)
|
||||
|
||||
173
patches/inputdevicerules/inputdevicerules-v0.7.patch
Normal file
173
patches/inputdevicerules/inputdevicerules-v0.7.patch
Normal file
@ -0,0 +1,173 @@
|
||||
From 89f870a04f903681b0a7a0ac4eb1ae70c4984b46 Mon Sep 17 00:00:00 2001
|
||||
From: Ben Collerson <benc@benc.cc>
|
||||
Date: Sat, 15 Jun 2024 12:34:01 +1000
|
||||
Subject: [PATCH] input device rules
|
||||
|
||||
* customise input device handling
|
||||
* ignore unwanted input devices
|
||||
* configure a toggle for an input device
|
||||
---
|
||||
config.def.h | 13 ++++++++++
|
||||
dwl.c | 68 ++++++++++++++++++++++++++++++++++++++++++++++++++--
|
||||
2 files changed, 79 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/config.def.h b/config.def.h
|
||||
index 22d2171d..0b287ab5 100644
|
||||
--- a/config.def.h
|
||||
+++ b/config.def.h
|
||||
@@ -60,6 +60,18 @@ static const struct xkb_rule_names xkb_rules = {
|
||||
.options = NULL,
|
||||
};
|
||||
|
||||
+/* input devices */
|
||||
+static const InputRule inputrules[] = {
|
||||
+ /* name kbcreate ptrcreate */
|
||||
+ /* ignore bad device - like a touchpad ;) */
|
||||
+ { "BAD DEVICE", NULL, NULL },
|
||||
+ /* ungroup ydotool device - fixes a bug */
|
||||
+ { "ydotoold virtual device", createungroupedkeyboard, createpointer },
|
||||
+ /* put your touchpad name here to enable toggle touchpad */
|
||||
+ { "Elan Touchpad", createkeyboard, createtogglepointer },
|
||||
+ { NULL, createkeyboard, createpointer },
|
||||
+};
|
||||
+
|
||||
static const int repeat_rate = 25;
|
||||
static const int repeat_delay = 600;
|
||||
|
||||
@@ -142,6 +154,7 @@ static const Key keys[] = {
|
||||
{ MODKEY, XKB_KEY_space, setlayout, {0} },
|
||||
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_space, togglefloating, {0} },
|
||||
{ MODKEY, XKB_KEY_e, togglefullscreen, {0} },
|
||||
+ { MODKEY, XKB_KEY_u, togglepointer, {0} },
|
||||
{ MODKEY, XKB_KEY_0, view, {.ui = ~0} },
|
||||
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_parenright, tag, {.ui = ~0} },
|
||||
{ MODKEY, XKB_KEY_comma, focusmon, {.i = WLR_DIRECTION_LEFT} },
|
||||
diff --git a/dwl.c b/dwl.c
|
||||
index a2711f67..f6f91938 100644
|
||||
--- a/dwl.c
|
||||
+++ b/dwl.c
|
||||
@@ -143,6 +143,12 @@ typedef struct {
|
||||
uint32_t resize; /* configure serial of a pending resize */
|
||||
} Client;
|
||||
|
||||
+typedef struct {
|
||||
+ const char *name;
|
||||
+ void (*kbcreate)(struct wlr_keyboard *);
|
||||
+ void (*ptrcreate)(struct wlr_pointer *);
|
||||
+} InputRule;
|
||||
+
|
||||
typedef struct {
|
||||
uint32_t mod;
|
||||
xkb_keysym_t keysym;
|
||||
@@ -270,6 +276,8 @@ 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 createtogglepointer(struct wlr_pointer *pointer);
|
||||
+static void createungroupedkeyboard(struct wlr_keyboard *keyboard);
|
||||
static void cursorconstrain(struct wlr_pointer_constraint_v1 *constraint);
|
||||
static void cursorframe(struct wl_listener *listener, void *data);
|
||||
static void cursorwarptohint(void);
|
||||
@@ -340,6 +348,7 @@ static void tagmon(const Arg *arg);
|
||||
static void tile(Monitor *m);
|
||||
static void togglefloating(const Arg *arg);
|
||||
static void togglefullscreen(const Arg *arg);
|
||||
+static void togglepointer(const Arg *arg);
|
||||
static void toggletag(const Arg *arg);
|
||||
static void toggleview(const Arg *arg);
|
||||
static void unlocksession(struct wl_listener *listener, void *data);
|
||||
@@ -413,6 +422,8 @@ static struct wlr_box sgeom;
|
||||
static struct wl_list mons;
|
||||
static Monitor *selmon;
|
||||
|
||||
+static struct libinput_device *togglepointerdevice = NULL;
|
||||
+
|
||||
#ifdef XWAYLAND
|
||||
static void activatex11(struct wl_listener *listener, void *data);
|
||||
static void associatex11(struct wl_listener *listener, void *data);
|
||||
@@ -1133,6 +1144,33 @@ createpopup(struct wl_listener *listener, void *data)
|
||||
LISTEN_STATIC(&popup->base->surface->events.commit, commitpopup);
|
||||
}
|
||||
|
||||
+void
|
||||
+createtogglepointer(struct wlr_pointer *pointer)
|
||||
+{
|
||||
+ struct libinput_device *device;
|
||||
+
|
||||
+ createpointer(pointer);
|
||||
+
|
||||
+ if (wlr_input_device_is_libinput(&pointer->base)
|
||||
+ && (device = wlr_libinput_get_device_handle(&pointer->base))) {
|
||||
+ togglepointerdevice = device;
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+void
|
||||
+createungroupedkeyboard(struct wlr_keyboard *keyboard)
|
||||
+{
|
||||
+ /* for keyboards that need their own keyboard group */
|
||||
+ KeyboardGroup *group = createkeyboardgroup();
|
||||
+
|
||||
+ /* Set the keymap to match the group keymap */
|
||||
+ wlr_keyboard_set_keymap(keyboard, group->wlr_group->keyboard.keymap);
|
||||
+ LISTEN(&keyboard->base.events.destroy, &group->destroy, destroykeyboardgroup);
|
||||
+
|
||||
+ /* Add the new keyboard to the group */
|
||||
+ wlr_keyboard_group_add_keyboard(group->wlr_group, keyboard);
|
||||
+}
|
||||
+
|
||||
void
|
||||
cursorconstrain(struct wlr_pointer_constraint_v1 *constraint)
|
||||
{
|
||||
@@ -1531,13 +1569,27 @@ inputdevice(struct wl_listener *listener, void *data)
|
||||
* available. */
|
||||
struct wlr_input_device *device = data;
|
||||
uint32_t caps;
|
||||
+ const InputRule *r;
|
||||
|
||||
switch (device->type) {
|
||||
case WLR_INPUT_DEVICE_KEYBOARD:
|
||||
- createkeyboard(wlr_keyboard_from_input_device(device));
|
||||
+ for (r = inputrules; r < END(inputrules); r++) {
|
||||
+ if (!r->name || strstr(device->name, r->name)) {
|
||||
+ if (r->kbcreate)
|
||||
+ r->kbcreate(wlr_keyboard_from_input_device(device));
|
||||
+ break;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
break;
|
||||
case WLR_INPUT_DEVICE_POINTER:
|
||||
- createpointer(wlr_pointer_from_input_device(device));
|
||||
+ for (r = inputrules; r < END(inputrules); r++) {
|
||||
+ if (!r->name || strstr(device->name, r->name)) {
|
||||
+ if (r->ptrcreate)
|
||||
+ r->ptrcreate(wlr_pointer_from_input_device(device));
|
||||
+ break;
|
||||
+ }
|
||||
+ }
|
||||
break;
|
||||
default:
|
||||
/* TODO handle other input device types */
|
||||
@@ -2739,6 +2791,18 @@ togglefullscreen(const Arg *arg)
|
||||
setfullscreen(sel, !sel->isfullscreen);
|
||||
}
|
||||
|
||||
+void
|
||||
+togglepointer(const Arg *arg)
|
||||
+{
|
||||
+ if (!togglepointerdevice)
|
||||
+ return;
|
||||
+
|
||||
+ libinput_device_config_send_events_set_mode(
|
||||
+ togglepointerdevice,
|
||||
+ libinput_device_config_send_events_get_mode(togglepointerdevice) ^ LIBINPUT_CONFIG_SEND_EVENTS_DISABLED
|
||||
+ );
|
||||
+}
|
||||
+
|
||||
void
|
||||
toggletag(const Arg *arg)
|
||||
{
|
||||
--
|
||||
2.45.2
|
||||
|
||||
@ -1,9 +1,13 @@
|
||||
### Description
|
||||
|
||||
Like smartborders. Don't put borders when there is only one window on the screen.
|
||||
|
||||
The patch for tag v0.7 below appears to apply cleanly to the current HEAD of
|
||||
upstream/main as at 2024-10-11.
|
||||
|
||||
### Download
|
||||
- [git branch](https://codeberg.org/bencc/dwl/src/branch/simpleborders)
|
||||
- [2024-06-18 applies to dwl wlroots-next branch](https://codeberg.org/dwl/dwl-patches/raw/branch/main/patches/simpleborders/simpleborders-wlrootsnext-20240618.patch)
|
||||
- [2023-01-07](https://codeberg.org/dwl/dwl-patches/raw/branch/main/patches/simpleborders/simpleborders.patch)
|
||||
- [v0.7](https://codeberg.org/dwl/dwl-patches/raw/branch/main/patches/simpleborders/simpleborders-v0.7.patch)
|
||||
- [v0.6](https://codeberg.org/dwl/dwl-patches/raw/branch/main/patches/simpleborders/simpleborders-v0.6.patch)
|
||||
### Authors
|
||||
- [Ben Collerson](https://codeberg.org/bencc)
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
From 143b8d35f73f32be7f6a1f8e099144a38b4c5eb6 Mon Sep 17 00:00:00 2001
|
||||
From 09759c3ef75158c366e9fc63814485fbb31a3ccf Mon Sep 17 00:00:00 2001
|
||||
From: Ben Collerson <benc@benc.cc>
|
||||
Date: Sat, 30 Dec 2023 13:39:31 +1000
|
||||
Subject: [PATCH] simpleborders
|
||||
@ -8,10 +8,10 @@ Subject: [PATCH] simpleborders
|
||||
1 file changed, 22 insertions(+)
|
||||
|
||||
diff --git a/dwl.c b/dwl.c
|
||||
index 9890a6c..66760ec 100644
|
||||
index a2711f67..415fe1a0 100644
|
||||
--- a/dwl.c
|
||||
+++ b/dwl.c
|
||||
@@ -258,6 +258,7 @@ static void closemon(Monitor *m);
|
||||
@@ -259,6 +259,7 @@ static void closemon(Monitor *m);
|
||||
static void commitlayersurfacenotify(struct wl_listener *listener, void *data);
|
||||
static void commitnotify(struct wl_listener *listener, void *data);
|
||||
static void commitpopup(struct wl_listener *listener, void *data);
|
||||
@ -19,7 +19,7 @@ index 9890a6c..66760ec 100644
|
||||
static void createdecoration(struct wl_listener *listener, void *data);
|
||||
static void createidleinhibitor(struct wl_listener *listener, void *data);
|
||||
static void createkeyboard(struct wlr_keyboard *keyboard);
|
||||
@@ -307,6 +308,7 @@ static void motionnotify(uint32_t time, struct wlr_input_device *device, double
|
||||
@@ -308,6 +309,7 @@ static void motionnotify(uint32_t time, struct wlr_input_device *device, double
|
||||
double sy, double sx_unaccel, double sy_unaccel);
|
||||
static void motionrelative(struct wl_listener *listener, void *data);
|
||||
static void moveresize(const Arg *arg);
|
||||
@ -27,8 +27,8 @@ index 9890a6c..66760ec 100644
|
||||
static void outputmgrapply(struct wl_listener *listener, void *data);
|
||||
static void outputmgrapplyortest(struct wlr_output_configuration_v1 *config, int test);
|
||||
static void outputmgrtest(struct wl_listener *listener, void *data);
|
||||
@@ -804,6 +806,17 @@ commitnotify(struct wl_listener *listener, void *data)
|
||||
c->resize = 0;
|
||||
@@ -849,6 +851,17 @@ commitpopup(struct wl_listener *listener, void *data)
|
||||
wl_list_remove(&listener->link);
|
||||
}
|
||||
|
||||
+int
|
||||
@ -43,9 +43,9 @@ index 9890a6c..66760ec 100644
|
||||
+}
|
||||
+
|
||||
void
|
||||
commitpopup(struct wl_listener *listener, void *data)
|
||||
createdecoration(struct wl_listener *listener, void *data)
|
||||
{
|
||||
@@ -1893,6 +1906,14 @@ moveresize(const Arg *arg)
|
||||
@@ -1927,6 +1940,14 @@ moveresize(const Arg *arg)
|
||||
}
|
||||
}
|
||||
|
||||
@ -60,8 +60,8 @@ index 9890a6c..66760ec 100644
|
||||
void
|
||||
outputmgrapply(struct wl_listener *listener, void *data)
|
||||
{
|
||||
@@ -2127,6 +2148,7 @@ resize(Client *c, struct wlr_box geo, int interact)
|
||||
struct wlr_box clip;
|
||||
@@ -2190,6 +2211,7 @@ resize(Client *c, struct wlr_box geo, int interact)
|
||||
|
||||
client_set_bounds(c, geo.width, geo.height);
|
||||
c->geom = geo;
|
||||
+ c->bw = needsborder(c) ? borderpx : 0;
|
||||
@ -69,5 +69,5 @@ index 9890a6c..66760ec 100644
|
||||
|
||||
/* Update scene-graph, including borders */
|
||||
--
|
||||
2.44.1
|
||||
2.45.2
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user