Convert cursor bitmap to supported format
The 1-bit image formats QImage::Format_Mono and QImage::Format_MonoLSB used by cursor bitmaps don't have a corresponding wl_shm_format. Therefore, convert to a supported image format as necessary to make such bitmap cursors work on Wayland as well. Fixes: QTBUG-95434 Change-Id: I402fd870b301ddc01075251b66f2cf7cc1923133 Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
This commit is contained in:
parent
f9180f6cd6
commit
fb79f4c3bd
@ -214,7 +214,21 @@ QWaylandCursor::QWaylandCursor(QWaylandDisplay *display)
|
|||||||
QSharedPointer<QWaylandBuffer> QWaylandCursor::cursorBitmapBuffer(QWaylandDisplay *display, const QCursor *cursor)
|
QSharedPointer<QWaylandBuffer> QWaylandCursor::cursorBitmapBuffer(QWaylandDisplay *display, const QCursor *cursor)
|
||||||
{
|
{
|
||||||
Q_ASSERT(cursor->shape() == Qt::BitmapCursor);
|
Q_ASSERT(cursor->shape() == Qt::BitmapCursor);
|
||||||
const QImage &img = cursor->pixmap().toImage();
|
QImage img = !cursor->pixmap().isNull() ? cursor->pixmap().toImage() : cursor->bitmap().toImage();
|
||||||
|
|
||||||
|
// convert to supported format if necessary
|
||||||
|
if (!display->shm()->formatSupported(img.format())) {
|
||||||
|
if (cursor->mask().isNull()) {
|
||||||
|
img.convertTo(QImage::Format_RGB32);
|
||||||
|
} else {
|
||||||
|
// preserve mask
|
||||||
|
img.convertTo(QImage::Format_ARGB32);
|
||||||
|
QPixmap pixmap = QPixmap::fromImage(img);
|
||||||
|
pixmap.setMask(cursor->mask());
|
||||||
|
img = pixmap.toImage();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
QSharedPointer<QWaylandShmBuffer> buffer(new QWaylandShmBuffer(display, img.size(), img.format()));
|
QSharedPointer<QWaylandShmBuffer> buffer(new QWaylandShmBuffer(display, img.size(), img.format()));
|
||||||
memcpy(buffer->image()->bits(), img.bits(), size_t(img.sizeInBytes()));
|
memcpy(buffer->image()->bits(), img.bits(), size_t(img.sizeInBytes()));
|
||||||
return buffer;
|
return buffer;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user