mirror of
https://github.com/hyprwm/wlroots-hyprland.git
synced 2024-11-22 21:05:58 +01:00
Allow to update the cursor hotspot without its pixels
This commit is contained in:
parent
5c6a933890
commit
92daa790bb
5 changed files with 34 additions and 11 deletions
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -11,7 +11,7 @@ struct wlr_output_impl {
|
|||
enum wl_output_transform transform);
|
||||
bool (*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);
|
||||
bool (*move_cursor)(struct wlr_output *output, int x, int y);
|
||||
void (*destroy)(struct wlr_output *output);
|
||||
void (*make_current)(struct wlr_output *output);
|
||||
|
|
|
@ -127,7 +127,7 @@ static bool set_cursor(struct wlr_output *output, const uint8_t *buf,
|
|||
int32_t hotspot_y) {
|
||||
if (output->impl->set_cursor
|
||||
&& output->impl->set_cursor(output, buf, stride, width, height,
|
||||
hotspot_x, hotspot_y)) {
|
||||
hotspot_x, hotspot_y, true)) {
|
||||
output->cursor.is_sw = false;
|
||||
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_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) {
|
||||
wl_list_remove(&output->cursor.surface_commit.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
|
||||
wl_signal_emit(&surface->events.commit, surface);
|
||||
|
||||
// TODO: call this
|
||||
//wlr_surface_state_release_buffer(surface->current);
|
||||
// Release the buffer after calling commit, because some listeners
|
||||
// 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) {
|
||||
|
|
Loading…
Reference in a new issue