summaryrefslogtreecommitdiff
path: root/src/input.c
diff options
context:
space:
mode:
authorDerek Foreman <derekf@osg.samsung.com>2015-03-23 10:55:32 -0500
committerPekka Paalanen <pekka.paalanen@collabora.co.uk>2015-03-26 10:15:48 +0200
commit4e53c53fe705781e848cfbfa24f0aff7eba0a5ff (patch)
treed48f2055cad2260aa68296a771eff7392ee3bf4a /src/input.c
parentabff883d2c8aca3ea28e880e90e5806604588720 (diff)
downloadweston-4e53c53fe705781e848cfbfa24f0aff7eba0a5ff.tar.gz
input: Don't recreate the cursor sprite when only the hotspot changes
Currently we unmap and re-map the cursor when the hotspot changes which causes spurious enter/leave events. This changes the pointer_set_cursor() logic to avoid this. Signed-off-by: Derek Foreman <derekf@osg.samsung.com> Reviewed-by: Jonas Ã…dahl <jadahl@gmail.com> Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Diffstat (limited to 'src/input.c')
-rw-r--r--src/input.c36
1 files changed, 20 insertions, 16 deletions
diff --git a/src/input.c b/src/input.c
index 469d5cee..142c6708 100644
--- a/src/input.c
+++ b/src/input.c
@@ -1648,31 +1648,35 @@ pointer_set_cursor(struct wl_client *client, struct wl_resource *resource,
if (pointer->focus_serial - serial > UINT32_MAX / 2)
return;
- if (surface) {
- if (weston_surface_set_role(surface, "wl_pointer-cursor",
- resource,
- WL_POINTER_ERROR_ROLE) < 0)
- return;
+ if (!surface) {
+ if (pointer->sprite)
+ pointer_unmap_sprite(pointer);
+ return;
}
if (pointer->sprite && pointer->sprite->surface == surface &&
pointer->hotspot_x == x && pointer->hotspot_y == y)
return;
- if (pointer->sprite)
- pointer_unmap_sprite(pointer);
+ if (!pointer->sprite || pointer->sprite->surface != surface) {
+ if (weston_surface_set_role(surface, "wl_pointer-cursor",
+ resource,
+ WL_POINTER_ERROR_ROLE) < 0)
+ return;
- if (!surface)
- return;
+ if (pointer->sprite)
+ pointer_unmap_sprite(pointer);
- wl_signal_add(&surface->destroy_signal,
- &pointer->sprite_destroy_listener);
+ wl_signal_add(&surface->destroy_signal,
+ &pointer->sprite_destroy_listener);
+
+ surface->configure = pointer_cursor_surface_configure;
+ surface->configure_private = pointer;
+ weston_surface_set_label_func(surface,
+ pointer_cursor_surface_get_label);
+ pointer->sprite = weston_view_create(surface);
+ }
- surface->configure = pointer_cursor_surface_configure;
- surface->configure_private = pointer;
- weston_surface_set_label_func(surface,
- pointer_cursor_surface_get_label);
- pointer->sprite = weston_view_create(surface);
pointer->hotspot_x = x;
pointer->hotspot_y = y;