Keep track of what cusor image buffer is attached to the cursor surface and avoid re-attaching it if we don't have to.
This isn't just an obviously pointless optimization, it turns all of toy toolkit into a test case for handling this properly. Signed-off-by: Derek Foreman <der...@osg.samsung.com> --- Continuing my streak of posting unpopular patches, this patch breaks weston, so I'm not pushing for inclusion, but I think we need to resolve why it breaks, and fix either weston or wayland documentation to reflect expected behaviour. I think this can be attributed to a weston bug, and we should be able to expect that the compositor will be able to redisplay the surface without needing to attach a new buffer, and that if the compositor has released the buffer then it has a kept copy somewhere... Any other opinions? clients/window.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/clients/window.c b/clients/window.c index 15a86e15..81417bd2 100644 --- a/clients/window.c +++ b/clients/window.c @@ -353,6 +353,7 @@ struct input { bool cursor_timer_running; struct task cursor_task; struct wl_surface *pointer_surface; + struct wl_buffer *current_cursor_buffer; uint32_t modifiers; uint32_t pointer_enter_serial; uint32_t cursor_serial; @@ -3769,10 +3770,14 @@ input_set_pointer_image_index(struct input *input, int index) if (!buffer) return; - wl_surface_attach(input->pointer_surface, buffer, 0, 0); - wl_surface_damage(input->pointer_surface, 0, 0, - image->width, image->height); - wl_surface_commit(input->pointer_surface); + if (buffer != input->current_cursor_buffer) { + wl_surface_attach(input->pointer_surface, buffer, 0, 0); + wl_surface_damage(input->pointer_surface, 0, 0, + image->width, image->height); + wl_surface_commit(input->pointer_surface); + } + + input->current_cursor_buffer = buffer; wl_pointer_set_cursor(input->pointer, input->pointer_enter_serial, input->pointer_surface, image->hotspot_x, image->hotspot_y); -- 2.14.3 _______________________________________________ wayland-devel mailing list wayland-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/wayland-devel