Merge pull request #257 from emersion/fix-client-cursors

[WIP] Fix client cursors
This commit is contained in:
Drew DeVault 2017-10-17 09:22:43 -04:00 committed by GitHub
commit 62371a9974
7 changed files with 82 additions and 31 deletions

View file

@ -54,13 +54,24 @@ static void wlr_wl_output_transform(struct wlr_output *_output,
static bool wlr_wl_output_set_cursor(struct wlr_output *_output,
const uint8_t *buf, 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, bool update_pixels) {
struct wlr_wl_backend_output *output = (struct wlr_wl_backend_output *)_output;
struct wlr_wl_backend *backend = output->backend;
if (!update_pixels) {
// Update hotspot without changing cursor image
wlr_wl_output_update_cursor(output, output->enter_serial, hotspot_x,
hotspot_y);
return true;
}
if (!buf) {
wl_pointer_set_cursor(output->backend->pointer, output->enter_serial,
NULL, 0, 0);
// Hide cursor
wl_surface_destroy(output->cursor_surface);
munmap(output->cursor_data, output->cursor_buf_size);
output->cursor_surface = NULL;
output->cursor_buf_size = 0;
wlr_wl_output_update_cursor(output, output->enter_serial, hotspot_x,
hotspot_y);
return true;
}
@ -153,7 +164,7 @@ static void wlr_wl_output_destroy(struct wlr_output *_output) {
void wlr_wl_output_update_cursor(struct wlr_wl_backend_output *output,
uint32_t serial, int32_t hotspot_x, int32_t hotspot_y) {
if (output->cursor_surface && output->backend->pointer && serial) {
if (output->backend->pointer && serial) {
wl_pointer_set_cursor(output->backend->pointer, serial,
output->cursor_surface, hotspot_x, hotspot_y);
}