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.
Simon Ser 3 years ago committed by Isaac Freund
parent e3e2a34cd8
commit 459a642e83

@ -498,6 +498,8 @@ bool wlr_output_cursor_set_image(struct wlr_output_cursor *cursor,
int32_t hotspot_x, int32_t hotspot_y); int32_t hotspot_x, int32_t hotspot_y);
void wlr_output_cursor_set_surface(struct wlr_output_cursor *cursor, void wlr_output_cursor_set_surface(struct wlr_output_cursor *cursor,
struct wlr_surface *surface, int32_t hotspot_x, int32_t hotspot_y); 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, bool wlr_output_cursor_move(struct wlr_output_cursor *cursor,
double x, double y); double x, double y);
void wlr_output_cursor_destroy(struct wlr_output_cursor *cursor); void wlr_output_cursor_destroy(struct wlr_output_cursor *cursor);

@ -411,6 +411,50 @@ bool wlr_output_cursor_set_image(struct wlr_output_cursor *cursor,
return true; 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, static void output_cursor_commit(struct wlr_output_cursor *cursor,
bool update_hotspot) { bool update_hotspot) {
if (cursor->output->hardware_cursor != cursor) { if (cursor->output->hardware_cursor != cursor) {

Loading…
Cancel
Save