From fbd905155aa1f7e33b3f7d4a54a3312166902335 Mon Sep 17 00:00:00 2001 From: Guido Cella Date: Fri, 11 Sep 2020 13:09:18 +0200 Subject: fix multi monitors even more When a monitor is created or removed, the geometries of the old ones must be updated. This is also more efficient than before since we calculate the monitor geometries only when creating and destroying monitors. arrangelayers() is needed to recalculate m->w. arrange() is so clients don't move to the left monitor when plugging or unplugging monitors (clients keep the same coordinates but the field below them changes). --- dwl.c | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/dwl.c b/dwl.c index 7bf8e5b..0d92d35 100644 --- a/dwl.c +++ b/dwl.c @@ -472,7 +472,7 @@ void arrangelayer(Monitor *m, struct wl_list *list, struct wlr_box *usable_area, bool exclusive) { LayerSurface *layersurface; - struct wlr_box full_area = *wlr_output_layout_get_box(output_layout, m->wlr_output); + struct wlr_box full_area = m->m; wl_list_for_each(layersurface, list, link) { struct wlr_layer_surface_v1 *wlr_layer_surface = layersurface->layer_surface; @@ -547,7 +547,7 @@ arrangelayer(Monitor *m, struct wl_list *list, struct wlr_box *usable_area, bool void arrangelayers(Monitor *m) { - struct wlr_box usable_area = *wlr_output_layout_get_box(output_layout, m->wlr_output); + struct wlr_box usable_area = m->m; uint32_t layers_above_shell[] = { ZWLR_LAYER_SHELL_V1_LAYER_OVERLAY, ZWLR_LAYER_SHELL_V1_LAYER_TOP, @@ -690,6 +690,12 @@ cleanupmon(struct wl_listener *listener, void *data) wl_list_remove(&m->destroy.link); free(m); + + wl_list_for_each(m, &mons, link) { + m->m = m->w = *wlr_output_layout_get_box(output_layout, m->wlr_output); + arrangelayers(m); + arrange(m); + } } void @@ -813,13 +819,16 @@ createmon(struct wl_listener *listener, void *data) wlr_output_layout_add_auto(output_layout, wlr_output); sgeom = *wlr_output_layout_get_box(output_layout, NULL); - /* Get effective monitor geometry to use for window area */ - m->m = *wlr_output_layout_get_box(output_layout, m->wlr_output); - m->w = m->m; - for (size_t i = 0; i < nlayers; ++i) { wl_list_init(&m->layers[i]); } + + /* Get effective monitor geometry to use for window area */ + wl_list_for_each(m, &mons, link) { + m->m = m->w = *wlr_output_layout_get_box(output_layout, m->wlr_output); + arrangelayers(m); + arrange(m); + } } void -- cgit v1.2.3