diff options
author | Stivvo <stivvo01@gmail.com> | 2020-10-30 23:22:55 +0100 |
---|---|---|
committer | Stivvo <stivvo01@gmail.com> | 2020-10-30 23:22:55 +0100 |
commit | d4178b9d2a89c24b99e2b26aec8ac15ab5dcdd84 (patch) | |
tree | d52fa2aa36bb9afaf54d45860353e83613a8144b /dwl.c | |
parent | ef7043e4d1445142ab18bf7de886f1963fbade8b (diff) |
Closemon(), newmon as parameter
This allows to fix output-management: move clients to the monitor on the
left of the disabled one, instead of the leftmost (which might happen to
be the disabled one)
Also using wl_list_foreach() and then brake after the first iteration is
ugly and inefficient
Diffstat (limited to 'dwl.c')
-rw-r--r-- | dwl.c | 25 |
1 files changed, 10 insertions, 15 deletions
@@ -204,7 +204,7 @@ static void chvt(const Arg *arg); static void cleanup(void); static void cleanupkeyboard(struct wl_listener *listener, void *data); static void cleanupmon(struct wl_listener *listener, void *data); -static void closemon(Monitor *m); +static void closemon(Monitor *m, Monitor *newmon); static void commitlayersurfacenotify(struct wl_listener *listener, void *data); static void commitnotify(struct wl_listener *listener, void *data); static void createkeyboard(struct wlr_input_device *device); @@ -688,7 +688,7 @@ void cleanupmon(struct wl_listener *listener, void *data) { struct wlr_output *wlr_output = data; - Monitor *m = wlr_output->data; + Monitor *m = wlr_output->data, *newmon; wl_list_remove(&m->destroy.link); wl_list_remove(&m->frame.link); @@ -696,27 +696,22 @@ cleanupmon(struct wl_listener *listener, void *data) wlr_output_layout_remove(output_layout, m->wlr_output); updatemons(); - closemon(m); + closemon(m, wl_container_of(mons.next, newmon, link)); free(m); } void -closemon(Monitor *m) +closemon(Monitor *m, Monitor *newmon) { // move all the clients on a closed monitor to another one - Monitor *newmon; Client *c; - wl_list_for_each(newmon, &mons, link) { - wl_list_for_each(c, &clients, link) { - if (c->isfloating && c->geom.x > m->m.width) { - resize(c, c->geom.x - m->w.width, c->geom.y, - c->geom.width, c->geom.height, 0); - } - if (c->mon == m) - setmon(c, newmon, c->tags); - } - break; + wl_list_for_each(c, &clients, link) { + if (c->isfloating && c->geom.x > m->m.width) + resize(c, c->geom.x - m->w.width, c->geom.y, + c->geom.width, c->geom.height, 0); + if (c->mon == m) + setmon(c, newmon, c->tags); } } |