From ec5427a43d56491f3215298e4f4ccd55169aabf3 Mon Sep 17 00:00:00 2001 From: Ray Andrew <4437323+rayandrew@users.noreply.github.com> Date: Sat, 28 Sep 2024 15:30:12 -0500 Subject: [PATCH] add restoremonitor --- dwl.c | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/dwl.c b/dwl.c index a104988..a7af796 100644 --- a/dwl.c +++ b/dwl.c @@ -125,6 +125,7 @@ struct Client { 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; @@ -1327,6 +1328,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; @@ -1415,6 +1417,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 @@ -1650,6 +1659,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); } @@ -2532,6 +2542,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: @@ -3587,8 +3601,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