Commit 39e493eb5bf766599c21abad7e37693e3ab22911 Parent: d1d22eb074acd47994e76007ba56fb8d525f9b7a Author: mcol <mcol@posteo.net> Date: 2021-01-28 21:50:12 +0000 Committer: mcol <mcol@posteo.net> Committed: 2021-01-28 21:50:12 +0000 Organise layers into arrays on struct output Closes #15.
src/types.h Modified
@@ -112,7 +112,7 @@ struct output { struct wl_list link; - struct wl_list layer_views; + struct wl_list layer_views[4]; struct wlr_output *wlr_output; struct wl_listener frame_listener; };
src/output.c Modified
@@ -125,19 +125,15 @@ // paint background and bottom layers struct layer_view *lview; - wl_list_for_each(lview, &output->layer_views, link) { - if (lview->surface->current.layer == ZWLR_LAYER_SHELL_V1_LAYER_BACKGROUND) { - wlr_surface_for_each_surface( - lview->surface->surface, render_surface, &rdata - ); - } + wl_list_for_each(lview, &output->layer_views[ZWLR_LAYER_SHELL_V1_LAYER_BACKGROUND], link) { + wlr_surface_for_each_surface( + lview->surface->surface, render_surface, &rdata + ); } - wl_list_for_each(lview, &output->layer_views, link) { - if (lview->surface->current.layer == ZWLR_LAYER_SHELL_V1_LAYER_BOTTOM) { - wlr_surface_for_each_surface( - lview->surface->surface, render_surface, &rdata - ); - } + wl_list_for_each(lview, &output->layer_views[ZWLR_LAYER_SHELL_V1_LAYER_BOTTOM], link) { + wlr_surface_for_each_surface( + lview->surface->surface, render_surface, &rdata + ); } // paint clients @@ -157,19 +153,15 @@ rdata.y = 0; // paint top and overlay layers - wl_list_for_each(lview, &output->layer_views, link) { - if (lview->surface->current.layer == ZWLR_LAYER_SHELL_V1_LAYER_TOP) { - wlr_surface_for_each_surface( - lview->surface->surface, render_surface, &rdata - ); - } + wl_list_for_each(lview, &output->layer_views[ZWLR_LAYER_SHELL_V1_LAYER_TOP], link) { + wlr_surface_for_each_surface( + lview->surface->surface, render_surface, &rdata + ); } - wl_list_for_each(lview, &output->layer_views, link) { - if (lview->surface->current.layer == ZWLR_LAYER_SHELL_V1_LAYER_OVERLAY) { - wlr_surface_for_each_surface( - lview->surface->surface, render_surface, &rdata - ); - } + wl_list_for_each(lview, &output->layer_views[ZWLR_LAYER_SHELL_V1_LAYER_OVERLAY], link) { + wlr_surface_for_each_surface( + lview->surface->surface, render_surface, &rdata + ); } // paint mark indicator @@ -209,7 +201,10 @@ wl_list_insert(&wimp.outputs, &output->link); wlr_output_layout_add_auto(wimp.output_layout, wlr_output); - wl_list_init(&output->layer_views); + wl_list_init(&output->layer_views[0]); + wl_list_init(&output->layer_views[1]); + wl_list_init(&output->layer_views[2]); + wl_list_init(&output->layer_views[3]); }
src/main.c Modified
@@ -83,10 +83,12 @@ struct output *output, *toutput; struct layer_view *lview, *tlview; wl_list_for_each_safe(output, toutput, &wimp.outputs, link) { - wl_list_for_each_safe(lview, tlview, &output->layer_views, link) { - wl_list_remove(&lview->link); - free(lview); - }; + for (int i = 0; i < 4; i++ ) { + wl_list_for_each_safe(lview, tlview, &output->layer_views[i], link) { + wl_list_remove(&lview->link); + free(lview); + }; + } wl_list_remove(&output->link); free(output); };
src/layer_shell.c Modified
@@ -8,14 +8,16 @@ struct wlr_layer_surface_v1 *surface; struct wlr_layer_surface_v1_state *state; - if (wl_list_empty(&output->layer_views)) { - return; - } - - wl_list_for_each(lview, &output->layer_views, link) { - surface = lview->surface; - state = &surface->current; - wlr_layer_surface_v1_configure(surface, state->desired_width, state->desired_height); + for (int i = 0; i<4; i++) { + if (wl_list_empty(&output->layer_views[i])) { + continue; + } + + wl_list_for_each(lview, &output->layer_views[i], link) { + surface = lview->surface; + state = &surface->current; + wlr_layer_surface_v1_configure(surface, state->desired_width, state->desired_height); + } } } @@ -61,7 +63,7 @@ wl_signal_add(&surface->events.map, &lview->map_listener); wl_signal_add(&surface->events.unmap, &lview->unmap_listener); wl_signal_add(&surface->events.destroy, &lview->destroy_listener); - + if (!surface->output) { surface->output = wlr_output_layout_output_at( wimp.output_layout, wimp.cursor->x, wimp.cursor->y @@ -69,7 +71,7 @@ } struct output *output = surface->output->data; lview->output = output; - wl_list_insert(&output->layer_views, &lview->link); + wl_list_insert(&output->layer_views[surface->client_pending.layer], &lview->link); layer(lview->output); }