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

@ -13,6 +13,8 @@
#include <wlr/backend.h>
#include <wlr/types/wlr_output.h>
struct wlr_output_layer;
/**
* Output state fields that don't require backend support. Backends can ignore
* them without breaking the API contract.
@ -136,4 +138,12 @@ void wlr_output_send_present(struct wlr_output *output,
void wlr_output_send_request_state(struct wlr_output *output,
const struct wlr_output_state *state);
/**
* Check whether a layer is enabled in an output state.
*
* The output state must have the layers field populated.
*/
bool wlr_output_state_is_layer_enabled(const struct wlr_output_state *state,
struct wlr_output_layer *layer);
#endif

View file

@ -38,7 +38,8 @@
* output contents to be composited onto a single buffer, e.g. during screen
* capture.
*
* Callers must always include the state for all layers on output test/commit.
* To disable an output layer, callers can leave it out of the array supplied
* on output test/commit.
*/
struct wlr_output_layer {
struct wl_list link; // wlr_output.layers
@ -62,7 +63,7 @@ struct wlr_output_layer {
struct wlr_output_layer_state {
struct wlr_output_layer *layer;
// Buffer to display, or NULL to disable the layer
// Buffer to display, must not be NULL
struct wlr_buffer *buffer;
// Source box, leave empty to use the whole buffer
struct wlr_fbox src_box;