From 4157715e263d7728f235b801e9d192d08a70a864 Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Mon, 27 Feb 2023 10:46:25 +0100 Subject: [PATCH] output: add output_state_get_cursor_layer() helper --- include/types/wlr_output.h | 3 +++ types/output/state.c | 17 +++++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/include/types/wlr_output.h b/include/types/wlr_output.h index 22a5c4639..253f116a4 100644 --- a/include/types/wlr_output.h +++ b/include/types/wlr_output.h @@ -18,4 +18,7 @@ bool output_cursor_set_texture(struct wlr_output_cursor *cursor, struct wlr_texture *texture, bool own_texture, float scale, enum wl_output_transform transform, int32_t hotspot_x, int32_t hotspot_y); +struct wlr_output_layer_state *output_state_get_cursor_layer( + const struct wlr_output_state *state); + #endif diff --git a/types/output/state.c b/types/output/state.c index 41610f035..a5e00cc75 100644 --- a/types/output/state.c +++ b/types/output/state.c @@ -1,6 +1,7 @@ #include #include #include +#include #include "types/wlr_output.h" void wlr_output_state_init(struct wlr_output_state *state) { @@ -150,3 +151,19 @@ err: wlr_output_state_finish(©); return false; } + +struct wlr_output_layer_state *output_state_get_cursor_layer( + const struct wlr_output_state *state) { + if (!(state->committed & WLR_OUTPUT_STATE_LAYERS)) { + return NULL; + } + if (state->layers_len == 0) { + return NULL; + } + + struct wlr_output_layer_state *layer_state = &state->layers[state->layers_len - 1]; + if (!layer_state->layer->cursor) { + return NULL; + } + return layer_state; +}