use loop to call arrangelayer

zwlr_layer_shell_v1_layer are ordered by bottom-most first so we can
just use a loop from 3 to 0
This commit is contained in:
Leonardo Hernandez Hernandez 2022-01-26 00:54:00 -06:00 committed by Leonardo Hernández Hernández
parent c49a42ee58
commit 0e5d7124de
No known key found for this signature in database
GPG Key ID: E538897EE11B9624
1 changed files with 7 additions and 18 deletions

25
dwl.c
View File

@ -560,6 +560,7 @@ arrangelayer(Monitor *m, struct wl_list *list, struct wlr_box *usable_area, int
void void
arrangelayers(Monitor *m) arrangelayers(Monitor *m)
{ {
int i;
struct wlr_box usable_area = m->m; struct wlr_box usable_area = m->m;
uint32_t layers_above_shell[] = { uint32_t layers_above_shell[] = {
ZWLR_LAYER_SHELL_V1_LAYER_OVERLAY, ZWLR_LAYER_SHELL_V1_LAYER_OVERLAY,
@ -568,30 +569,18 @@ arrangelayers(Monitor *m)
LayerSurface *layersurface; LayerSurface *layersurface;
struct wlr_keyboard *kb = wlr_seat_get_keyboard(seat); struct wlr_keyboard *kb = wlr_seat_get_keyboard(seat);
// Arrange exclusive surfaces from top->bottom /* Arrange exclusive surfaces from top->bottom */
arrangelayer(m, &m->layers[ZWLR_LAYER_SHELL_V1_LAYER_OVERLAY], for (i = 3; i >= 0; i--)
&usable_area, 1); arrangelayer(m, &m->layers[i], &usable_area, 1);
arrangelayer(m, &m->layers[ZWLR_LAYER_SHELL_V1_LAYER_TOP],
&usable_area, 1);
arrangelayer(m, &m->layers[ZWLR_LAYER_SHELL_V1_LAYER_BOTTOM],
&usable_area, 1);
arrangelayer(m, &m->layers[ZWLR_LAYER_SHELL_V1_LAYER_BACKGROUND],
&usable_area, 1);
if (memcmp(&usable_area, &m->w, sizeof(struct wlr_box))) { if (memcmp(&usable_area, &m->w, sizeof(struct wlr_box))) {
m->w = usable_area; m->w = usable_area;
arrange(m); arrange(m);
} }
// Arrange non-exlusive surfaces from top->bottom /* Arrange non-exlusive surfaces from top->bottom */
arrangelayer(m, &m->layers[ZWLR_LAYER_SHELL_V1_LAYER_OVERLAY], for (i = 3; i >= 0; i--)
&usable_area, 0); arrangelayer(m, &m->layers[i], &usable_area, 0);
arrangelayer(m, &m->layers[ZWLR_LAYER_SHELL_V1_LAYER_TOP],
&usable_area, 0);
arrangelayer(m, &m->layers[ZWLR_LAYER_SHELL_V1_LAYER_BOTTOM],
&usable_area, 0);
arrangelayer(m, &m->layers[ZWLR_LAYER_SHELL_V1_LAYER_BACKGROUND],
&usable_area, 0);
// Find topmost keyboard interactive layer, if such a layer exists // Find topmost keyboard interactive layer, if such a layer exists
for (size_t i = 0; i < LENGTH(layers_above_shell); i++) { for (size_t i = 0; i < LENGTH(layers_above_shell); i++) {