mirror of
https://github.com/hyprwm/wlroots-hyprland.git
synced 2024-11-22 21:05:58 +01:00
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().
This commit is contained in:
parent
1d581656c7
commit
2a1d7d40f4
1 changed files with 12 additions and 8 deletions
|
@ -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,
|
bool wlr_output_cursor_set_image(struct wlr_output_cursor *cursor,
|
||||||
const uint8_t *pixels, int32_t stride, uint32_t width, uint32_t height,
|
const uint8_t *pixels, int32_t stride, uint32_t width, uint32_t height,
|
||||||
int32_t hotspot_x, int32_t hotspot_y) {
|
int32_t hotspot_x, int32_t hotspot_y) {
|
||||||
struct wlr_readonly_data_buffer *buffer =
|
struct wlr_buffer *buffer = NULL;
|
||||||
readonly_data_buffer_create(DRM_FORMAT_ARGB8888, stride, width, height,
|
|
||||||
pixels);
|
if (pixels) {
|
||||||
if (buffer == NULL) {
|
struct wlr_readonly_data_buffer *ro_buffer = readonly_data_buffer_create(
|
||||||
|
DRM_FORMAT_ARGB8888, stride, width, height, pixels);
|
||||||
|
if (ro_buffer == NULL) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
bool ok = wlr_output_cursor_set_buffer(cursor, &buffer->base,
|
buffer = &ro_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;
|
return ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue