Don't reset the cursor at every mouse move
Change-Id: I67f9a0d171da403ebb124ab584c2510891da80fc Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
This commit is contained in:
parent
882f20bbf4
commit
999fe98f66
@ -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)
|
||||
{
|
||||
|
@ -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
|
||||
|
@ -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)
|
||||
|
@ -217,7 +217,6 @@ protected:
|
||||
QWaylandAbstractDecoration *mWindowDecoration;
|
||||
bool mMouseEventsInContentArea;
|
||||
Qt::MouseButtons mMousePressedInContentArea;
|
||||
QCursor m_cursor;
|
||||
|
||||
WId mWindowId;
|
||||
bool mWaitingForFrameSync;
|
||||
|
Loading…
x
Reference in New Issue
Block a user