mirror of
https://github.com/hyprwm/wlroots-hyprland.git
synced 2024-12-23 18:39:48 +01:00
Read surface buffer to set output cursor
This commit is contained in:
parent
9b83caa658
commit
17354b630a
1 changed files with 15 additions and 15 deletions
|
@ -172,24 +172,24 @@ bool wlr_output_set_cursor(struct wlr_output *output,
|
||||||
|
|
||||||
bool wlr_output_set_cursor_surface(struct wlr_output *output,
|
bool wlr_output_set_cursor_surface(struct wlr_output *output,
|
||||||
struct wlr_surface *surface, int32_t hotspot_x, int32_t hotspot_y) {
|
struct wlr_surface *surface, int32_t hotspot_x, int32_t hotspot_y) {
|
||||||
if (output->impl->set_cursor) {
|
struct wl_shm_buffer *buffer = wl_shm_buffer_get(surface->current->buffer);
|
||||||
output->impl->set_cursor(output, NULL, 0, 0, 0, 0, 0);
|
if (buffer == NULL) {
|
||||||
wlr_log(L_INFO, "TODO: wlr_output_set_cursor_surface for hw cursors");
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
output->cursor.is_sw = true;
|
uint32_t format = wl_shm_buffer_get_format(buffer);
|
||||||
output->cursor.width = surface->current->width;
|
if (format != WL_SHM_FORMAT_ARGB8888) {
|
||||||
output->cursor.height = surface->current->height;
|
return false;
|
||||||
output->cursor.hotspot_x = hotspot_x;
|
}
|
||||||
output->cursor.hotspot_y = hotspot_y;
|
|
||||||
|
|
||||||
wlr_texture_destroy(output->cursor.texture);
|
void *data = wl_shm_buffer_get_data(buffer);
|
||||||
output->cursor.texture = surface->texture;
|
int32_t width = wl_shm_buffer_get_width(buffer);
|
||||||
|
int32_t height = wl_shm_buffer_get_height(buffer);
|
||||||
wlr_renderer_destroy(output->cursor.renderer);
|
wl_shm_buffer_begin_access(buffer);
|
||||||
output->cursor.renderer = surface->renderer;
|
bool ok = wlr_output_set_cursor(output, data, width, width, height,
|
||||||
|
hotspot_x, hotspot_y);
|
||||||
return true;
|
wl_shm_buffer_end_access(buffer);
|
||||||
|
return ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wlr_output_move_cursor(struct wlr_output *output, int x, int y) {
|
bool wlr_output_move_cursor(struct wlr_output *output, int x, int y) {
|
||||||
|
|
Loading…
Reference in a new issue