aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRouven Czerwinski <rouven@czerwinskis.de>2022-06-20 08:36:40 +0200
committerRouven Czerwinski <rouven@czerwinskis.de>2022-06-20 10:20:55 +0200
commit2a1d7d40f4987bda17637796ce2aeae67370b1e3 (patch)
treec7bb1a2017e35f91a78792af9d91aa3625020225
parent1d581656c756fd17a6cf55474d32586f6769663f (diff)
cursor: re-enable NULL buffer for cursor
The previous wlr_output_cursor_set_image() allows setting a NULL buffer for the cursor to hide it. This functionality was used by sway to hide the cursor, restore the original semantics by allowing NULL buffers again by avoiding the wlr_buffer allocation in case we have NULL pixels and handing a NULL wlr_buffer to wlr_output_cursor_set_buffer().
-rw-r--r--types/output/cursor.c20
1 files changed, 12 insertions, 8 deletions
diff --git a/types/output/cursor.c b/types/output/cursor.c
index bd6f757e..85973ce9 100644
--- a/types/output/cursor.c
+++ b/types/output/cursor.c
@@ -376,15 +376,19 @@ static bool output_cursor_attempt_hardware(struct wlr_output_cursor *cursor) {
bool wlr_output_cursor_set_image(struct wlr_output_cursor *cursor,
const uint8_t *pixels, int32_t stride, uint32_t width, uint32_t height,
int32_t hotspot_x, int32_t hotspot_y) {
- struct wlr_readonly_data_buffer *buffer =
- readonly_data_buffer_create(DRM_FORMAT_ARGB8888, stride, width, height,
- pixels);
- if (buffer == NULL) {
- return false;
+ struct wlr_buffer *buffer = NULL;
+
+ if (pixels) {
+ struct wlr_readonly_data_buffer *ro_buffer = readonly_data_buffer_create(
+ DRM_FORMAT_ARGB8888, stride, width, height, pixels);
+ if (ro_buffer == NULL) {
+ return false;
+ }
+ buffer = &ro_buffer->base;
}
- bool ok = wlr_output_cursor_set_buffer(cursor, &buffer->base,
- hotspot_x, hotspot_y);
- wlr_buffer_drop(&buffer->base);
+ bool ok = wlr_output_cursor_set_buffer(cursor, buffer, hotspot_x, hotspot_y);
+
+ wlr_buffer_drop(buffer);
return ok;
}