Compare commits

...

2 Commits

Author SHA1 Message Date
pi66
2bfdd50f98 fix: enable focus-follow-mouse for tablet pen input 2026-05-05 10:30:16 +02:00
Hans von Hohenstaufen
ea5c2c7439 Fix rules for focus and unfocus 2026-05-05 10:25:17 +02:00
4 changed files with 58 additions and 56 deletions

View File

@ -14,7 +14,7 @@ The opacity levels can be change by short cuts.
### Download
- [git branch](https://codeberg.org/Hansvon/dwl/src/branch/client-opacity-focus)
- [2025-12-11](https://codeberg.org/dwl/dwl-patches/raw/branch/main/patches/client-opacity-focus/client-opacity-focus.patch)
- [2026-04-27](https://codeberg.org/dwl/dwl-patches/raw/branch/main/patches/client-opacity-focus/client-opacity-focus.patch)
### Authors
- [Hansvon](https://codeberg.org/Hansvon)

View File

@ -1,15 +1,15 @@
From 694751a31a437bbb28c3a75c917ed922231ab366 Mon Sep 17 00:00:00 2001
From 57c5475d7f715b77ec05d69a2bda808b224cf0b4 Mon Sep 17 00:00:00 2001
From: Hans von Hohenstaufen <Hans.von.Hohenstaufen@protonmail.com>
Date: Mon, 22 Dec 2025 01:43:50 +0000
Subject: [PATCH] Add client opacity focus
---
config.def.h | 12 +++++++---
dwl.c | 63 ++++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 72 insertions(+), 3 deletions(-)
dwl.c | 65 ++++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 74 insertions(+), 3 deletions(-)
diff --git a/config.def.h b/config.def.h
index 95c2afa..b7002f5 100644
index 95c2afa..55abf84 100644
--- a/config.def.h
+++ b/config.def.h
@@ -13,6 +13,8 @@ static const float focuscolor[] = COLOR(0x005577ff);
@ -26,12 +26,12 @@ index 95c2afa..b7002f5 100644
/* NOTE: ALWAYS keep a rule declared even if you don't use rules (e.g leave at least one example) */
static const Rule rules[] = {
- /* app_id title tags mask isfloating monitor */
+ /* app_id title tags mask isfloating alpha unfocus monitor */
+ /* app_id title tags mask isfloating alpha focus alpha unfocus monitor */
/* examples: */
- { "Gimp_EXAMPLE", NULL, 0, 1, -1 }, /* Start on currently visible tags floating, not tiled */
- { "firefox_EXAMPLE", NULL, 1 << 8, 0, -1 }, /* Start on ONLY tag "9" */
+ { "Gimp_EXAMPLE", NULL, 0, 1, default_opacity_unfocus, -1 }, /* Start on currently visible tags floating, not tiled */
+ { "firefox_EXAMPLE", NULL, 1 << 8, 0, 1.00, -1 }, /* Start on ONLY tag "9" */
+ { "Gimp_EXAMPLE", NULL, 0, 1, 1.00, 0.20, -1 }, /* Start on currently visible tags floating, not tiled */
+ { "firefox_EXAMPLE", NULL, 1 << 8, 0, 1.00, 1.00, -1 }, /* Start on ONLY tag "9" */
};
/* layout(s) */
@ -47,7 +47,7 @@ index 95c2afa..b7002f5 100644
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_space, togglefloating, {0} },
{ MODKEY, XKB_KEY_e, togglefullscreen, {0} },
diff --git a/dwl.c b/dwl.c
index 12f441e..7539738 100644
index 12f441e..e45e420 100644
--- a/dwl.c
+++ b/dwl.c
@@ -138,6 +138,9 @@ typedef struct {
@ -60,15 +60,16 @@ index 12f441e..7539738 100644
uint32_t resize; /* configure serial of a pending resize */
} Client;
@@ -227,6 +230,7 @@ typedef struct {
@@ -227,6 +230,8 @@ typedef struct {
const char *title;
uint32_t tags;
int isfloating;
+ float opacity_focus;
+ float opacity_unfocus;
int monitor;
} Rule;
@@ -319,6 +323,7 @@ static void requeststartdrag(struct wl_listener *listener, void *data);
@@ -319,6 +324,7 @@ static void requeststartdrag(struct wl_listener *listener, void *data);
static void requestmonstate(struct wl_listener *listener, void *data);
static void resize(Client *c, struct wlr_box geo, int interact);
static void run(char *startup_cmd);
@ -76,7 +77,7 @@ index 12f441e..7539738 100644
static void setcursor(struct wl_listener *listener, void *data);
static void setcursorshape(struct wl_listener *listener, void *data);
static void setfloating(Client *c, int floating);
@@ -326,6 +331,8 @@ static void setfullscreen(Client *c, int fullscreen);
@@ -326,6 +332,8 @@ static void setfullscreen(Client *c, int fullscreen);
static void setlayout(const Arg *arg);
static void setmfact(const Arg *arg);
static void setmon(Client *c, Monitor *m, uint32_t newtags);
@ -85,15 +86,16 @@ index 12f441e..7539738 100644
static void setpsel(struct wl_listener *listener, void *data);
static void setsel(struct wl_listener *listener, void *data);
static void setup(void);
@@ -490,6 +497,7 @@ applyrules(Client *c)
@@ -490,6 +498,8 @@ applyrules(Client *c)
if ((!r->title || strstr(title, r->title))
&& (!r->id || strstr(appid, r->id))) {
c->isfloating = r->isfloating;
+ c->opacity = r->opacity_unfocus;
+ c->opacity_unfocus = r->opacity_unfocus;
+ c->opacity_focus = r->opacity_focus;
newtags |= r->tags;
i = 0;
wl_list_for_each(m, &mons, link) {
@@ -1127,6 +1135,10 @@ createnotify(struct wl_listener *listener, void *data)
@@ -1127,6 +1137,10 @@ createnotify(struct wl_listener *listener, void *data)
c = toplevel->base->data = ecalloc(1, sizeof(*c));
c->surface.xdg = toplevel->base;
c->bw = borderpx;
@ -104,7 +106,7 @@ index 12f441e..7539738 100644
LISTEN(&toplevel->base->surface->events.commit, &c->commit, commitnotify);
LISTEN(&toplevel->base->surface->events.map, &c->map, mapnotify);
@@ -1429,6 +1441,7 @@ focusclient(Client *c, int lift)
@@ -1429,6 +1443,7 @@ focusclient(Client *c, int lift)
wl_list_insert(&fstack, &c->flink);
selmon = c->mon;
c->isurgent = 0;
@ -112,7 +114,7 @@ index 12f441e..7539738 100644
/* Don't change border color if there is an exclusive focus or we are
* handling a drag operation */
@@ -1453,6 +1466,7 @@ focusclient(Client *c, int lift)
@@ -1453,6 +1468,7 @@ focusclient(Client *c, int lift)
client_set_border_color(old_c, bordercolor);
client_activate_surface(old, 0);
@ -120,7 +122,7 @@ index 12f441e..7539738 100644
}
}
printstatus();
@@ -2159,6 +2173,7 @@ rendermon(struct wl_listener *listener, void *data)
@@ -2159,6 +2175,7 @@ rendermon(struct wl_listener *listener, void *data)
/* Render if no XDG clients have an outstanding resize and are visible on
* this monitor. */
wl_list_for_each(c, &clients, link) {
@ -128,7 +130,7 @@ index 12f441e..7539738 100644
if (c->resize && !c->isfloating && client_is_rendered_on_mon(c, m) && !client_is_stopped(c))
goto skip;
}
@@ -2295,6 +2310,15 @@ run(char *startup_cmd)
@@ -2295,6 +2312,15 @@ run(char *startup_cmd)
wl_display_run(dpy);
}
@ -144,7 +146,7 @@ index 12f441e..7539738 100644
void
setcursor(struct wl_listener *listener, void *data)
{
@@ -2363,6 +2387,7 @@ setfullscreen(Client *c, int fullscreen)
@@ -2363,6 +2389,7 @@ setfullscreen(Client *c, int fullscreen)
* client positions are set by the user and cannot be recalculated */
resize(c, c->prev, 0);
}
@ -152,7 +154,7 @@ index 12f441e..7539738 100644
arrange(c->mon);
printstatus();
}
@@ -2419,6 +2444,44 @@ setmon(Client *c, Monitor *m, uint32_t newtags)
@@ -2419,6 +2446,44 @@ setmon(Client *c, Monitor *m, uint32_t newtags)
focusclient(focustop(selmon), 1);
}
@ -198,5 +200,5 @@ index 12f441e..7539738 100644
setpsel(struct wl_listener *listener, void *data)
{
--
2.51.2
2.53.0

View File

@ -1,7 +1,7 @@
From a14dff19f38fffa498f3de4679952b39b4323502 Mon Sep 17 00:00:00 2001
From 3a142ab58c5a66d2d71a8184b7e318d0f9d048c6 Mon Sep 17 00:00:00 2001
From: pi66 <pixel2176@proton.me>
Date: Wed, 8 Apr 2026 21:47:41 +0100
Subject: [PATCH] feat: add pad/tool bindings and pen region
Date: Mon, 27 Apr 2026 21:13:38 +0100
Subject: [PATCH] fix: enable focus-follow-mouse for tablet pen input
---
Makefile | 6 +-
@ -34,7 +34,7 @@ index 578194f..e0d1835 100644
config.h:
cp config.def.h $@
diff --git a/config.def.h b/config.def.h
index 8a6eda0..288494e 100644
index 8a6eda0..9c678d4 100644
--- a/config.def.h
+++ b/config.def.h
@@ -4,6 +4,7 @@
@ -75,7 +75,7 @@ index 8a6eda0..288494e 100644
+ { 0, 0, NULL, {0} }
+};
diff --git a/dwl.c b/dwl.c
index 44f3ad9..7572756 100644
index 44f3ad9..a5ae8e7 100644
--- a/dwl.c
+++ b/dwl.c
@@ -51,6 +51,9 @@
@ -132,7 +132,7 @@ index 44f3ad9..7572756 100644
static void startdrag(struct wl_listener *listener, void *data);
static void tag(const Arg *arg);
static void tagmon(const Arg *arg);
+static void tablettoolmotion(struct wlr_tablet_v2_tablet_tool *tool, bool change_x, bool change_y, double x, double y, double dx, double dy);
+static void tablettoolmotion(struct wlr_tablet_v2_tablet_tool *tool, bool change_x, bool change_y, double x, double y, double dx, double dy, uint32_t time);
+static void tablettoolproximity(struct wl_listener *listener, void *data);
+static void tabletpadbutton(struct wl_listener *listener, void *data);
+static void tablettoolaxis(struct wl_listener *listener, void *data);
@ -326,7 +326,7 @@ index 44f3ad9..7572756 100644
+
+void
+tablettoolmotion(struct wlr_tablet_v2_tablet_tool *tool, bool change_x, bool change_y,
+ double x, double y, double dx, double dy)
+ double x, double y, double dx, double dy, uint32_t time)
+{
+ struct wlr_surface *surface = NULL;
+ double sx, sy;
@ -351,7 +351,7 @@ index 44f3ad9..7572756 100644
+ break;
+ }
+
+ motionnotify(0, NULL, 0, 0, 0, 0);
+ motionnotify(time, NULL, 0, 0, 0, 0);
+
+ xytonode(cursor->x, cursor->y, &surface, NULL, NULL, &sx, &sy);
+ if (surface && !wlr_surface_accepts_tablet_v2(surface, tablet))
@ -398,7 +398,7 @@ index 44f3ad9..7572756 100644
+ destroytabletsurfacenotify(NULL, NULL);
+ break;
+ case WLR_TABLET_TOOL_PROXIMITY_IN:
+ tablettoolmotion(tablet_tool, true, true, event->x, event->y, 0, 0);
+ tablettoolmotion(tablet_tool, true, true, event->x, event->y, 0, 0, event->time_msec);
+ break;
+ }
+}
@ -414,7 +414,7 @@ index 44f3ad9..7572756 100644
+ tablettoolmotion(tablet_tool,
+ event->updated_axes & WLR_TABLET_TOOL_AXIS_X,
+ event->updated_axes & WLR_TABLET_TOOL_AXIS_Y,
+ event->x, event->y, event->dx, event->dy);
+ event->x, event->y, event->dx, event->dy, event->time_msec);
+
+ if (event->updated_axes & WLR_TABLET_TOOL_AXIS_PRESSURE)
+ wlr_tablet_v2_tablet_tool_notify_pressure(tablet_tool, event->pressure);

