summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuido Cella <guidocella91@gmail.com>2020-09-11 13:09:18 +0200
committerGuido Cella <guidocella91@gmail.com>2020-09-11 13:09:18 +0200
commitfbd905155aa1f7e33b3f7d4a54a3312166902335 (patch)
tree77c9124278cd86f9ce0f11656d908625ebae9c10
parent8f0ce672d384759dd4a3cbcf2b0555b4a87edc7e (diff)
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).
-rw-r--r--dwl.c21
1 files 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