output: add output_state_get_cursor_layer() helper

This commit is contained in:
Simon Ser 2023-02-27 10:46:25 +01:00
parent a863b82bdb
commit 4157715e26
2 changed files with 20 additions and 0 deletions

View file

@ -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

View file

@ -1,6 +1,7 @@
#include <stdlib.h>
#include <string.h>
#include <wlr/util/log.h>
#include <wlr/types/wlr_output_layer.h>
#include "types/wlr_output.h"
void wlr_output_state_init(struct wlr_output_state *state) {
@ -150,3 +151,19 @@ err:
wlr_output_state_finish(&copy);
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;
}