output: introduce wlr_output_cursor_set_buffer

This will supersede wlr_output_cursor_set_image, and then later
also supersede wlr_output_cursor_set_surface.
This commit is contained in:
Simon Ser 2022-05-27 18:28:55 +02:00 committed by Isaac Freund
parent e3e2a34cd8
commit 459a642e83
2 changed files with 46 additions and 0 deletions

View File

@ -498,6 +498,8 @@ bool wlr_output_cursor_set_image(struct wlr_output_cursor *cursor,
int32_t hotspot_x, int32_t hotspot_y);
void wlr_output_cursor_set_surface(struct wlr_output_cursor *cursor,
struct wlr_surface *surface, int32_t hotspot_x, int32_t hotspot_y);
bool wlr_output_cursor_set_buffer(struct wlr_output_cursor *cursor,
struct wlr_buffer *buffer, int32_t hotspot_x, int32_t hotspot_y);
bool wlr_output_cursor_move(struct wlr_output_cursor *cursor,
double x, double y);
void wlr_output_cursor_destroy(struct wlr_output_cursor *cursor);

View File

@ -411,6 +411,50 @@ bool wlr_output_cursor_set_image(struct wlr_output_cursor *cursor,
return true;
}
bool wlr_output_cursor_set_buffer(struct wlr_output_cursor *cursor,
struct wlr_buffer *buffer, int32_t hotspot_x, int32_t hotspot_y) {
struct wlr_renderer *renderer = cursor->output->renderer;
if (!renderer) {
return false;
}
output_cursor_reset(cursor);
if (buffer != NULL) {
cursor->width = buffer->width;
cursor->height = buffer->height;
} else {
cursor->width = 0;
cursor->height = 0;
}
cursor->hotspot_x = hotspot_x;
cursor->hotspot_y = hotspot_y;
output_cursor_update_visible(cursor);
wlr_texture_destroy(cursor->texture);
cursor->texture = NULL;
cursor->enabled = false;
if (buffer != NULL) {
cursor->texture = wlr_texture_from_buffer(renderer, buffer);
if (cursor->texture == NULL) {
return false;
}
cursor->enabled = true;
}
if (output_cursor_attempt_hardware(cursor)) {
return true;
}
wlr_log(WLR_DEBUG, "Falling back to software cursor on output '%s'",
cursor->output->name);
output_cursor_damage_whole(cursor);
return true;
}
static void output_cursor_commit(struct wlr_output_cursor *cursor,
bool update_hotspot) {
if (cursor->output->hardware_cursor != cursor) {