diff --git a/src/Gui/View3DInventorViewer.cpp b/src/Gui/View3DInventorViewer.cpp index 4979b07400..af8ee9fc35 100644 --- a/src/Gui/View3DInventorViewer.cpp +++ b/src/Gui/View3DInventorViewer.cpp @@ -72,6 +72,10 @@ # include # include # include +#if defined(Q_OS_LINUX) && QT_VERSION < QT_VERSION_CHECK(6,6,0) && QT_VERSION >= QT_VERSION_CHECK(5,13,0) +# include +# define HAS_QTBUG_95434 +#endif # include # include # include @@ -643,35 +647,43 @@ View3DInventorViewer::~View3DInventorViewer() delete glAction; } -void View3DInventorViewer::createStandardCursors(double dpr) +static QCursor createCursor(QBitmap &bitmap, QBitmap &mask, int hotX, int hotY, double dpr) { - // NOLINTBEGIN - QBitmap cursor = QBitmap::fromData(QSize(ROTATE_WIDTH, ROTATE_HEIGHT), rotate_bitmap); - QBitmap mask = QBitmap::fromData(QSize(ROTATE_WIDTH, ROTATE_HEIGHT), rotate_mask_bitmap); #if defined(Q_OS_WIN32) - cursor.setDevicePixelRatio(dpr); + bitmap.setDevicePixelRatio(dpr); mask.setDevicePixelRatio(dpr); #else Q_UNUSED(dpr) #endif - spinCursor = QCursor(cursor, mask, ROTATE_HOT_X, ROTATE_HOT_Y); +#ifdef HAS_QTBUG_95434 + QPixmap pixmap; + if (qGuiApp->platformName() == QLatin1String("wayland")) { + QImage img = bitmap.toImage(); + img.convertTo(QImage::Format_ARGB32); + pixmap = QPixmap::fromImage(img); + } else { + pixmap = bitmap; + } + pixmap.setMask(mask); + return QCursor(pixmap, hotX, hotY); +#else + return QCursor(bitmap, mask, hotX, hotY); +#endif +} + +void View3DInventorViewer::createStandardCursors(double dpr) +{ + QBitmap cursor = QBitmap::fromData(QSize(ROTATE_WIDTH, ROTATE_HEIGHT), rotate_bitmap); + QBitmap mask = QBitmap::fromData(QSize(ROTATE_WIDTH, ROTATE_HEIGHT), rotate_mask_bitmap); + spinCursor = createCursor(cursor, mask, ROTATE_HOT_X, ROTATE_HOT_Y, dpr); cursor = QBitmap::fromData(QSize(ZOOM_WIDTH, ZOOM_HEIGHT), zoom_bitmap); mask = QBitmap::fromData(QSize(ZOOM_WIDTH, ZOOM_HEIGHT), zoom_mask_bitmap); -#if defined(Q_OS_WIN32) - cursor.setDevicePixelRatio(dpr); - mask.setDevicePixelRatio(dpr); -#endif - zoomCursor = QCursor(cursor, mask, ZOOM_HOT_X, ZOOM_HOT_Y); + zoomCursor = createCursor(cursor, mask, ZOOM_HOT_X, ZOOM_HOT_Y, dpr); cursor = QBitmap::fromData(QSize(PAN_WIDTH, PAN_HEIGHT), pan_bitmap); mask = QBitmap::fromData(QSize(PAN_WIDTH, PAN_HEIGHT), pan_mask_bitmap); -#if defined(Q_OS_WIN32) - cursor.setDevicePixelRatio(dpr); - mask.setDevicePixelRatio(dpr); -#endif - panCursor = QCursor(cursor, mask, PAN_HOT_X, PAN_HOT_Y); - // NOLINTEND + panCursor = createCursor(cursor, mask, PAN_HOT_X, PAN_HOT_Y, dpr); } void View3DInventorViewer::aboutToDestroyGLContext()