aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Ser <contact@emersion.fr>2023-06-13 10:44:26 +0200
committerAlexander Orzechowski <alex@ozal.ski>2023-06-13 12:02:49 +0000
commit670915eeeaa2faee95cb3c32c64199da4379adf8 (patch)
treea7e66fee3447da091489c49ddb08fda8c488b356
parent73ca1ea48a208a1ef9b21ffe9f721a4289deb15c (diff)
output: add wlr_output_state_set_layers()
-rw-r--r--examples/output-layers.c8
-rw-r--r--include/wlr/types/wlr_output.h7
-rw-r--r--types/output/output.c4
-rw-r--r--types/output/state.c7
4 files changed, 18 insertions, 8 deletions
diff --git a/examples/output-layers.c b/examples/output-layers.c
index 973633d4..e6ec8150 100644
--- a/examples/output-layers.c
+++ b/examples/output-layers.c
@@ -82,11 +82,9 @@ static void output_handle_frame(struct wl_listener *listener, void *data) {
};
}
- struct wlr_output_state output_state = {
- .committed = WLR_OUTPUT_STATE_LAYERS,
- .layers = layers_arr.data,
- .layers_len = layers_arr.size / sizeof(struct wlr_output_layer_state),
- };
+ struct wlr_output_state output_state = {0};
+ wlr_output_state_set_layers(&output_state, layers_arr.data,
+ layers_arr.size / sizeof(struct wlr_output_layer_state));
if (!wlr_output_test_state(output->wlr_output, &output_state)) {
wlr_log(WLR_ERROR, "wlr_output_test() failed");
diff --git a/include/wlr/types/wlr_output.h b/include/wlr/types/wlr_output.h
index 3ca8863a..a38a431a 100644
--- a/include/wlr/types/wlr_output.h
+++ b/include/wlr/types/wlr_output.h
@@ -580,6 +580,13 @@ bool wlr_output_state_set_gamma_lut(struct wlr_output_state *state,
*/
void wlr_output_state_set_damage(struct wlr_output_state *state,
const pixman_region32_t *damage);
+/**
+ * Set the state's layers.
+ *
+ * The array must be kept valid by the caller until wlr_output_state_finish().
+ */
+void wlr_output_state_set_layers(struct wlr_output_state *state,
+ struct wlr_output_layer_state *layers, size_t layers_len);
/**
diff --git a/types/output/output.c b/types/output/output.c
index 76ee54e6..6b332e1c 100644
--- a/types/output/output.c
+++ b/types/output/output.c
@@ -478,9 +478,7 @@ void wlr_output_set_damage(struct wlr_output *output,
void wlr_output_set_layers(struct wlr_output *output,
struct wlr_output_layer_state *layers, size_t layers_len) {
- output->pending.committed |= WLR_OUTPUT_STATE_LAYERS;
- output->pending.layers = layers;
- output->pending.layers_len = layers_len;
+ wlr_output_state_set_layers(&output->pending, layers, layers_len);
}
static void output_state_clear_gamma_lut(struct wlr_output_state *state) {
diff --git a/types/output/state.c b/types/output/state.c
index 761c419a..9c96fc8e 100644
--- a/types/output/state.c
+++ b/types/output/state.c
@@ -120,3 +120,10 @@ bool wlr_output_state_set_gamma_lut(struct wlr_output_state *state,
state->gamma_lut = gamma_lut;
return true;
}
+
+void wlr_output_state_set_layers(struct wlr_output_state *state,
+ struct wlr_output_layer_state *layers, size_t layers_len) {
+ state->committed |= WLR_OUTPUT_STATE_LAYERS;
+ state->layers = layers;
+ state->layers_len = layers_len;
+}