From 9653c017ea9baf56d41e2ae91311747ce05b8316 Mon Sep 17 00:00:00 2001 From: Zoe Roux Date: Sun, 8 Oct 2023 16:31:58 +0200 Subject: [PATCH] Fix dwm bugs with singletagset --- dwl_patches/cursor_warp.patch | 17 +++++++++-- dwl_patches/gdk_monitors_status.patch | 2 +- dwl_patches/singletagset.patch | 42 +++++++++++++++----------- modules/dwl/ags/services/brightness.js | 2 +- modules/dwl/home.nix | 6 ++-- 5 files changed, 45 insertions(+), 24 deletions(-) diff --git a/dwl_patches/cursor_warp.patch b/dwl_patches/cursor_warp.patch index 636e4af..e35d575 100644 --- a/dwl_patches/cursor_warp.patch +++ b/dwl_patches/cursor_warp.patch @@ -1,5 +1,5 @@ diff --git a/dwl.c b/dwl.c -index 0841bef..426ec14 100644 +index 0841bef..b53cc14 100644 --- a/dwl.c +++ b/dwl.c @@ -322,6 +322,7 @@ static void updatetitle(struct wl_listener *listener, void *data); @@ -31,7 +31,20 @@ index 0841bef..426ec14 100644 if ((old_client_type = toplevel_from_wlr_surface(old, &old_c, &old_l)) == XDGShell) { struct wlr_xdg_popup *popup, *tmp; wl_list_for_each_safe(popup, tmp, &old_c->surface.xdg->popups, link) -@@ -2736,6 +2744,18 @@ virtualkeyboard(struct wl_listener *listener, void *data) +@@ -1372,6 +1380,12 @@ focusmon(const Arg *arg) + selmon = dirtomon(arg->i); + while (!selmon->wlr_output->enabled && i++ < nmons); + focusclient(focustop(selmon), 1); ++ if (cursor_warp) { ++ wlr_cursor_warp_closest(cursor, ++ NULL, ++ selmon->m.x + selmon->m.width / 2.0, ++ selmon->m.y + selmon->m.height / 2.0); ++ } + } + + void +@@ -2736,6 +2750,18 @@ virtualkeyboard(struct wl_listener *listener, void *data) createkeyboard(&keyboard->keyboard); } diff --git a/dwl_patches/gdk_monitors_status.patch b/dwl_patches/gdk_monitors_status.patch index cbc99ca..8b84a0b 100644 --- a/dwl_patches/gdk_monitors_status.patch +++ b/dwl_patches/gdk_monitors_status.patch @@ -4,7 +4,7 @@ index a7c2e28..b23067a 100644 +++ b/dwl.c @@ -2090,29 +2090,31 @@ printstatus(void) + if (!m->wlr_output->enabled) -+ return; ++ continue; occ = urg = 0; wl_list_for_each(c, &clients, link) { occ |= c->tags; diff --git a/dwl_patches/singletagset.patch b/dwl_patches/singletagset.patch index cb5f4b5..a3118a6 100644 --- a/dwl_patches/singletagset.patch +++ b/dwl_patches/singletagset.patch @@ -1,8 +1,8 @@ diff --git a/dwl.c b/dwl.c -index e6bb8c6..d7a6e55 100644 +index ae39203..2e60842 100644 --- a/dwl.c +++ b/dwl.c -@@ -245,6 +245,7 @@ static void arrange(Monitor *m); +@@ -234,6 +234,7 @@ static void arrange(Monitor *m); static void arrangelayer(Monitor *m, struct wl_list *list, struct wlr_box *usable_area, int exclusive); static void arrangelayers(Monitor *m); @@ -10,14 +10,15 @@ index e6bb8c6..d7a6e55 100644 static void autostartexec(void); static void axisnotify(struct wl_listener *listener, void *data); static void buttonpress(struct wl_listener *listener, void *data); -@@ -271,5 +272,6 @@ static void focusmon(const Arg *arg); +@@ -271,6 +272,7 @@ static void focusmon(const Arg *arg); static void focusstack(const Arg *arg); static Client *focustop(Monitor *m); static void fullscreennotify(struct wl_listener *listener, void *data); +static size_t getunusedtag(void); static void handlesig(int signo); static void incnmaster(const Arg *arg); -@@ -554,6 +556,15 @@ arrangelayer(Monitor *m, struct wl_list *list, struct wlr_box *usable_area, int + static void inputdevice(struct wl_listener *listener, void *data); +@@ -538,6 +540,15 @@ arrangelayer(Monitor *m, struct wl_list *list, struct wlr_box *usable_area, int } } @@ -33,7 +34,7 @@ index e6bb8c6..d7a6e55 100644 void arrangelayers(Monitor *m) { -@@ -986,7 +997,7 @@ createmon(struct wl_listener *listener, void *data) +@@ -970,7 +981,7 @@ createmon(struct wl_listener *listener, void *data) m->gappiv = gappiv; m->gappoh = gappoh; m->gappov = gappov; @@ -42,7 +43,7 @@ index e6bb8c6..d7a6e55 100644 for (r = monrules; r < END(monrules); r++) { if (!r->name || strstr(wlr_output->name, r->name)) { m->mfact = r->mfact; -@@ -1498,6 +1509,22 @@ fullscreennotify(struct wl_listener *listener, void *data) +@@ -1455,6 +1466,26 @@ fullscreennotify(struct wl_listener *listener, void *data) setfullscreen(c, client_wants_fullscreen(c)); } @@ -50,14 +51,18 @@ index e6bb8c6..d7a6e55 100644 +getunusedtag(void) +{ + size_t i = 0; ++ bool empty = true; + Monitor *m; + if (wl_list_empty(&mons)) + return i; + for (i=0; i < TAGCOUNT; i++) { + wl_list_for_each(m, &mons, link) { -+ if (!(m->tagset[m->seltags] & (1<tagset[m->seltags] & (1<tags; if (c->isurgent) urg |= c->tags; -@@ -2562,22 +2587,32 @@ startdrag(struct wl_listener *listener, void *data) +@@ -2504,22 +2533,32 @@ startdrag(struct wl_listener *listener, void *data) void tag(const Arg *arg) { @@ -109,7 +114,7 @@ index e6bb8c6..d7a6e55 100644 } void -@@ -2645,6 +2680,7 @@ togglefullscreen(const Arg *arg) +@@ -2587,6 +2626,7 @@ togglefullscreen(const Arg *arg) void toggletag(const Arg *arg) { @@ -117,7 +122,7 @@ index e6bb8c6..d7a6e55 100644 uint32_t newtags; Client *sel = focustop(selmon); if (!sel) -@@ -2653,7 +2689,11 @@ toggletag(const Arg *arg) +@@ -2595,7 +2635,11 @@ toggletag(const Arg *arg) if (!newtags) return; @@ -129,7 +134,7 @@ index e6bb8c6..d7a6e55 100644 focusclient(focustop(selmon), 1); arrange(selmon); printstatus(); -@@ -2662,12 +2702,17 @@ toggletag(const Arg *arg) +@@ -2604,12 +2648,17 @@ toggletag(const Arg *arg) void toggleview(const Arg *arg) { @@ -147,11 +152,12 @@ index e6bb8c6..d7a6e55 100644 focusclient(focustop(selmon), 1); arrange(selmon); printstatus(); -@@ -2836,15 +2881,38 @@ urgent(struct wl_listener *listener, void *data) +@@ -2778,15 +2827,41 @@ urgent(struct wl_listener *listener, void *data) void view(const Arg *arg) { + Monitor *m, *origm = selmon; ++ Client *c; + unsigned int newtags = selmon->tagset[selmon->seltags ^ 1]; + if (!selmon || (arg->ui & TAGMASK) == selmon->tagset[selmon->seltags]) { @@ -167,7 +173,7 @@ index e6bb8c6..d7a6e55 100644 - arrange(selmon); + newtags = arg->ui & TAGMASK; + wl_list_for_each(m, &mons, link) { -+ if (m != selmon && newtags & m->tagset[m->seltags]) { ++ if (m != selmon && newtags & m->tagset[m->seltags] && m->wlr_output->enabled) { + /* prevent displaying all tags (MODKEY-0) when multiple monitors + * are connected */ + if (newtags & selmon->tagset[selmon->seltags]) @@ -175,7 +181,8 @@ index e6bb8c6..d7a6e55 100644 + m->seltags ^= 1; + m->tagset[m->seltags] = selmon->tagset[selmon->seltags]; + attachclients(m); -+ focusclient(focustop(m), 1); ++ // disabled since i preffer keeping focus on the current monitor ++ // focusclient(focustop(m), 1); + arrange(m); + break; + } @@ -185,7 +192,8 @@ index e6bb8c6..d7a6e55 100644 + if (arg->ui & TAGMASK) + origm->tagset[origm->seltags] = arg->ui & TAGMASK; + attachclients(origm); -+ focusclient(focustop(origm), 1); ++ c = focustop(origm); ++ focusclient(c, 1); + arrange(origm); printstatus(); } diff --git a/modules/dwl/ags/services/brightness.js b/modules/dwl/ags/services/brightness.js index 3470500..0fc2b68 100644 --- a/modules/dwl/ags/services/brightness.js +++ b/modules/dwl/ags/services/brightness.js @@ -36,4 +36,4 @@ class BrightnessService extends Service { } export const Brightness = new BrightnessService(); -globalThis.brightness = Brightness; +ags.Service.Brightness = Brightness; diff --git a/modules/dwl/home.nix b/modules/dwl/home.nix index 855e8d6..e8c27b0 100644 --- a/modules/dwl/home.nix +++ b/modules/dwl/home.nix @@ -89,20 +89,20 @@ name = "laptop" [[profile]] name = "docked" -exec = "bash -c 'ags -q; cat /proc/$(pidof dwl)/fd/1 | ags'" +exec = ["bash -c 'ags -q; cat /proc/$(pidof dwl)/fd/1 | ags & disown'"] [[profile.output]] match = "eDP-1" enable = false [[profile.output]] - match = "/DP-1|.*|EB243Y A/" + match = "/DP-2|.*|EB243Y A/" enable = true mode = { width = 1920, height = 1080, refresh = 60 } position = { x = 0, y = 0 } scale = 1 [[profile.output]] - match = "/DP-2|.*|EB243Y A/" + match = "/DP-1|.*|EB243Y A/" enable = true mode = { width = 1920, height = 1080, refresh = 60 } position = { x = 0, y = 1180 }