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)
|
, mEnterSerial(0)
|
||||||
, mCursorSerial(0)
|
, mCursorSerial(0)
|
||||||
, mButtons(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)
|
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) {
|
if (cursor.shape() == Qt::BitmapCursor) {
|
||||||
setCursor(screen->waylandCursor()->cursorBitmapImage(&cursor), cursor.hotSpot());
|
setCursor(screen->waylandCursor()->cursorBitmapImage(&cursor), cursor.hotSpot());
|
||||||
return;
|
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)
|
void QWaylandInputDevice::setCursor(struct wl_buffer *buffer, const QPoint &hotSpot, const QSize &size)
|
||||||
{
|
{
|
||||||
if (mCaps & WL_SEAT_CAPABILITY_POINTER) {
|
if (mCaps & WL_SEAT_CAPABILITY_POINTER) {
|
||||||
|
bool force = mPointer->mEnterSerial > mPointer->mCursorSerial;
|
||||||
|
|
||||||
|
if (!force && mPointer->mCursorBuffer == buffer)
|
||||||
|
return;
|
||||||
|
|
||||||
mPixmapCursor.clear();
|
mPixmapCursor.clear();
|
||||||
mPointer->mCursorSerial = mPointer->mEnterSerial;
|
mPointer->mCursorSerial = mPointer->mEnterSerial;
|
||||||
|
|
||||||
|
mPointer->mCursorBuffer = buffer;
|
||||||
|
|
||||||
/* Hide cursor */
|
/* Hide cursor */
|
||||||
if (!buffer)
|
if (!buffer)
|
||||||
{
|
{
|
||||||
|
@ -99,7 +99,6 @@ public:
|
|||||||
|
|
||||||
struct ::wl_seat *wl_seat() { return QtWayland::wl_seat::object(); }
|
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(const QCursor &cursor, QWaylandScreen *screen);
|
||||||
void setCursor(struct wl_buffer *buffer, struct ::wl_cursor_image *image);
|
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(struct wl_buffer *buffer, const QPoint &hotSpot, const QSize &size);
|
||||||
@ -129,6 +128,8 @@ public:
|
|||||||
virtual Touch *createTouch(QWaylandInputDevice *device);
|
virtual Touch *createTouch(QWaylandInputDevice *device);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
void setCursor(Qt::CursorShape cursor, QWaylandScreen *screen);
|
||||||
|
|
||||||
QWaylandDisplay *mQDisplay;
|
QWaylandDisplay *mQDisplay;
|
||||||
struct wl_display *mDisplay;
|
struct wl_display *mDisplay;
|
||||||
|
|
||||||
@ -249,6 +250,8 @@ public:
|
|||||||
QPointF mSurfacePos;
|
QPointF mSurfacePos;
|
||||||
QPointF mGlobalPos;
|
QPointF mGlobalPos;
|
||||||
Qt::MouseButtons mButtons;
|
Qt::MouseButtons mButtons;
|
||||||
|
wl_buffer *mCursorBuffer;
|
||||||
|
Qt::CursorShape mCursorShape;
|
||||||
};
|
};
|
||||||
|
|
||||||
class Q_WAYLAND_CLIENT_EXPORT QWaylandInputDevice::Touch : public QtWayland::wl_touch
|
class Q_WAYLAND_CLIENT_EXPORT QWaylandInputDevice::Touch : public QtWayland::wl_touch
|
||||||
|
@ -81,7 +81,6 @@ QWaylandWindow::QWaylandWindow(QWindow *window)
|
|||||||
, mWindowDecoration(0)
|
, mWindowDecoration(0)
|
||||||
, mMouseEventsInContentArea(false)
|
, mMouseEventsInContentArea(false)
|
||||||
, mMousePressedInContentArea(Qt::NoButton)
|
, mMousePressedInContentArea(Qt::NoButton)
|
||||||
, m_cursor(Qt::ArrowCursor)
|
|
||||||
, mWaitingForFrameSync(false)
|
, mWaitingForFrameSync(false)
|
||||||
, mFrameCallback(nullptr)
|
, mFrameCallback(nullptr)
|
||||||
, mRequestResizeSent(false)
|
, mRequestResizeSent(false)
|
||||||
@ -780,10 +779,7 @@ void QWaylandWindow::handleMouseEventWithDecoration(QWaylandInputDevice *inputDe
|
|||||||
|
|
||||||
void QWaylandWindow::setMouseCursor(QWaylandInputDevice *device, const QCursor &cursor)
|
void QWaylandWindow::setMouseCursor(QWaylandInputDevice *device, const QCursor &cursor)
|
||||||
{
|
{
|
||||||
if (device->serial() >= device->cursorSerial()) {
|
device->setCursor(cursor, mScreen);
|
||||||
device->setCursor(cursor, mScreen);
|
|
||||||
m_cursor = cursor;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void QWaylandWindow::restoreMouseCursor(QWaylandInputDevice *device)
|
void QWaylandWindow::restoreMouseCursor(QWaylandInputDevice *device)
|
||||||
|
@ -217,7 +217,6 @@ protected:
|
|||||||
QWaylandAbstractDecoration *mWindowDecoration;
|
QWaylandAbstractDecoration *mWindowDecoration;
|
||||||
bool mMouseEventsInContentArea;
|
bool mMouseEventsInContentArea;
|
||||||
Qt::MouseButtons mMousePressedInContentArea;
|
Qt::MouseButtons mMousePressedInContentArea;
|
||||||
QCursor m_cursor;
|
|
||||||
|
|
||||||
WId mWindowId;
|
WId mWindowId;
|
||||||
bool mWaitingForFrameSync;
|
bool mWaitingForFrameSync;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user