summaryrefslogtreecommitdiffstats
path: root/src/compositor/compositor_api/qwaylandquickitem.cpp
diff options
context:
space:
mode:
authorJohan Klokkhammer Helsing <johan.helsing@qt.io>2018-10-17 14:07:42 +0200
committerJohan Helsing <johan.helsing@qt.io>2018-11-16 08:49:03 +0000
commit79b7925098936ebf3a8e6ca3119256fb4f1a52a9 (patch)
tree8325821ac50530ef09e9f9d224d2dc09cc707fd6 /src/compositor/compositor_api/qwaylandquickitem.cpp
parentb4509e500e2b538dd61048bf1a1f53255bbb917c (diff)
Compositor: Fix coordinate system inconsistencies
Several properties were using pixel coordinates and surface coordinates without converting. [ChangeLog][Compositor] QWaylandSurface::destinationSize has been added which returns the size of the surface that will be displayed on the screen in surface coordinates. [ChangeLog][Compositor] Fixed a bug where QWaylandSurface::inputRegionContains would return true for some points outside surfaces with buffer scale > 1. [ChangeLog][Compositor] Fixed a bug which caused ShellSurfaceItems for surfaces with buffer scale > 1 to move too much when resizing interactively. It also gets rid of all calls to QWaylandSurface::size, which confusingly returns the size of the surface's buffer in pixel coordinates. Most properties now use destionationSize's surface coordinates consistently. Hopefully, QWaylandSurface::size can be renamed or removed in Qt 6. Change-Id: I007256a8df7759cf74fbfd51624fa1f90c083336 Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
Diffstat (limited to 'src/compositor/compositor_api/qwaylandquickitem.cpp')
-rw-r--r--src/compositor/compositor_api/qwaylandquickitem.cpp18
1 files changed, 9 insertions, 9 deletions
diff --git a/src/compositor/compositor_api/qwaylandquickitem.cpp b/src/compositor/compositor_api/qwaylandquickitem.cpp
index 6be5701ff..8e1b84921 100644
--- a/src/compositor/compositor_api/qwaylandquickitem.cpp
+++ b/src/compositor/compositor_api/qwaylandquickitem.cpp
@@ -886,7 +886,7 @@ void QWaylandQuickItem::handleSurfaceChanged()
if (d->oldSurface) {
disconnect(d->oldSurface, &QWaylandSurface::hasContentChanged, this, &QWaylandQuickItem::surfaceMappedChanged);
disconnect(d->oldSurface, &QWaylandSurface::parentChanged, this, &QWaylandQuickItem::parentChanged);
- disconnect(d->oldSurface, &QWaylandSurface::sizeChanged, this, &QWaylandQuickItem::updateSize);
+ disconnect(d->oldSurface, &QWaylandSurface::destinationSizeChanged, this, &QWaylandQuickItem::updateSize);
disconnect(d->oldSurface, &QWaylandSurface::bufferScaleChanged, this, &QWaylandQuickItem::updateSize);
disconnect(d->oldSurface, &QWaylandSurface::configure, this, &QWaylandQuickItem::updateBuffer);
disconnect(d->oldSurface, &QWaylandSurface::redraw, this, &QQuickItem::update);
@@ -903,7 +903,7 @@ void QWaylandQuickItem::handleSurfaceChanged()
if (QWaylandSurface *newSurface = d->view->surface()) {
connect(newSurface, &QWaylandSurface::hasContentChanged, this, &QWaylandQuickItem::surfaceMappedChanged);
connect(newSurface, &QWaylandSurface::parentChanged, this, &QWaylandQuickItem::parentChanged);
- connect(newSurface, &QWaylandSurface::sizeChanged, this, &QWaylandQuickItem::updateSize);
+ connect(newSurface, &QWaylandSurface::destinationSizeChanged, this, &QWaylandQuickItem::updateSize);
connect(newSurface, &QWaylandSurface::bufferScaleChanged, this, &QWaylandQuickItem::updateSize);
connect(newSurface, &QWaylandSurface::configure, this, &QWaylandQuickItem::updateBuffer);
connect(newSurface, &QWaylandSurface::redraw, this, &QQuickItem::update);
@@ -992,7 +992,7 @@ void QWaylandQuickItem::updateSize()
QSize size(0, 0);
if (surface())
- size = surface()->size() * (d->scaleFactor() / surface()->bufferScale());
+ size = surface()->destinationSize() * d->scaleFactor();
setImplicitSize(size.width(), size.height());
if (d->sizeFollowsSurface)
@@ -1061,11 +1061,11 @@ bool QWaylandQuickItem::inputRegionContains(const QPointF &localPosition)
QPointF QWaylandQuickItem::mapToSurface(const QPointF &point) const
{
Q_D(const QWaylandQuickItem);
- if (!surface() || surface()->size().isEmpty())
+ if (!surface() || surface()->destinationSize().isEmpty())
return point / d->scaleFactor();
- qreal xScale = width() / surface()->size().width() * surface()->bufferScale();
- qreal yScale = height() / surface()->size().height() * surface()->bufferScale();
+ qreal xScale = width() / surface()->destinationSize().width();
+ qreal yScale = height() / surface()->destinationSize().height();
return QPointF(point.x() / xScale, point.y() / yScale);
}
@@ -1077,11 +1077,11 @@ QPointF QWaylandQuickItem::mapToSurface(const QPointF &point) const
QPointF QWaylandQuickItem::mapFromSurface(const QPointF &point) const
{
Q_D(const QWaylandQuickItem);
- if (!surface() || surface()->size().isEmpty())
+ if (!surface() || surface()->destinationSize().isEmpty())
return point * d->scaleFactor();
- qreal xScale = width() / surface()->size().width() * surface()->bufferScale();
- qreal yScale = height() / surface()->size().height() * surface()->bufferScale();
+ qreal xScale = width() / surface()->destinationSize().width();
+ qreal yScale = height() / surface()->destinationSize().height();
return QPointF(point.x() * xScale, point.y() * yScale);
}