output-layer: require all layers in wlr_output_state.layers

- Simplifies the backends
- Avoids having two ways to do the same thing: previously one could
  disable a layer by either omitting it from wlr_output_state.layers,
  or by passing a NULL buffer
- We can change our mind in the future: we can allow users to omit
  some layers and define a meaning without breaking the API.

References: https://gitlab.freedesktop.org/wlroots/wlroots/-/merge_requests/4017#note_1783997
Simon Ser 2 years ago committed by Alexander Orzechowski
parent 87969c1c7c
commit 1b6fac4aa6

@ -399,31 +399,6 @@ static bool commit_layers(struct wlr_wl_output *output,
} }
} }
// Unmap any layer we haven't seen
struct wlr_output_layer *wlr_layer;
wl_list_for_each(wlr_layer, &output->wlr_output.layers, link) {
bool found = false;
for (size_t i = 0; i < layers_len; i++) {
if (layers[i].layer == wlr_layer) {
found = true;
break;
}
}
if (found) {
continue;
}
struct wlr_wl_output_layer *layer =
get_or_create_output_layer(output, wlr_layer);
if (layer == NULL) {
continue;
}
// TODO: only do this once
wl_surface_attach(layer->surface, NULL, 0, 0);
wl_surface_commit(layer->surface);
}
return true; return true;
} }

@ -36,6 +36,8 @@
* Callers are responsible for disabling output layers when they need the full * Callers are responsible for disabling output layers when they need the full
* output contents to be composited onto a single buffer, e.g. during screen * output contents to be composited onto a single buffer, e.g. during screen
* capture. * capture.
*
* Callers must always include the state for all layers on output test/commit.
*/ */
struct wlr_output_layer { struct wlr_output_layer {
struct wl_list link; // wlr_output.layers struct wl_list link; // wlr_output.layers

@ -673,6 +673,11 @@ static bool output_basic_test(struct wlr_output *output,
} }
if (state->committed & WLR_OUTPUT_STATE_LAYERS) { if (state->committed & WLR_OUTPUT_STATE_LAYERS) {
if (state->layers_len != (size_t)wl_list_length(&output->layers)) {
wlr_log(WLR_DEBUG, "All output layers must be specified in wlr_output_state.layers");
return false;
}
for (size_t i = 0; i < state->layers_len; i++) { for (size_t i = 0; i < state->layers_len; i++) {
state->layers[i].accepted = false; state->layers[i].accepted = false;
} }

Loading…
Cancel
Save