summaryrefslogtreecommitdiffstats
path: root/src/compositor/compositor_api/qwaylandquickitem.cpp
diff options
context:
space:
mode:
authorJohan Klokkhammer Helsing <johan.helsing@qt.io>2016-06-02 16:01:12 +0200
committerJohan Helsing <johan.helsing@qt.io>2016-06-03 10:07:43 +0000
commite402e63d7b2253d3242f2603c2dc31d773951f7a (patch)
treebcf90e8f08a546e6a0ff2acb27906f7916535b95 /src/compositor/compositor_api/qwaylandquickitem.cpp
parent8ef270dacbbb03c5b1eeaabe35e034ce7df96f2f (diff)
Add mapToSurface method to QWaylandQuickItem
Takes the scale factor into account and maps the position to Wayland surface coordinates. Change-Id: Ia96de6d0f53d47c43ef07a4daec7ddb248a51664 Reviewed-by: Paul Olav Tvete <paul.tvete@theqtcompany.com> Reviewed-by: Giulio Camuffo <giulio.camuffo@kdab.com>
Diffstat (limited to 'src/compositor/compositor_api/qwaylandquickitem.cpp')
-rw-r--r--src/compositor/compositor_api/qwaylandquickitem.cpp20
1 files changed, 15 insertions, 5 deletions
diff --git a/src/compositor/compositor_api/qwaylandquickitem.cpp b/src/compositor/compositor_api/qwaylandquickitem.cpp
index ab11ff4f8..c2a5bd20a 100644
--- a/src/compositor/compositor_api/qwaylandquickitem.cpp
+++ b/src/compositor/compositor_api/qwaylandquickitem.cpp
@@ -497,7 +497,7 @@ void QWaylandQuickItem::mousePressEvent(QMouseEvent *event)
if (d->focusOnClick)
takeFocus(inputDevice);
- inputDevice->sendMouseMoveEvent(d->view.data(), event->localPos() / d->scaleFactor(), event->windowPos());
+ inputDevice->sendMouseMoveEvent(d->view.data(), mapToSurface(event->localPos()), event->windowPos());
inputDevice->sendMousePressEvent(event->button());
}
@@ -509,7 +509,7 @@ void QWaylandQuickItem::mouseMoveEvent(QMouseEvent *event)
Q_D(QWaylandQuickItem);
if (d->shouldSendInputEvents()) {
QWaylandInputDevice *inputDevice = compositor()->inputDeviceFor(event);
- inputDevice->sendMouseMoveEvent(d->view.data(), event->localPos() / d->scaleFactor(), event->windowPos());
+ inputDevice->sendMouseMoveEvent(d->view.data(), mapToSurface(event->localPos()), event->windowPos());
} else {
emit mouseMove(event->windowPos());
event->ignore();
@@ -563,7 +563,7 @@ void QWaylandQuickItem::hoverMoveEvent(QHoverEvent *event)
}
if (d->shouldSendInputEvents()) {
QWaylandInputDevice *inputDevice = compositor()->inputDeviceFor(event);
- inputDevice->sendMouseMoveEvent(d->view.data(), event->pos() / d->scaleFactor(), mapToScene(event->pos()));
+ inputDevice->sendMouseMoveEvent(d->view.data(), mapToSurface(event->pos()), mapToScene(event->pos()));
} else {
event->ignore();
}
@@ -898,13 +898,23 @@ void QWaylandQuickItem::setFocusOnClick(bool focus)
*/
bool QWaylandQuickItem::inputRegionContains(const QPointF &localPosition)
{
- Q_D(QWaylandQuickItem);
if (QWaylandSurface *s = surface())
- return s->inputRegionContains(localPosition.toPoint() / d->scaleFactor());
+ return s->inputRegionContains(mapToSurface(localPosition).toPoint());
return false;
}
/*!
+ * Maps the given \a point in this item's coordinate system to the equivalent
+ * point within the Wayland surface's coordinate system, and returns the mapped
+ * coordinate.
+ */
+QPointF QWaylandQuickItem::mapToSurface(const QPointF &point) const
+{
+ Q_D(const QWaylandQuickItem);
+ return point / d->scaleFactor();
+}
+
+/*!
* \qmlproperty bool QtWaylandCompositor::WaylandQuickItem::sizeFollowsSurface
*
* This property specifies whether the size of the item should always match