From ef3dbbf29ac818e21503d647fcbf947bcd85921e Mon Sep 17 00:00:00 2001 From: Consus Date: Tue, 28 Jun 2022 22:47:48 +0300 Subject: [PATCH] Fix usable area calculation Currently if a surface with exclusive zone is created prior to regular surfaces, the size of the exclusize zone does not affect the usable area for regular surfaces. This for example results in notifications being rendered over the statusbar. This commit fixes the issue by handling the surfaces with exclusive zones first. Fixes #420. --- src/layers.c | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/src/layers.c b/src/layers.c index d36e11a5..8a03d3cb 100644 --- a/src/layers.c +++ b/src/layers.c @@ -37,11 +37,29 @@ layers_arrange(struct output *output) int nr_layers = sizeof(output->layers) / sizeof(output->layers[0]); for (int i = 0; i < nr_layers; i++) { struct lab_layer_surface *lab_layer_surface; + + /* + * First we go over the list of surfaces that have + * exclusive_zone set (e.g. statusbars) because we have to + * determine the usable area before processing regular layouts. + */ wl_list_for_each(lab_layer_surface, &output->layers[i], link) { struct wlr_scene_layer_surface_v1 *scene_layer_surface = lab_layer_surface->scene_layer_surface; - wlr_scene_layer_surface_v1_configure( - scene_layer_surface, &full_area, &usable_area); + if (scene_layer_surface->layer_surface->current.exclusive_zone) { + wlr_scene_layer_surface_v1_configure( + scene_layer_surface, &full_area, &usable_area); + } + } + + /* Now we process regular layouts */ + wl_list_for_each(lab_layer_surface, &output->layers[i], link) { + struct wlr_scene_layer_surface_v1 *scene_layer_surface = + lab_layer_surface->scene_layer_surface; + if (!scene_layer_surface->layer_surface->current.exclusive_zone) { + wlr_scene_layer_surface_v1_configure( + scene_layer_surface, &full_area, &usable_area); + } } wlr_scene_node_set_position(&output->layer_tree[i]->node, @@ -350,7 +368,7 @@ new_layer_surface_notify(struct wl_listener *listener, void *data) return; } - wl_list_insert(&output->layers[layer_surface->pending.layer], + wl_list_insert(output->layers[layer_surface->pending.layer].prev, &surface->link); /* * Temporarily set the layer's current state to pending so that