From 2d7b97e3fb8ede4a8d604179589fac6d7b3d84c7 Mon Sep 17 00:00:00 2001 From: Alan Griffiths Date: Thu, 9 Jan 2020 15:33:11 +0000 Subject: [PATCH] Wayland: (cursor code) don't assume PixelSource::read() will execute the do_with_pixels functor. --- src/server/frontend_wayland/wl_pointer.cpp | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/src/server/frontend_wayland/wl_pointer.cpp b/src/server/frontend_wayland/wl_pointer.cpp index 83c807b0a69..7596b2f926c 100644 --- a/src/server/frontend_wayland/wl_pointer.cpp +++ b/src/server/frontend_wayland/wl_pointer.cpp @@ -55,13 +55,12 @@ class BufferCursorImage : public mg::CursorImage auto pixel_source = dynamic_cast(buffer.native_buffer_base()); if (pixel_source) { - pixel_source->read([&](unsigned char const* buffer_pixels) + size_t const buffer_size_bytes = buffer_size.width.as_int() * buffer_size.height.as_int() + * MIR_BYTES_PER_PIXEL(buffer.pixel_format()); + pixels = std::unique_ptr(new unsigned char[buffer_size_bytes]); + + pixel_source->read([this, buffer_size_bytes](unsigned char const* buffer_pixels) { - size_t buffer_size_bytes = buffer_size.width.as_int() * buffer_size.height.as_int() - * MIR_BYTES_PER_PIXEL(buffer.pixel_format()); - pixels = std::unique_ptr( - new unsigned char[buffer_size_bytes] - ); memcpy(pixels.get(), buffer_pixels, buffer_size_bytes); }); } @@ -357,7 +356,12 @@ void WlSurfaceCursor::apply_latest_buffer() auto const cursor_image = std::make_shared( *stream->lock_compositor_buffer(this), hotspot); - surface->set_cursor_image(cursor_image); + if (cursor_image->as_argb_8888()) + surface->set_cursor_image(cursor_image); + else + { + + } } else {