mirror of
https://gitlab.freedesktop.org/wlroots/wlroots.git
synced 2026-04-19 06:47:02 -04:00
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:
parent
f42920c414
commit
b931ac9ac0
8 changed files with 120 additions and 71 deletions
|
|
@ -664,13 +664,14 @@ static bool output_basic_test(struct wlr_output *output,
|
|||
}
|
||||
|
||||
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++) {
|
||||
assert(state->layers[i].layer != NULL);
|
||||
|
||||
if (state->layers[i].buffer == NULL) {
|
||||
wlr_log(WLR_DEBUG, "All output layer states must have a buffer");
|
||||
return false;
|
||||
}
|
||||
|
||||
state->layers[i].accepted = false;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
#include <assert.h>
|
||||
#include <stdlib.h>
|
||||
#include <wlr/interfaces/wlr_output.h>
|
||||
#include <wlr/types/wlr_output_layer.h>
|
||||
#include <wlr/util/log.h>
|
||||
|
||||
struct wlr_output_layer *wlr_output_layer_create(struct wlr_output *output) {
|
||||
struct wlr_output_layer *layer = calloc(1, sizeof(*layer));
|
||||
|
|
@ -28,3 +30,16 @@ void wlr_output_layer_destroy(struct wlr_output_layer *layer) {
|
|||
wl_list_remove(&layer->link);
|
||||
free(layer);
|
||||
}
|
||||
|
||||
bool wlr_output_state_is_layer_enabled(const struct wlr_output_state *state,
|
||||
struct wlr_output_layer *layer) {
|
||||
assert(state->committed & WLR_OUTPUT_STATE_LAYERS);
|
||||
|
||||
for (size_t i = 0; i < state->layers_len; i++) {
|
||||
if (state->layers[i].layer == layer) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue