summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Olav Tvete <paul.tvete@qt.io>2016-11-21 11:53:26 +0100
committerPaul Olav Tvete <paul.tvete@qt.io>2016-11-22 10:35:25 +0000
commitc445cf7d4e517248013e707a5050f9e0408a2746 (patch)
tree9079d063a8127d665a2ff095d6d57e957467f152
parent61e2b73e0922bd9983cd45a274ab4b813b380aff (diff)
Only send mouse move event when mouse moves
Qt Quick recently changed to send hover events 60 times per second even if the mouse doesn't move. Make sure we only send mouse move events over the Wayland protocol if the mouse actually moved. Change-Id: Ic196512dde1718de461eb2c64cec2e95e220ce89 Reviewed-by: Johan Helsing <johan.helsing@qt.io>
-rw-r--r--src/compositor/compositor_api/qwaylandquickitem.cpp8
-rw-r--r--src/compositor/compositor_api/qwaylandquickitem_p.h1
2 files changed, 8 insertions, 1 deletions
diff --git a/src/compositor/compositor_api/qwaylandquickitem.cpp b/src/compositor/compositor_api/qwaylandquickitem.cpp
index d57cbb42..9bf42813 100644
--- a/src/compositor/compositor_api/qwaylandquickitem.cpp
+++ b/src/compositor/compositor_api/qwaylandquickitem.cpp
@@ -481,6 +481,7 @@ void QWaylandQuickItem::mousePressEvent(QMouseEvent *event)
seat->sendMouseMoveEvent(d->view.data(), mapToSurface(event->localPos()), event->windowPos());
seat->sendMousePressEvent(event->button());
+ d->hoverPos = event->pos();
}
/*!
@@ -503,6 +504,7 @@ void QWaylandQuickItem::mouseMoveEvent(QMouseEvent *event)
}
} else {
seat->sendMouseMoveEvent(d->view.data(), mapToSurface(event->localPos()), event->windowPos());
+ d->hoverPos = event->pos();
}
} else {
emit mouseMove(event->windowPos());
@@ -543,6 +545,7 @@ void QWaylandQuickItem::hoverEnterEvent(QHoverEvent *event)
if (d->shouldSendInputEvents()) {
QWaylandSeat *seat = compositor()->seatFor(event);
seat->sendMouseMoveEvent(d->view.data(), event->pos(), mapToScene(event->pos()));
+ d->hoverPos = event->pos();
} else {
event->ignore();
}
@@ -562,7 +565,10 @@ void QWaylandQuickItem::hoverMoveEvent(QHoverEvent *event)
}
if (d->shouldSendInputEvents()) {
QWaylandSeat *seat = compositor()->seatFor(event);
- seat->sendMouseMoveEvent(d->view.data(), mapToSurface(event->pos()), mapToScene(event->pos()));
+ if (event->pos() != d->hoverPos) {
+ seat->sendMouseMoveEvent(d->view.data(), mapToSurface(event->pos()), mapToScene(event->pos()));
+ d->hoverPos = event->pos();
+ }
} else {
event->ignore();
}
diff --git a/src/compositor/compositor_api/qwaylandquickitem_p.h b/src/compositor/compositor_api/qwaylandquickitem_p.h
index 441ac976..fc69fe09 100644
--- a/src/compositor/compositor_api/qwaylandquickitem_p.h
+++ b/src/compositor/compositor_api/qwaylandquickitem_p.h
@@ -173,6 +173,7 @@ public:
bool newTexture;
bool focusOnClick;
bool sizeFollowsSurface;
+ QPoint hoverPos;
QQuickWindow *connectedWindow;
QWaylandSurface::Origin origin;