output-layers: change semantics of wlr_output_state.layers

Previously, we were requiring all layers to be included in
wlr_output_state.layers and wlr_output_layer_state.buffer to be
set to NULL to disable a layer.

This commit changes these semantics: disabled layers are left out
of wlr_output_state.layers, and wlr_output_layer_state.buffer is
required to be non-NULL.

This new API should make it easier for callers to populate the
layers, at the cost of some additional complexity in backends,
mostly addressed by introducing a new
wlr_output_state_is_layer_enabled() helper.
This commit is contained in:
Simon Ser 2023-06-12 17:15:16 +02:00
parent f42920c414
commit b931ac9ac0
8 changed files with 120 additions and 71 deletions

View file

@ -67,6 +67,10 @@ static void output_handle_frame(struct wl_listener *listener, void *data) {
struct wl_array layers_arr = {0};
struct output_surface *output_surface;
wl_list_for_each(output_surface, &output->surfaces, link) {
if (output_surface->buffer == NULL) {
continue;
}
struct wlr_output_layer_state *layer_state =
wl_array_add(&layers_arr, sizeof(*layer_state));
*layer_state = (struct wlr_output_layer_state){
@ -103,6 +107,10 @@ static void output_handle_frame(struct wl_listener *listener, void *data) {
size_t i = 0;
struct wlr_output_layer_state *layers = layers_arr.data;
wl_list_for_each(output_surface, &output->surfaces, link) {
if (output_surface->buffer == NULL) {
continue;
}
struct wlr_surface *wlr_surface = output_surface->wlr_surface;
output_surface->layer_accepted = layers[i].accepted;