|
|
@ -245,6 +245,9 @@ static void handle_display_destroy(struct wl_listener *listener, void *data) {
|
|
|
|
void wlr_output_init(struct wlr_output *output, struct wlr_backend *backend,
|
|
|
|
void wlr_output_init(struct wlr_output *output, struct wlr_backend *backend,
|
|
|
|
const struct wlr_output_impl *impl, struct wl_display *display) {
|
|
|
|
const struct wlr_output_impl *impl, struct wl_display *display) {
|
|
|
|
assert(impl->make_current && impl->swap_buffers && impl->transform);
|
|
|
|
assert(impl->make_current && impl->swap_buffers && impl->transform);
|
|
|
|
|
|
|
|
if (impl->set_cursor || impl->move_cursor) {
|
|
|
|
|
|
|
|
assert(impl->set_cursor && impl->move_cursor);
|
|
|
|
|
|
|
|
}
|
|
|
|
output->backend = backend;
|
|
|
|
output->backend = backend;
|
|
|
|
output->impl = impl;
|
|
|
|
output->impl = impl;
|
|
|
|
output->display = display;
|
|
|
|
output->display = display;
|
|
|
@ -691,6 +694,28 @@ static void output_cursor_update_visible(struct wlr_output_cursor *cursor) {
|
|
|
|
cursor->visible = visible;
|
|
|
|
cursor->visible = visible;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static bool output_cursor_attempt_hardware(struct wlr_output_cursor *cursor) {
|
|
|
|
|
|
|
|
struct wlr_texture *texture = cursor->texture;
|
|
|
|
|
|
|
|
if (cursor->surface != NULL) {
|
|
|
|
|
|
|
|
texture = cursor->surface->texture;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
struct wlr_output_cursor *hwcur = cursor->output->hardware_cursor;
|
|
|
|
|
|
|
|
if (cursor->output->impl->set_cursor && (hwcur == NULL || hwcur == cursor)) {
|
|
|
|
|
|
|
|
if (hwcur != cursor) {
|
|
|
|
|
|
|
|
assert(cursor->output->impl->move_cursor);
|
|
|
|
|
|
|
|
cursor->output->impl->move_cursor(cursor->output,
|
|
|
|
|
|
|
|
(int)cursor->x, (int)cursor->y);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (cursor->output->impl->set_cursor(cursor->output, texture,
|
|
|
|
|
|
|
|
cursor->hotspot_x, cursor->hotspot_y, true)) {
|
|
|
|
|
|
|
|
cursor->output->hardware_cursor = cursor;
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
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) {
|
|
|
@ -706,33 +731,26 @@ bool wlr_output_cursor_set_image(struct wlr_output_cursor *cursor,
|
|
|
|
cursor->hotspot_y = hotspot_y;
|
|
|
|
cursor->hotspot_y = hotspot_y;
|
|
|
|
output_cursor_update_visible(cursor);
|
|
|
|
output_cursor_update_visible(cursor);
|
|
|
|
|
|
|
|
|
|
|
|
struct wlr_output_cursor *hwcur = cursor->output->hardware_cursor;
|
|
|
|
wlr_texture_destroy(cursor->texture);
|
|
|
|
if (cursor->output->impl->set_cursor && (hwcur == NULL || hwcur == cursor)) {
|
|
|
|
cursor->texture = NULL;
|
|
|
|
if (cursor->output->impl->move_cursor && hwcur != cursor) {
|
|
|
|
|
|
|
|
cursor->output->impl->move_cursor(cursor->output,
|
|
|
|
cursor->enabled = false;
|
|
|
|
(int)cursor->x, (int)cursor->y);
|
|
|
|
if (pixels != NULL) {
|
|
|
|
}
|
|
|
|
cursor->texture = wlr_texture_from_pixels(renderer,
|
|
|
|
int ok = cursor->output->impl->set_cursor(cursor->output, pixels,
|
|
|
|
WL_SHM_FORMAT_ARGB8888, stride, width, height, pixels);
|
|
|
|
stride, width, height, hotspot_x, hotspot_y, true);
|
|
|
|
if (cursor->texture == NULL) {
|
|
|
|
if (ok) {
|
|
|
|
return false;
|
|
|
|
cursor->output->hardware_cursor = cursor;
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
cursor->enabled = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
wlr_log(L_DEBUG, "Falling back to software cursor");
|
|
|
|
if (output_cursor_attempt_hardware(cursor)) {
|
|
|
|
output_cursor_damage_whole(cursor);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
cursor->enabled = pixels != NULL;
|
|
|
|
|
|
|
|
if (!cursor->enabled) {
|
|
|
|
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
wlr_texture_destroy(cursor->texture);
|
|
|
|
wlr_log(L_DEBUG, "Falling back to software cursor");
|
|
|
|
|
|
|
|
output_cursor_damage_whole(cursor);
|
|
|
|
cursor->texture = wlr_texture_from_pixels(renderer, WL_SHM_FORMAT_ARGB8888,
|
|
|
|
return true;
|
|
|
|
stride, width, height, pixels);
|
|
|
|
|
|
|
|
return cursor->texture != NULL;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void output_cursor_commit(struct wlr_output_cursor *cursor) {
|
|
|
|
static void output_cursor_commit(struct wlr_output_cursor *cursor) {
|
|
|
@ -745,15 +763,15 @@ static void output_cursor_commit(struct wlr_output_cursor *cursor) {
|
|
|
|
cursor->width = cursor->surface->current->width * cursor->output->scale;
|
|
|
|
cursor->width = cursor->surface->current->width * cursor->output->scale;
|
|
|
|
cursor->height = cursor->surface->current->height * cursor->output->scale;
|
|
|
|
cursor->height = cursor->surface->current->height * cursor->output->scale;
|
|
|
|
|
|
|
|
|
|
|
|
if (cursor->output->hardware_cursor != cursor) {
|
|
|
|
if (output_cursor_attempt_hardware(cursor)) {
|
|
|
|
output_cursor_damage_whole(cursor);
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
// TODO: upload pixels
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
struct timespec now;
|
|
|
|
struct timespec now;
|
|
|
|
clock_gettime(CLOCK_MONOTONIC, &now);
|
|
|
|
clock_gettime(CLOCK_MONOTONIC, &now);
|
|
|
|
wlr_surface_send_frame_done(cursor->surface, &now);
|
|
|
|
wlr_surface_send_frame_done(cursor->surface, &now);
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Fallback to software cursor
|
|
|
|
|
|
|
|
output_cursor_damage_whole(cursor);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void output_cursor_handle_commit(struct wl_listener *listener,
|
|
|
|
static void output_cursor_handle_commit(struct wl_listener *listener,
|
|
|
@ -789,11 +807,9 @@ void wlr_output_cursor_set_surface(struct wlr_output_cursor *cursor,
|
|
|
|
cursor->hotspot_y = hotspot_y;
|
|
|
|
cursor->hotspot_y = hotspot_y;
|
|
|
|
if (cursor->output->hardware_cursor != cursor) {
|
|
|
|
if (cursor->output->hardware_cursor != cursor) {
|
|
|
|
output_cursor_damage_whole(cursor);
|
|
|
|
output_cursor_damage_whole(cursor);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
|
|
|
|
assert(cursor->output->impl->set_cursor);
|
|
|
|
if (cursor->output->hardware_cursor == cursor &&
|
|
|
|
cursor->output->impl->set_cursor(cursor->output, NULL,
|
|
|
|
cursor->output->impl->set_cursor) {
|
|
|
|
|
|
|
|
cursor->output->impl->set_cursor(cursor->output, NULL, 0, 0, 0,
|
|
|
|
|
|
|
|
hotspot_x, hotspot_y, false);
|
|
|
|
hotspot_x, hotspot_y, false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
return;
|
|
|
@ -801,15 +817,6 @@ void wlr_output_cursor_set_surface(struct wlr_output_cursor *cursor,
|
|
|
|
|
|
|
|
|
|
|
|
output_cursor_reset(cursor);
|
|
|
|
output_cursor_reset(cursor);
|
|
|
|
|
|
|
|
|
|
|
|
// Disable hardware cursor for surfaces
|
|
|
|
|
|
|
|
// TODO: support hardware cursors
|
|
|
|
|
|
|
|
if (cursor->output->hardware_cursor == cursor &&
|
|
|
|
|
|
|
|
cursor->output->impl->set_cursor) {
|
|
|
|
|
|
|
|
cursor->output->impl->set_cursor(cursor->output, NULL, 0, 0, 0, 0, 0,
|
|
|
|
|
|
|
|
true);
|
|
|
|
|
|
|
|
cursor->output->hardware_cursor = NULL;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
cursor->surface = surface;
|
|
|
|
cursor->surface = surface;
|
|
|
|
cursor->hotspot_x = hotspot_x;
|
|
|
|
cursor->hotspot_x = hotspot_x;
|
|
|
|
cursor->hotspot_y = hotspot_y;
|
|
|
|
cursor->hotspot_y = hotspot_y;
|
|
|
@ -826,7 +833,10 @@ void wlr_output_cursor_set_surface(struct wlr_output_cursor *cursor,
|
|
|
|
cursor->width = 0;
|
|
|
|
cursor->width = 0;
|
|
|
|
cursor->height = 0;
|
|
|
|
cursor->height = 0;
|
|
|
|
|
|
|
|
|
|
|
|
// TODO: if hardware cursor, disable cursor
|
|
|
|
if (cursor->output->hardware_cursor == cursor) {
|
|
|
|
|
|
|
|
assert(cursor->output->impl->set_cursor);
|
|
|
|
|
|
|
|
cursor->output->impl->set_cursor(cursor->output, NULL, 0, 0, true);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -857,9 +867,7 @@ bool wlr_output_cursor_move(struct wlr_output_cursor *cursor,
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!cursor->output->impl->move_cursor) {
|
|
|
|
assert(cursor->output->impl->move_cursor);
|
|
|
|
return false;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return cursor->output->impl->move_cursor(cursor->output, (int)x, (int)y);
|
|
|
|
return cursor->output->impl->move_cursor(cursor->output, (int)x, (int)y);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -889,8 +897,7 @@ void wlr_output_cursor_destroy(struct wlr_output_cursor *cursor) {
|
|
|
|
if (cursor->output->hardware_cursor == cursor) {
|
|
|
|
if (cursor->output->hardware_cursor == cursor) {
|
|
|
|
// If this cursor was the hardware cursor, disable it
|
|
|
|
// If this cursor was the hardware cursor, disable it
|
|
|
|
if (cursor->output->impl->set_cursor) {
|
|
|
|
if (cursor->output->impl->set_cursor) {
|
|
|
|
cursor->output->impl->set_cursor(cursor->output, NULL, 0, 0, 0, 0,
|
|
|
|
cursor->output->impl->set_cursor(cursor->output, NULL, 0, 0, true);
|
|
|
|
0, true);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
cursor->output->hardware_cursor = NULL;
|
|
|
|
cursor->output->hardware_cursor = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|