TechDraw: Buggy Wayland custom cursors workaround (#16740)
* Gui: Minor polishing of cursor regression fix
* TD: Buggy Wayland custom cursors workaround
Until Qt v6.6 displaying custom cursors on Wayland is broken,
so add a workaround. See also QTBUG-95434.
Fix is the same as 094c1b10 ("Gui: Buggy Wayland custom cursors workaround")
plus subsequent fixes.
This commit is contained in:
@@ -656,11 +656,10 @@ static QCursor createCursor(QBitmap &bitmap, QBitmap &mask, int hotX, int hotY,
|
||||
Q_UNUSED(dpr)
|
||||
#endif
|
||||
#ifdef HAS_QTBUG_95434
|
||||
QPixmap pixmap;
|
||||
if (qGuiApp->platformName() == QLatin1String("wayland")) {
|
||||
QImage img = bitmap.toImage();
|
||||
img.convertTo(QImage::Format_ARGB32);
|
||||
pixmap = QPixmap::fromImage(img);
|
||||
QPixmap pixmap = QPixmap::fromImage(img);
|
||||
pixmap.setMask(mask);
|
||||
return QCursor(pixmap, hotX, hotY);
|
||||
}
|
||||
|
||||
@@ -683,24 +683,36 @@ Base::Type QGVPage::getStyleType(std::string model)
|
||||
return type;
|
||||
}
|
||||
|
||||
static QCursor createCursor(QBitmap &bitmap, QBitmap &mask, int hotX, int hotY, double dpr)
|
||||
{
|
||||
#if defined(Q_OS_WIN32)
|
||||
bitmap.setDevicePixelRatio(dpr);
|
||||
mask.setDevicePixelRatio(dpr);
|
||||
#else
|
||||
Q_UNUSED(dpr)
|
||||
#endif
|
||||
#if defined(Q_OS_LINUX) && QT_VERSION < QT_VERSION_CHECK(6,6,0) && QT_VERSION >= QT_VERSION_CHECK(5,13,0)
|
||||
if (qGuiApp->platformName() == QLatin1String("wayland")) {
|
||||
QImage img = bitmap.toImage();
|
||||
img.convertTo(QImage::Format_ARGB32);
|
||||
QPixmap pixmap = QPixmap::fromImage(img);
|
||||
pixmap.setMask(mask);
|
||||
return QCursor(pixmap, hotX, hotY);
|
||||
}
|
||||
#endif
|
||||
|
||||
return QCursor(bitmap, mask, hotX, hotY);
|
||||
}
|
||||
|
||||
void QGVPage::createStandardCursors(double dpr)
|
||||
{
|
||||
(void)dpr;//avoid clang warning re unused parameter
|
||||
QBitmap cursor = QBitmap::fromData(QSize(PAN_WIDTH, PAN_HEIGHT), pan_bitmap);
|
||||
QBitmap 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);
|
||||
panCursor = createCursor(cursor, mask, PAN_HOT_X, PAN_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);
|
||||
}
|
||||
|
||||
#include <Mod/TechDraw/Gui/moc_QGVPage.cpp>
|
||||
|
||||
Reference in New Issue
Block a user