Allow to update the cursor hotspot without its pixels

master
emersion 7 years ago
parent 5c6a933890
commit 92daa790bb
No known key found for this signature in database
GPG Key ID: 0FDE7BE0E88F5E48

@ -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, static bool wlr_drm_connector_set_cursor(struct wlr_output *output,
const uint8_t *buf, int32_t stride, uint32_t width, uint32_t height, 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_connector *conn = (struct wlr_drm_connector *)output;
struct wlr_drm_backend *drm = conn->drm; struct wlr_drm_backend *drm = conn->drm;
struct wlr_drm_renderer *renderer = &drm->renderer; 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_crtc *crtc = conn->crtc;
struct wlr_drm_plane *plane = crtc->cursor; 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); 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; break;
} }
if (!update_pixels) {
// Only update the cursor hotspot
return true;
}
struct gbm_bo *bo = plane->cursor_bo; struct gbm_bo *bo = plane->cursor_bo;
uint32_t bo_width = gbm_bo_get_width(bo); uint32_t bo_width = gbm_bo_get_width(bo);
uint32_t bo_height = gbm_bo_get_height(bo); uint32_t bo_height = gbm_bo_get_height(bo);

@ -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, static bool wlr_wl_output_set_cursor(struct wlr_output *_output,
const uint8_t *buf, int32_t stride, uint32_t width, uint32_t height, 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_output *output = (struct wlr_wl_backend_output *)_output;
struct wlr_wl_backend *backend = output->backend; 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) { if (!buf) {
// Hide cursor
wl_pointer_set_cursor(output->backend->pointer, output->enter_serial, wl_pointer_set_cursor(output->backend->pointer, output->enter_serial,
NULL, 0, 0); NULL, 0, 0);
return true; return true;

@ -8,16 +8,16 @@ struct wlr_output_impl {
void (*enable)(struct wlr_output *output, bool enable); void (*enable)(struct wlr_output *output, bool enable);
bool (*set_mode)(struct wlr_output *output, struct wlr_output_mode *mode); bool (*set_mode)(struct wlr_output *output, struct wlr_output_mode *mode);
void (*transform)(struct wlr_output *output, void (*transform)(struct wlr_output *output,
enum wl_output_transform transform); enum wl_output_transform transform);
bool (*set_cursor)(struct wlr_output *output, const uint8_t *buf, bool (*set_cursor)(struct wlr_output *output, const uint8_t *buf,
int32_t stride, uint32_t width, uint32_t height, 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);
bool (*move_cursor)(struct wlr_output *output, int x, int y); bool (*move_cursor)(struct wlr_output *output, int x, int y);
void (*destroy)(struct wlr_output *output); void (*destroy)(struct wlr_output *output);
void (*make_current)(struct wlr_output *output); void (*make_current)(struct wlr_output *output);
void (*swap_buffers)(struct wlr_output *output); void (*swap_buffers)(struct wlr_output *output);
void (*set_gamma)(struct wlr_output *output, void (*set_gamma)(struct wlr_output *output,
uint16_t size, uint16_t *r, uint16_t *g, uint16_t *b); uint16_t size, uint16_t *r, uint16_t *g, uint16_t *b);
uint16_t (*get_gamma_size)(struct wlr_output *output); uint16_t (*get_gamma_size)(struct wlr_output *output);
}; };
@ -25,6 +25,6 @@ void wlr_output_init(struct wlr_output *output, const struct wlr_output_impl *im
void wlr_output_free(struct wlr_output *output); void wlr_output_free(struct wlr_output *output);
void wlr_output_update_matrix(struct wlr_output *output); void wlr_output_update_matrix(struct wlr_output *output);
struct wl_global *wlr_output_create_global( struct wl_global *wlr_output_create_global(
struct wlr_output *wlr_output, struct wl_display *display); struct wlr_output *wlr_output, struct wl_display *display);
#endif #endif

@ -127,7 +127,7 @@ static bool set_cursor(struct wlr_output *output, const uint8_t *buf,
int32_t hotspot_y) { int32_t hotspot_y) {
if (output->impl->set_cursor if (output->impl->set_cursor
&& output->impl->set_cursor(output, buf, stride, width, height, && output->impl->set_cursor(output, buf, stride, width, height,
hotspot_x, hotspot_y)) { hotspot_x, hotspot_y, true)) {
output->cursor.is_sw = false; output->cursor.is_sw = false;
return true; return true;
} }
@ -238,6 +238,15 @@ void wlr_output_set_cursor_surface(struct wlr_output *output,
output->cursor.hotspot_x = hotspot_x; output->cursor.hotspot_x = hotspot_x;
output->cursor.hotspot_y = hotspot_y; output->cursor.hotspot_y = hotspot_y;
if (surface && surface == output->cursor.surface) {
if (output->impl->set_cursor && !output->cursor.is_sw) {
// Only update the hotspot
output->impl->set_cursor(output, NULL, 0, 0, 0, hotspot_x,
hotspot_y, false);
}
return;
}
if (output->cursor.surface) { if (output->cursor.surface) {
wl_list_remove(&output->cursor.surface_commit.link); wl_list_remove(&output->cursor.surface_commit.link);
wl_list_remove(&output->cursor.surface_destroy.link); wl_list_remove(&output->cursor.surface_destroy.link);

@ -427,8 +427,9 @@ static void wlr_surface_commit_pending(struct wlr_surface *surface) {
// TODO: add the invalid bitfield to this callback // TODO: add the invalid bitfield to this callback
wl_signal_emit(&surface->events.commit, surface); wl_signal_emit(&surface->events.commit, surface);
// TODO: call this // Release the buffer after calling commit, because some listeners
//wlr_surface_state_release_buffer(surface->current); // might need it (e.g. for cursor surfaces)
wlr_surface_state_release_buffer(surface->current);
} }
static bool wlr_subsurface_is_synchronized(struct wlr_subsurface *subsurface) { static bool wlr_subsurface_is_synchronized(struct wlr_subsurface *subsurface) {

Loading…
Cancel
Save