From 7cee19778a5fe603105ba056a4d0307fd04c361a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kristian=20H=C3=B8gsberg?= Date: Mon, 4 Jun 2012 23:37:42 -0400 Subject: [PATCH] window.c: Add primitive support for animated cursors This just adds an entry point to set a specific frame of an animated cursor. --- clients/window.c | 21 ++++++++++++++++----- clients/window.h | 3 +++ 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/clients/window.c b/clients/window.c index 314e5e98..6b36c842 100644 --- a/clients/window.c +++ b/clients/window.c @@ -2275,20 +2275,22 @@ static const struct wl_data_device_listener data_device_listener = { }; void -input_set_pointer_image(struct input *input, int pointer) +input_set_pointer_image_index(struct input *input, int pointer, int index) { struct wl_buffer *buffer; struct wl_cursor *cursor; struct wl_cursor_image *image; - if (pointer == input->current_cursor) - return; - cursor = input->display->cursors[pointer]; if (!cursor) return; - image = cursor->images[0]; + if (index >= (int) cursor->image_count) { + fprintf(stderr, "cursor index out of range\n"); + return; + } + + image = cursor->images[index]; buffer = wl_cursor_image_get_buffer(image); if (!buffer) return; @@ -2298,6 +2300,15 @@ input_set_pointer_image(struct input *input, int pointer) buffer, image->hotspot_x, image->hotspot_y); } +void +input_set_pointer_image(struct input *input, int pointer) +{ + if (pointer == input->current_cursor) + return; + + input_set_pointer_image_index(input, pointer, 0); +} + struct wl_data_device * input_get_data_device(struct input *input) { diff --git a/clients/window.h b/clients/window.h index 56ca3ea3..25219641 100644 --- a/clients/window.h +++ b/clients/window.h @@ -367,6 +367,9 @@ frame_create(struct window *window, void *data); void input_set_pointer_image(struct input *input, int pointer); +void +input_set_pointer_image_index(struct input *input, int pointer, int index); + void input_get_position(struct input *input, int32_t *x, int32_t *y);