fix crash when the last monitor is disconnected
This commit is contained in:
parent
3e6d584de1
commit
8cace19218
1 changed files with 16 additions and 5 deletions
15
dwl.c
15
dwl.c
|
@ -57,7 +57,7 @@
|
||||||
#define MAX(A, B) ((A) > (B) ? (A) : (B))
|
#define MAX(A, B) ((A) > (B) ? (A) : (B))
|
||||||
#define MIN(A, B) ((A) < (B) ? (A) : (B))
|
#define MIN(A, B) ((A) < (B) ? (A) : (B))
|
||||||
#define CLEANMASK(mask) (mask & ~WLR_MODIFIER_CAPS)
|
#define CLEANMASK(mask) (mask & ~WLR_MODIFIER_CAPS)
|
||||||
#define VISIBLEON(C, M) ((C)->mon == (M) && ((C)->tags & (M)->tagset[(M)->seltags]))
|
#define VISIBLEON(C, M) ((M) && (C)->mon == (M) && ((C)->tags & (M)->tagset[(M)->seltags]))
|
||||||
#define LENGTH(X) (sizeof X / sizeof X[0])
|
#define LENGTH(X) (sizeof X / sizeof X[0])
|
||||||
#define END(A) ((A) + LENGTH(A))
|
#define END(A) ((A) + LENGTH(A))
|
||||||
#define TAGMASK ((1 << LENGTH(tags)) - 1)
|
#define TAGMASK ((1 << LENGTH(tags)) - 1)
|
||||||
|
@ -720,10 +720,11 @@ cleanupmon(struct wl_listener *listener, void *data)
|
||||||
wl_list_remove(&m->link);
|
wl_list_remove(&m->link);
|
||||||
wlr_output_layout_remove(output_layout, m->wlr_output);
|
wlr_output_layout_remove(output_layout, m->wlr_output);
|
||||||
|
|
||||||
nmons = wl_list_length(&mons);
|
if ((nmons = wl_list_length(&mons)))
|
||||||
do // don't switch to disabled mons
|
do // don't switch to disabled mons
|
||||||
selmon = wl_container_of(mons.prev, selmon, link);
|
selmon = wl_container_of(mons.prev, selmon, link);
|
||||||
while (!selmon->wlr_output->enabled && i++ < nmons);
|
while (!selmon->wlr_output->enabled && i++ < nmons);
|
||||||
|
|
||||||
focusclient(focustop(selmon), 1);
|
focusclient(focustop(selmon), 1);
|
||||||
closemon(m);
|
closemon(m);
|
||||||
free(m);
|
free(m);
|
||||||
|
@ -860,6 +861,16 @@ createmon(struct wl_listener *listener, void *data)
|
||||||
wlr_output_layout_add(output_layout, wlr_output, r->x, r->y);
|
wlr_output_layout_add(output_layout, wlr_output, r->x, r->y);
|
||||||
sgeom = *wlr_output_layout_get_box(output_layout, NULL);
|
sgeom = *wlr_output_layout_get_box(output_layout, NULL);
|
||||||
|
|
||||||
|
/* If length == 1 we need update selmon.
|
||||||
|
* Maybe it will change in run(). */
|
||||||
|
if (wl_list_length(&mons) == 1) {
|
||||||
|
Client *c;
|
||||||
|
selmon = m;
|
||||||
|
/* If there is any client, set c->mon to this monitor */
|
||||||
|
wl_list_for_each(c, &clients, link)
|
||||||
|
setmon(c, m, c->tags);
|
||||||
|
}
|
||||||
|
|
||||||
/* When adding monitors, the geometries of all monitors must be updated */
|
/* When adding monitors, the geometries of all monitors must be updated */
|
||||||
wl_list_for_each(m, &mons, link) {
|
wl_list_for_each(m, &mons, link) {
|
||||||
/* The first monitor in the list is the most recently added */
|
/* The first monitor in the list is the most recently added */
|
||||||
|
|
Loading…
Reference in a new issue