From 92daa790bb4ac1b15eedd91e02ab65b340e8f2a5 Mon Sep 17 00:00:00 2001 From: emersion Date: Thu, 12 Oct 2017 09:40:51 +0200 Subject: Allow to update the cursor hotspot without its pixels --- backend/drm/drm.c | 10 ++++++++-- backend/wayland/output.c | 9 ++++++++- 2 files changed, 16 insertions(+), 3 deletions(-) (limited to 'backend') diff --git a/backend/drm/drm.c b/backend/drm/drm.c index 9e5346a1..ff4dc7f6 100644 --- a/backend/drm/drm.c +++ b/backend/drm/drm.c @@ -470,7 +470,7 @@ static void wlr_drm_connector_transform(struct wlr_output *output, static bool wlr_drm_connector_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_drm_connector *conn = (struct wlr_drm_connector *)output; struct wlr_drm_backend *drm = conn->drm; struct wlr_drm_renderer *renderer = &drm->renderer; @@ -478,7 +478,8 @@ static bool wlr_drm_connector_set_cursor(struct wlr_output *output, struct wlr_drm_crtc *crtc = conn->crtc; struct wlr_drm_plane *plane = crtc->cursor; - if (!buf) { + if (!buf && update_pixels) { + // Hide the cursor return drm->iface->crtc_set_cursor(drm, crtc, NULL); } @@ -566,6 +567,11 @@ static bool wlr_drm_connector_set_cursor(struct wlr_output *output, break; } + if (!update_pixels) { + // Only update the cursor hotspot + return true; + } + struct gbm_bo *bo = plane->cursor_bo; uint32_t bo_width = gbm_bo_get_width(bo); uint32_t bo_height = gbm_bo_get_height(bo); diff --git a/backend/wayland/output.c b/backend/wayland/output.c index 03b43b35..2616b347 100644 --- a/backend/wayland/output.c +++ b/backend/wayland/output.c @@ -54,11 +54,18 @@ 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) { + // Hide cursor wl_pointer_set_cursor(output->backend->pointer, output->enter_serial, NULL, 0, 0); return true; -- cgit v1.2.3 From 19860c03f7567bd85ffd735ce2ccc90c454dd5b1 Mon Sep 17 00:00:00 2001 From: emersion Date: Thu, 12 Oct 2017 13:25:29 +0200 Subject: Better handling of hidden cursors in wayland backend, add TODOs --- backend/wayland/output.c | 10 +++++++--- types/wlr_output.c | 4 +++- types/wlr_surface.c | 3 ++- 3 files changed, 12 insertions(+), 5 deletions(-) (limited to 'backend') diff --git a/backend/wayland/output.c b/backend/wayland/output.c index 2616b347..d308b907 100644 --- a/backend/wayland/output.c +++ b/backend/wayland/output.c @@ -66,8 +66,12 @@ static bool wlr_wl_output_set_cursor(struct wlr_output *_output, } if (!buf) { // Hide cursor - wl_pointer_set_cursor(output->backend->pointer, output->enter_serial, - NULL, 0, 0); + 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; } @@ -160,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); } diff --git a/types/wlr_output.c b/types/wlr_output.c index 568ea093..b416f9de 100644 --- a/types/wlr_output.c +++ b/types/wlr_output.c @@ -259,7 +259,9 @@ void wlr_output_set_cursor_surface(struct wlr_output *output, wl_signal_add(&surface->events.commit, &output->cursor.surface_commit); wl_signal_add(&surface->events.destroy, &output->cursor.surface_destroy); - commit_cursor_surface(output, surface); + // TODO: doing it breaks GTK apps + // TODO: not doing it breaks weston-subsurfaces + //commit_cursor_surface(output, surface); } else { set_cursor(output, NULL, 0, 0, 0, hotspot_x, hotspot_y); } diff --git a/types/wlr_surface.c b/types/wlr_surface.c index a5760d67..b3cdb809 100644 --- a/types/wlr_surface.c +++ b/types/wlr_surface.c @@ -429,7 +429,8 @@ static void wlr_surface_commit_pending(struct wlr_surface *surface) { // Release the buffer after calling commit, because some listeners // might need it (e.g. for cursor surfaces) - wlr_surface_state_release_buffer(surface->current); + // TODO: breaks weston-subsurfaces + //wlr_surface_state_release_buffer(surface->current); } static bool wlr_subsurface_is_synchronized(struct wlr_subsurface *subsurface) { -- cgit v1.2.3