diff options
-rw-r--r-- | src/client/qwaylandcursor.cpp | 19 | ||||
-rw-r--r-- | src/client/qwaylanddisplay.cpp | 8 | ||||
-rw-r--r-- | src/client/qwaylanddisplay_p.h | 4 | ||||
-rw-r--r-- | src/client/qwaylandinputdevice.cpp | 16 | ||||
-rw-r--r-- | src/client/qwaylandinputdevice_p.h | 6 |
5 files changed, 28 insertions, 25 deletions
diff --git a/src/client/qwaylandcursor.cpp b/src/client/qwaylandcursor.cpp index 21a6c0811..a356950c3 100644 --- a/src/client/qwaylandcursor.cpp +++ b/src/client/qwaylandcursor.cpp @@ -60,11 +60,14 @@ QWaylandCursor::QWaylandCursor(QWaylandScreen *screen) QByteArray cursorTheme = qgetenv("XCURSOR_THEME"); if (cursorTheme.isEmpty()) cursorTheme = QByteArray("default"); - QByteArray cursorSizeFromEnv = qgetenv("XCURSOR_SIZE"); - bool hasCursorSize = false; - int cursorSize = cursorSizeFromEnv.toInt(&hasCursorSize); - if (!hasCursorSize || cursorSize <= 0) + int cursorSize = qEnvironmentVariableIntValue("XCURSOR_SIZE"); + if (cursorSize <= 0) cursorSize = 32; + + // wl_surface.set_buffer_scale is not supported on earlier versions + if (mDisplay->compositorVersion() >= 3) + cursorSize *= screen->devicePixelRatio(); + mCursorTheme = wl_cursor_theme_load(cursorTheme, cursorSize, mDisplay->shm()->object()); if (!mCursorTheme) qDebug() << "Could not load theme" << cursorTheme; @@ -84,7 +87,7 @@ struct wl_cursor_image *QWaylandCursor::cursorImage(Qt::CursorShape newShape) /* Hide cursor */ if (newShape == Qt::BlankCursor) { - mDisplay->setCursor(nullptr, nullptr); + mDisplay->setCursor(nullptr, nullptr, 1); return nullptr; } @@ -125,12 +128,10 @@ QSharedPointer<QWaylandBuffer> QWaylandCursor::cursorBitmapImage(const QCursor * void QWaylandCursor::changeCursor(QCursor *cursor, QWindow *window) { - Q_UNUSED(window) - const Qt::CursorShape newShape = cursor ? cursor->shape() : Qt::ArrowCursor; if (newShape == Qt::BitmapCursor) { - mDisplay->setCursor(cursorBitmapImage(cursor), cursor->hotSpot()); + mDisplay->setCursor(cursorBitmapImage(cursor), cursor->hotSpot(), window->screen()->devicePixelRatio()); return; } @@ -140,7 +141,7 @@ void QWaylandCursor::changeCursor(QCursor *cursor, QWindow *window) } struct wl_buffer *buffer = wl_cursor_image_get_buffer(image); - mDisplay->setCursor(buffer, image); + mDisplay->setCursor(buffer, image, window->screen()->devicePixelRatio()); } void QWaylandCursor::pointerEvent(const QMouseEvent &event) diff --git a/src/client/qwaylanddisplay.cpp b/src/client/qwaylanddisplay.cpp index 515888d4a..1c2b47da5 100644 --- a/src/client/qwaylanddisplay.cpp +++ b/src/client/qwaylanddisplay.cpp @@ -474,23 +474,23 @@ QWaylandInputDevice *QWaylandDisplay::defaultInputDevice() const } #if QT_CONFIG(cursor) -void QWaylandDisplay::setCursor(struct wl_buffer *buffer, struct wl_cursor_image *image) +void QWaylandDisplay::setCursor(struct wl_buffer *buffer, struct wl_cursor_image *image, qreal dpr) { /* Qt doesn't tell us which input device we should set the cursor * for, so set it for all devices. */ for (int i = 0; i < mInputDevices.count(); i++) { QWaylandInputDevice *inputDevice = mInputDevices.at(i); - inputDevice->setCursor(buffer, image); + inputDevice->setCursor(buffer, image, dpr); } } -void QWaylandDisplay::setCursor(const QSharedPointer<QWaylandBuffer> &buffer, const QPoint &hotSpot) +void QWaylandDisplay::setCursor(const QSharedPointer<QWaylandBuffer> &buffer, const QPoint &hotSpot, qreal dpr) { /* Qt doesn't tell us which input device we should set the cursor * for, so set it for all devices. */ for (int i = 0; i < mInputDevices.count(); i++) { QWaylandInputDevice *inputDevice = mInputDevices.at(i); - inputDevice->setCursor(buffer, hotSpot); + inputDevice->setCursor(buffer, hotSpot, dpr); } } #endif // QT_CONFIG(cursor) diff --git a/src/client/qwaylanddisplay_p.h b/src/client/qwaylanddisplay_p.h index 4100c798d..72f8444e0 100644 --- a/src/client/qwaylanddisplay_p.h +++ b/src/client/qwaylanddisplay_p.h @@ -121,8 +121,8 @@ public: QWaylandWindowManagerIntegration *windowManagerIntegration() const; #if QT_CONFIG(cursor) - void setCursor(struct wl_buffer *buffer, struct wl_cursor_image *image); - void setCursor(const QSharedPointer<QWaylandBuffer> &buffer, const QPoint &hotSpot); + void setCursor(struct wl_buffer *buffer, struct wl_cursor_image *image, qreal dpr); + void setCursor(const QSharedPointer<QWaylandBuffer> &buffer, const QPoint &hotSpot, qreal dpr); #endif struct wl_display *wl_display() const { return mDisplay; } struct ::wl_registry *wl_registry() { return object(); } diff --git a/src/client/qwaylandinputdevice.cpp b/src/client/qwaylandinputdevice.cpp index 93344d13f..4835bd68e 100644 --- a/src/client/qwaylandinputdevice.cpp +++ b/src/client/qwaylandinputdevice.cpp @@ -371,7 +371,7 @@ void QWaylandInputDevice::setCursor(Qt::CursorShape newShape, QWaylandScreen *sc } struct wl_buffer *buffer = wl_cursor_image_get_buffer(image); - setCursor(buffer, image); + setCursor(buffer, image, screen->devicePixelRatio()); } void QWaylandInputDevice::setCursor(const QCursor &cursor, QWaylandScreen *screen) @@ -381,20 +381,20 @@ void QWaylandInputDevice::setCursor(const QCursor &cursor, QWaylandScreen *scree mPointer->mCursorShape = cursor.shape(); if (cursor.shape() == Qt::BitmapCursor) { - setCursor(screen->waylandCursor()->cursorBitmapImage(&cursor), cursor.hotSpot()); + setCursor(screen->waylandCursor()->cursorBitmapImage(&cursor), cursor.hotSpot(), screen->devicePixelRatio()); return; } setCursor(cursor.shape(), screen); } -void QWaylandInputDevice::setCursor(struct wl_buffer *buffer, struct wl_cursor_image *image) +void QWaylandInputDevice::setCursor(struct wl_buffer *buffer, struct wl_cursor_image *image, int bufferScale) { setCursor(buffer, image ? QPoint(image->hotspot_x, image->hotspot_y) : QPoint(), - image ? QSize(image->width, image->height) : QSize()); + image ? QSize(image->width, image->height) : QSize(), bufferScale); } -void QWaylandInputDevice::setCursor(struct wl_buffer *buffer, const QPoint &hotSpot, const QSize &size) +void QWaylandInputDevice::setCursor(struct wl_buffer *buffer, const QPoint &hotSpot, const QSize &size, int bufferScale) { if (mCaps & WL_SEAT_CAPABILITY_POINTER) { bool force = mPointer->mEnterSerial > mPointer->mCursorSerial; @@ -417,14 +417,16 @@ void QWaylandInputDevice::setCursor(struct wl_buffer *buffer, const QPoint &hotS mPointer->set_cursor(mPointer->mEnterSerial, pointerSurface, hotSpot.x(), hotSpot.y()); wl_surface_attach(pointerSurface, buffer, 0, 0); + if (mQDisplay->compositorVersion() >= 3) + wl_surface_set_buffer_scale(pointerSurface, bufferScale); wl_surface_damage(pointerSurface, 0, 0, size.width(), size.height()); wl_surface_commit(pointerSurface); } } -void QWaylandInputDevice::setCursor(const QSharedPointer<QWaylandBuffer> &buffer, const QPoint &hotSpot) +void QWaylandInputDevice::setCursor(const QSharedPointer<QWaylandBuffer> &buffer, const QPoint &hotSpot, int bufferScale) { - setCursor(buffer->buffer(), hotSpot, buffer->size()); + setCursor(buffer->buffer(), hotSpot, buffer->size(), bufferScale); mPixmapCursor = buffer; } #endif diff --git a/src/client/qwaylandinputdevice_p.h b/src/client/qwaylandinputdevice_p.h index 48c1cf57f..4b12cc089 100644 --- a/src/client/qwaylandinputdevice_p.h +++ b/src/client/qwaylandinputdevice_p.h @@ -110,9 +110,9 @@ public: #if QT_CONFIG(cursor) void setCursor(const QCursor &cursor, QWaylandScreen *screen); - void setCursor(struct wl_buffer *buffer, struct ::wl_cursor_image *image); - void setCursor(struct wl_buffer *buffer, const QPoint &hotSpot, const QSize &size); - void setCursor(const QSharedPointer<QWaylandBuffer> &buffer, const QPoint &hotSpot); + void setCursor(struct wl_buffer *buffer, struct ::wl_cursor_image *image, int bufferScale); + void setCursor(struct wl_buffer *buffer, const QPoint &hotSpot, const QSize &size, int bufferScale); + void setCursor(const QSharedPointer<QWaylandBuffer> &buffer, const QPoint &hotSpot, int bufferScale); #endif void handleWindowDestroyed(QWaylandWindow *window); void handleEndDrag(); |