summaryrefslogtreecommitdiff
path: root/src/compositor/compositor_api/qwaylandsurface.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/qwaylandsurface.cpp
parentb4509e500e2b538dd61048bf1a1f53255bbb917c (diff)
downloadqtwayland-79b7925098936ebf3a8e6ca3119256fb4f1a52a9.tar.gz
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/qwaylandsurface.cpp')
-rw-r--r--src/compositor/compositor_api/qwaylandsurface.cpp48
1 files changed, 42 insertions, 6 deletions
diff --git a/src/compositor/compositor_api/qwaylandsurface.cpp b/src/compositor/compositor_api/qwaylandsurface.cpp
index 13ae2822..79b2a9d4 100644
--- a/src/compositor/compositor_api/qwaylandsurface.cpp
+++ b/src/compositor/compositor_api/qwaylandsurface.cpp
@@ -234,19 +234,21 @@ void QWaylandSurfacePrivate::surface_commit(Resource *)
// Needed in order to know whether we want to emit signals later
QSize oldBufferSize = bufferSize;
+ QSize oldDestinationSize = destinationSize;
bool oldHasContent = hasContent;
int oldBufferScale = bufferScale;
// Update all internal state
if (pending.buffer.hasBuffer() || pending.newlyAttached)
bufferRef = pending.buffer;
+ bufferScale = pending.bufferScale;
bufferSize = bufferRef.size();
- damage = pending.damage.intersected(QRect(QPoint(), bufferSize));
+ destinationSize = pending.destinationSize.isEmpty() ? bufferSize / bufferScale : pending.destinationSize;
+ damage = pending.damage.intersected(QRect(QPoint(), destinationSize));
hasContent = bufferRef.hasContent();
- bufferScale = pending.bufferScale;
frameCallbacks << pendingFrameCallbacks;
- inputRegion = pending.inputRegion.intersected(QRect(QPoint(), bufferSize));
- opaqueRegion = pending.opaqueRegion.intersected(QRect(QPoint(), bufferSize));
+ inputRegion = pending.inputRegion.intersected(QRect(QPoint(), destinationSize));
+ opaqueRegion = pending.opaqueRegion.intersected(QRect(QPoint(), destinationSize));
QPoint offsetForNextFrame = pending.offset;
// Clear per-commit state
@@ -274,6 +276,9 @@ void QWaylandSurfacePrivate::surface_commit(Resource *)
if (oldBufferScale != bufferScale)
emit q->bufferScaleChanged();
+ if (oldDestinationSize != destinationSize)
+ emit q->destinationSizeChanged();
+
if (oldHasContent != hasContent)
emit q->hasContentChanged();
@@ -448,15 +453,46 @@ bool QWaylandSurface::hasContent() const
}
/*!
+ * \qmlproperty size QtWaylandCompositor::WaylandSurface::destinationSize
+ *
+ * This property holds the size of this WaylandSurface in surface coordinates.
+ *
+ * If you want the size in pixels, multiply this size with \l bufferScale.
+ *
+ * \sa bufferScale
+ */
+
+/*!
+ * \property QWaylandSurface::destinationSize
+ *
+ * This property holds the size of this WaylandSurface in surface coordinates.
+ *
+ * If you want the size in pixels, multiply this size with \l bufferScale.
+ *
+ * \sa bufferScale
+ */
+QSize QWaylandSurface::destinationSize() const
+{
+ Q_D(const QWaylandSurface);
+ return d->destinationSize;
+}
+
+/*!
* \qmlproperty size QtWaylandCompositor::WaylandSurface::size
*
- * This property holds the WaylandSurface's size in pixels.
+ * This property holds the size of the current buffer of this WaylandSurface in pixels,
+ * not in surface coordinates.
+ *
+ * For the size in surface coordinates, use \l destinationSize instead.
*/
/*!
* \property QWaylandSurface::size
*
- * This property holds the QWaylandSurface's size in pixels.
+ * This property holds the size of the current buffer of this QWaylandSurface in pixels,
+ * not in surface coordinates.
+ *
+ * For the size in surface coordinates, use \l destinationSize instead.
*/
QSize QWaylandSurface::size() const
{