View File

@ -1,7 +1,7 @@
From a14dff19f38fffa498f3de4679952b39b4323502 Mon Sep 17 00:00:00 2001
From 63b62ff508ecd2e74d95ba0550b3ec856b478bbb Mon Sep 17 00:00:00 2001
From: pi66 <pixel2176@proton.me>
Date: Wed, 8 Apr 2026 21:47:41 +0100
Subject: [PATCH] feat: add pad/tool bindings and pen region
Date: Mon, 27 Apr 2026 21:21:52 +0100
Subject: [PATCH] fix: enable focus-follow-mouse for tablet pen input
---
Makefile | 6 +-
@ -34,7 +34,7 @@ index 578194f..e0d1835 100644
config.h:
cp config.def.h $@
diff --git a/config.def.h b/config.def.h
index 8a6eda0..288494e 100644
index 8a6eda0..9c678d4 100644
--- a/config.def.h
+++ b/config.def.h
@@ -4,6 +4,7 @@
@ -75,10 +75,10 @@ index 8a6eda0..288494e 100644
+ { 0, 0, NULL, {0} }
+};
diff --git a/dwl.c b/dwl.c
index 44f3ad9..7572756 100644
index 101a45f..f09b662 100644
--- a/dwl.c
+++ b/dwl.c
@@ -51,6 +51,9 @@
@@ -52,6 +52,9 @@
#include <wlr/types/wlr_session_lock_v1.h>
#include <wlr/types/wlr_single_pixel_buffer_v1.h>
#include <wlr/types/wlr_subcompositor.h>
@ -88,7 +88,7 @@ index 44f3ad9..7572756 100644
#include <wlr/types/wlr_viewporter.h>
#include <wlr/types/wlr_virtual_keyboard_v1.h>
#include <wlr/types/wlr_virtual_pointer_v1.h>
@@ -239,6 +242,20 @@ typedef struct {
@@ -240,6 +243,20 @@ typedef struct {
struct wl_listener destroy;
} SessionLock;
@ -109,7 +109,7 @@ index 44f3ad9..7572756 100644
/* function declarations */
static void applybounds(Client *c, struct wlr_box *bbox);
static void applyrules(Client *c);
@@ -268,6 +285,7 @@ static void createnotify(struct wl_listener *listener, void *data);
@@ -269,6 +286,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);
@ -117,7 +117,7 @@ index 44f3ad9..7572756 100644
static void cursorconstrain(struct wlr_pointer_constraint_v1 *constraint);
static void cursorframe(struct wl_listener *listener, void *data);
static void cursorwarptohint(void);
@@ -281,6 +299,10 @@ static void destroynotify(struct wl_listener *listener, void *data);
@@ -282,6 +300,10 @@ 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 destroykeyboardgroup(struct wl_listener *listener, void *data);
@ -128,11 +128,11 @@ index 44f3ad9..7572756 100644
static Monitor *dirtomon(enum wlr_direction dir);
static void focusclient(Client *c, int lift);
static void focusmon(const Arg *arg);
@@ -333,6 +355,12 @@ static void spawn(const Arg *arg);
@@ -334,6 +356,12 @@ 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);
+static void tablettoolmotion(struct wlr_tablet_v2_tablet_tool *tool, bool change_x, bool change_y, double x, double y, double dx, double dy);
+static void tablettoolmotion(struct wlr_tablet_v2_tablet_tool *tool, bool change_x, bool change_y, double x, double y, double dx, double dy, uint32_t time);
+static void tablettoolproximity(struct wl_listener *listener, void *data);
+static void tabletpadbutton(struct wl_listener *listener, void *data);
+static void tablettoolaxis(struct wl_listener *listener, void *data);
@ -141,7 +141,7 @@ index 44f3ad9..7572756 100644
static void tile(Monitor *m);
static void togglefloating(const Arg *arg);
static void togglefullscreen(const Arg *arg);
@@ -390,6 +418,13 @@ static struct wlr_pointer_constraint_v1 *active_constraint;
@@ -391,6 +419,13 @@ static struct wlr_pointer_constraint_v1 *active_constraint;
static struct wlr_cursor *cursor;
static struct wlr_xcursor_manager *cursor_mgr;
@ -155,7 +155,7 @@ index 44f3ad9..7572756 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;
@@ -412,6 +447,14 @@ static struct wl_listener cursor_button = {.notify = buttonpress};
@@ -413,6 +448,14 @@ 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};
@ -170,7 +170,7 @@ index 44f3ad9..7572756 100644
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};
@@ -1199,6 +1242,27 @@ createpopup(struct wl_listener *listener, void *data)
@@ -1200,6 +1243,27 @@ createpopup(struct wl_listener *listener, void *data)
LISTEN_STATIC(&popup->base->surface->events.commit, commitpopup);
}
@ -198,7 +198,7 @@ index 44f3ad9..7572756 100644
void
cursorconstrain(struct wlr_pointer_constraint_v1 *constraint)
{
@@ -1383,6 +1447,37 @@ destroykeyboardgroup(struct wl_listener *listener, void *data)
@@ -1384,6 +1448,37 @@ destroykeyboardgroup(struct wl_listener *listener, void *data)
free(group);
}
@ -236,7 +236,7 @@ index 44f3ad9..7572756 100644
Monitor *
dirtomon(enum wlr_direction dir)
{
@@ -1581,6 +1676,7 @@ inputdevice(struct wl_listener *listener, void *data)
@@ -1582,6 +1677,7 @@ inputdevice(struct wl_listener *listener, void *data)
/* This event is raised by the backend when a new input device becomes
* available. */
struct wlr_input_device *device = data;
@ -244,7 +244,7 @@ index 44f3ad9..7572756 100644
uint32_t caps;
switch (device->type) {
@@ -1590,6 +1686,15 @@ inputdevice(struct wl_listener *listener, void *data)
@@ -1591,6 +1687,15 @@ inputdevice(struct wl_listener *listener, void *data)
case WLR_INPUT_DEVICE_POINTER:
createpointer(wlr_pointer_from_input_device(device));
break;
@ -260,7 +260,7 @@ index 44f3ad9..7572756 100644
default:
/* TODO handle other input device types */
break;
@@ -2585,6 +2690,8 @@ setup(void)
@@ -2587,6 +2692,8 @@ setup(void)
relative_pointer_mgr = wlr_relative_pointer_manager_v1_create(dpy);
@ -269,7 +269,7 @@ index 44f3ad9..7572756 100644
/*
* Creates a cursor, which is a wlroots utility for tracking the cursor
* image shown on screen.
@@ -2614,6 +2721,11 @@ setup(void)
@@ -2616,6 +2723,11 @@ setup(void)
wl_signal_add(&cursor->events.button, &cursor_button);
wl_signal_add(&cursor->events.axis, &cursor_axis);
wl_signal_add(&cursor->events.frame, &cursor_frame);
@ -281,7 +281,7 @@ index 44f3ad9..7572756 100644
cursor_shape_mgr = wlr_cursor_shape_manager_v1_create(dpy, 1);
wl_signal_add(&cursor_shape_mgr->events.request_set_shape, &request_set_cursor_shape);
@@ -2709,6 +2821,197 @@ tagmon(const Arg *arg)
@@ -2711,6 +2823,197 @@ tagmon(const Arg *arg)
setmon(sel, dirtomon(arg->i), 0);
}
@ -326,7 +326,7 @@ index 44f3ad9..7572756 100644
+
+void
+tablettoolmotion(struct wlr_tablet_v2_tablet_tool *tool, bool change_x, bool change_y,
+ double x, double y, double dx, double dy)
+ double x, double y, double dx, double dy, uint32_t time)
+{
+ struct wlr_surface *surface = NULL;
+ double sx, sy;
@ -351,7 +351,7 @@ index 44f3ad9..7572756 100644
+ break;
+ }
+
+ motionnotify(0, NULL, 0, 0, 0, 0);
+ motionnotify(time, NULL, 0, 0, 0, 0);
+
+ xytonode(cursor->x, cursor->y, &surface, NULL, NULL, &sx, &sy);
+ if (surface && !wlr_surface_accepts_tablet_v2(surface, tablet))
@ -398,7 +398,7 @@ index 44f3ad9..7572756 100644
+ destroytabletsurfacenotify(NULL, NULL);
+ break;
+ case WLR_TABLET_TOOL_PROXIMITY_IN:
+ tablettoolmotion(tablet_tool, true, true, event->x, event->y, 0, 0);
+ tablettoolmotion(tablet_tool, true, true, event->x, event->y, 0, 0, event->time_msec);
+ break;
+ }
+}
@ -414,7 +414,7 @@ index 44f3ad9..7572756 100644
+ tablettoolmotion(tablet_tool,
+ event->updated_axes & WLR_TABLET_TOOL_AXIS_X,
+ event->updated_axes & WLR_TABLET_TOOL_AXIS_Y,
+ event->x, event->y, event->dx, event->dy);
+ event->x, event->y, event->dx, event->dy, event->time_msec);
+
+ if (event->updated_axes & WLR_TABLET_TOOL_AXIS_PRESSURE)
+ wlr_tablet_v2_tablet_tool_notify_pressure(tablet_tool, event->pressure);