From 86fc4bd35d7020bbce120114a4ae1cf3fd728df2 Mon Sep 17 00:00:00 2001 From: Hans von Hohenstaufen Date: Mon, 27 Apr 2026 04:25:20 +0000 Subject: [PATCH] Fix rules for focus and unfocus --- patches/client-opacity-focus/README.md | 2 +- .../client-opacity-focus.patch | 44 ++++++++++--------- 2 files changed, 24 insertions(+), 22 deletions(-) diff --git a/patches/client-opacity-focus/README.md b/patches/client-opacity-focus/README.md index 69b158a..cb2c8b5 100644 --- a/patches/client-opacity-focus/README.md +++ b/patches/client-opacity-focus/README.md @@ -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) diff --git a/patches/client-opacity-focus/client-opacity-focus.patch b/patches/client-opacity-focus/client-opacity-focus.patch index 37f7e4d..cc3cbe2 100644 --- a/patches/client-opacity-focus/client-opacity-focus.patch +++ b/patches/client-opacity-focus/client-opacity-focus.patch @@ -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 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