diff options
author | Leonard Kugis <leonard@kug.is> | 2025-05-23 11:41:09 +0000 |
---|---|---|
committer | Leonard Kugis <leonard@kug.is> | 2025-05-23 11:41:09 +0000 |
commit | c70505d7c7b7b48600f273357694b56ccf5d2a15 (patch) | |
tree | 21c27ac6ffced8d6d904e35bdb39baa5d685d829 /dwl-patches/patches/restore-monitor | |
download | dotfiles-master.tar.gz dotfiles-master.tar.bz2 dotfiles-master.zip |
Diffstat (limited to 'dwl-patches/patches/restore-monitor')
-rw-r--r-- | dwl-patches/patches/restore-monitor/README.md | 8 | ||||
-rw-r--r-- | dwl-patches/patches/restore-monitor/restore-monitor.patch | 82 |
2 files changed, 90 insertions, 0 deletions
diff --git a/dwl-patches/patches/restore-monitor/README.md b/dwl-patches/patches/restore-monitor/README.md new file mode 100644 index 0000000..8380967 --- /dev/null +++ b/dwl-patches/patches/restore-monitor/README.md @@ -0,0 +1,8 @@ +### Description
+Moves clients to their old output when it is reattached.
+
+### Download
+- [git branch](https://codeberg.org/eyusupov/dwl/src/branch/restore-monitor)
+- [2024-04-07](https://codeberg.org/dwl/dwl-patches/raw/branch/main/patches/restore-monitor/restore-monitor.patch)
+### Authors
+- [eyusupov](https://codeberg.org/eyusupov)
\ No newline at end of file diff --git a/dwl-patches/patches/restore-monitor/restore-monitor.patch b/dwl-patches/patches/restore-monitor/restore-monitor.patch new file mode 100644 index 0000000..0d6da98 --- /dev/null +++ b/dwl-patches/patches/restore-monitor/restore-monitor.patch @@ -0,0 +1,82 @@ +From e42ca1c539437d3098d80983cfe2ad6f938d7a08 Mon Sep 17 00:00:00 2001 +From: Eldar Yusupov <eyusupov@gmail.com> +Date: Sun, 17 Mar 2024 19:12:29 +0300 +Subject: [PATCH] Restore correct montior for client when it is reattached + +--- + dwl.c | 24 ++++++++++++++++++++++-- + 1 file changed, 22 insertions(+), 2 deletions(-) + +diff --git a/dwl.c b/dwl.c +index bf763df..d8d8139 100644 +--- a/dwl.c ++++ b/dwl.c +@@ -107,6 +107,7 @@ typedef struct { + unsigned int type; /* XDGShell or X11* */ + struct wlr_box geom; /* layout-relative, includes border */ + Monitor *mon; ++ char *output; + struct wlr_scene_tree *scene; + struct wlr_scene_rect *border[4]; /* top, bottom, left, right */ + struct wlr_scene_tree *scene_surface; +@@ -869,6 +870,7 @@ createmon(struct wl_listener *listener, void *data) + size_t i; + struct wlr_output_state state; + Monitor *m; ++ Client *c; + + if (!wlr_output_init_render(wlr_output, alloc, drw)) + return; +@@ -938,6 +940,13 @@ createmon(struct wl_listener *listener, void *data) + wlr_output_layout_add_auto(output_layout, wlr_output); + else + wlr_output_layout_add(output_layout, wlr_output, m->m.x, m->m.y); ++ ++ wl_list_for_each(c, &clients, link) { ++ if (strcmp(wlr_output->name, c->output) == 0) { ++ c->mon = m; ++ } ++ } ++ updatemons(NULL, NULL); + } + + void +@@ -1186,6 +1195,7 @@ destroynotify(struct wl_listener *listener, void *data) + wl_list_remove(&c->map.link); + wl_list_remove(&c->unmap.link); + } ++ free(c->output); + free(c); + } + +@@ -1618,6 +1628,10 @@ mapnotify(struct wl_listener *listener, void *data) + } else { + applyrules(c); + } ++ c->output = strdup(c->mon->wlr_output->name); ++ if (c->output == NULL) { ++ die("oom"); ++ } + printstatus(); + + unset_fullscreen: +@@ -2565,8 +2579,14 @@ void + tagmon(const Arg *arg) + { + Client *sel = focustop(selmon); +- if (sel) +- setmon(sel, dirtomon(arg->i), 0); ++ if (!sel) ++ return; ++ setmon(sel, dirtomon(arg->i), 0); ++ free(sel->output); ++ sel->output = strdup(sel->mon->wlr_output->name); ++ if (sel->output == NULL) { ++ die("oom"); ++ } + } + + void +-- +2.44.0 + |