diff options
author | Giulio Camuffo <giulio.camuffo@kdab.com> | 2016-11-19 08:58:17 +0100 |
---|---|---|
committer | Giulio Camuffo <giulio.camuffo@kdab.com> | 2016-11-22 09:09:17 +0000 |
commit | fc1901b4b34d29df79be1b9b1c1d3f5a127eaa59 (patch) | |
tree | 136cc934fc114c9c65c2cbfd52e9729484a98ff3 | |
parent | 7197be7c0e9d00f98551d12bcc30782503612fe9 (diff) | |
download | qtwayland-fc1901b4b34d29df79be1b9b1c1d3f5a127eaa59.tar.gz |
Don't reset the cursor at every mouse move
Change-Id: I67f9a0d171da403ebb124ab584c2510891da80fc
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
-rw-r--r-- | src/client/qwaylandinputdevice.cpp | 14 | ||||
-rw-r--r-- | src/client/qwaylandinputdevice_p.h | 5 | ||||
-rw-r--r-- | src/client/qwaylandwindow.cpp | 6 | ||||
-rw-r--r-- | src/client/qwaylandwindow_p.h | 1 |
4 files changed, 19 insertions, 7 deletions
diff --git a/src/client/qwaylandinputdevice.cpp b/src/client/qwaylandinputdevice.cpp index 94316baf..de052089 100644 --- a/src/client/qwaylandinputdevice.cpp +++ b/src/client/qwaylandinputdevice.cpp @@ -147,6 +147,8 @@ QWaylandInputDevice::Pointer::Pointer(QWaylandInputDevice *p) , mEnterSerial(0) , mCursorSerial(0) , mButtons(0) + , mCursorBuffer(nullptr) + , mCursorShape(Qt::BitmapCursor) { } @@ -362,6 +364,10 @@ void QWaylandInputDevice::setCursor(Qt::CursorShape newShape, QWaylandScreen *sc void QWaylandInputDevice::setCursor(const QCursor &cursor, QWaylandScreen *screen) { + if (cursor.shape() != Qt::BitmapCursor && cursor.shape() == mPointer->mCursorShape) + return; + + mPointer->mCursorShape = cursor.shape(); if (cursor.shape() == Qt::BitmapCursor) { setCursor(screen->waylandCursor()->cursorBitmapImage(&cursor), cursor.hotSpot()); return; @@ -379,8 +385,16 @@ void QWaylandInputDevice::setCursor(struct wl_buffer *buffer, struct wl_cursor_i void QWaylandInputDevice::setCursor(struct wl_buffer *buffer, const QPoint &hotSpot, const QSize &size) { if (mCaps & WL_SEAT_CAPABILITY_POINTER) { + bool force = mPointer->mEnterSerial > mPointer->mCursorSerial; + + if (!force && mPointer->mCursorBuffer == buffer) + return; + mPixmapCursor.clear(); mPointer->mCursorSerial = mPointer->mEnterSerial; + + mPointer->mCursorBuffer = buffer; + /* Hide cursor */ if (!buffer) { diff --git a/src/client/qwaylandinputdevice_p.h b/src/client/qwaylandinputdevice_p.h index 2f39bc54..d41bde56 100644 --- a/src/client/qwaylandinputdevice_p.h +++ b/src/client/qwaylandinputdevice_p.h @@ -99,7 +99,6 @@ public: struct ::wl_seat *wl_seat() { return QtWayland::wl_seat::object(); } - void setCursor(Qt::CursorShape cursor, QWaylandScreen *screen); 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); @@ -129,6 +128,8 @@ public: virtual Touch *createTouch(QWaylandInputDevice *device); private: + void setCursor(Qt::CursorShape cursor, QWaylandScreen *screen); + QWaylandDisplay *mQDisplay; struct wl_display *mDisplay; @@ -249,6 +250,8 @@ public: QPointF mSurfacePos; QPointF mGlobalPos; Qt::MouseButtons mButtons; + wl_buffer *mCursorBuffer; + Qt::CursorShape mCursorShape; }; class Q_WAYLAND_CLIENT_EXPORT QWaylandInputDevice::Touch : public QtWayland::wl_touch diff --git a/src/client/qwaylandwindow.cpp b/src/client/qwaylandwindow.cpp index 1ff6686f..8e40f3b3 100644 --- a/src/client/qwaylandwindow.cpp +++ b/src/client/qwaylandwindow.cpp @@ -81,7 +81,6 @@ QWaylandWindow::QWaylandWindow(QWindow *window) , mWindowDecoration(0) , mMouseEventsInContentArea(false) , mMousePressedInContentArea(Qt::NoButton) - , m_cursor(Qt::ArrowCursor) , mWaitingForFrameSync(false) , mFrameCallback(nullptr) , mRequestResizeSent(false) @@ -780,10 +779,7 @@ void QWaylandWindow::handleMouseEventWithDecoration(QWaylandInputDevice *inputDe void QWaylandWindow::setMouseCursor(QWaylandInputDevice *device, const QCursor &cursor) { - if (device->serial() >= device->cursorSerial()) { - device->setCursor(cursor, mScreen); - m_cursor = cursor; - } + device->setCursor(cursor, mScreen); } void QWaylandWindow::restoreMouseCursor(QWaylandInputDevice *device) diff --git a/src/client/qwaylandwindow_p.h b/src/client/qwaylandwindow_p.h index 7e7078fc..f5988fbd 100644 --- a/src/client/qwaylandwindow_p.h +++ b/src/client/qwaylandwindow_p.h @@ -217,7 +217,6 @@ protected: QWaylandAbstractDecoration *mWindowDecoration; bool mMouseEventsInContentArea; Qt::MouseButtons mMousePressedInContentArea; - QCursor m_cursor; WId mWindowId; bool mWaitingForFrameSync; |