/* First remove from the layout the disabled monitors */
wl_list_for_each(m, &mons, link) {
int nmons, i = 0;
if (m->wlr_output->enabled)
continue;
config_head = wlr_output_configuration_head_v1_create(config, m->wlr_output);
config_head->state.enabled = 0;
if (m == selmon && (nmons = wl_list_length(&mons)))
do /* don't switch to disabled mons */
selmon = wl_container_of(mons.next, selmon, link);
while (!selmon->wlr_output->enabled && i++ < nmons);
/* Remove this output from the layout to avoid cursor enter inside it */
wlr_output_layout_remove(output_layout, m->wlr_output);
focusclient(focustop(selmon), 1);
closemon(m);
memset(&m->m, 0, sizeof(m->m));
memset(&m->w, 0, sizeof(m->w));
}
/* Insert outputs that need to */
wl_list_for_each(m, &mons, link)
if (m->wlr_output->enabled
&& !wlr_output_layout_get(output_layout, m->wlr_output))
wlr_output_layout_add_auto(output_layout, m->wlr_output);
/* Now that we update the output layout we can get its box */