summaryrefslogtreecommitdiffstats
path: root/tests/auto/compositor/compositor/tst_compositor.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 /tests/auto/compositor/compositor/tst_compositor.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 'tests/auto/compositor/compositor/tst_compositor.cpp')
-rw-r--r--tests/auto/compositor/compositor/tst_compositor.cpp36
1 files changed, 36 insertions, 0 deletions
diff --git a/tests/auto/compositor/compositor/tst_compositor.cpp b/tests/auto/compositor/compositor/tst_compositor.cpp
index 2c0e46b2..78e01af7 100644
--- a/tests/auto/compositor/compositor/tst_compositor.cpp
+++ b/tests/auto/compositor/compositor/tst_compositor.cpp
@@ -68,6 +68,7 @@ private slots:
void seatKeyboardFocus();
void seatMouseFocus();
void inputRegion();
+ void defaultInputRegionHiDpi();
void singleClient();
void multipleClients();
void geometry();
@@ -411,6 +412,7 @@ void tst_WaylandCompositor::mapSurface()
QSignalSpy hasContentSpy(waylandSurface, SIGNAL(hasContentChanged()));
QCOMPARE(waylandSurface->size(), QSize());
+ QCOMPARE(waylandSurface->destinationSize(), QSize());
QCOMPARE(waylandSurface->hasContent(), false);
QSize size(256, 256);
@@ -425,6 +427,7 @@ void tst_WaylandCompositor::mapSurface()
QTRY_COMPARE(hasContentSpy.count(), 1);
QCOMPARE(waylandSurface->hasContent(), true);
QCOMPARE(waylandSurface->size(), size);
+ QCOMPARE(waylandSurface->destinationSize(), size);
wl_surface_destroy(surface);
}
@@ -455,6 +458,7 @@ void tst_WaylandCompositor::mapSurfaceHiDpi()
auto verifyComittedState = [=]() {
QCOMPARE(waylandSurface->size(), bufferSize);
+ QCOMPARE(waylandSurface->destinationSize(), surfaceSize);
QCOMPARE(waylandSurface->bufferScale(), bufferScale);
QCOMPARE(waylandSurface->hasContent(), true);
};
@@ -473,6 +477,9 @@ void tst_WaylandCompositor::mapSurfaceHiDpi()
QObject::connect(waylandSurface, &QWaylandSurface::sizeChanged, verifyComittedState);
QSignalSpy sizeSpy(waylandSurface, SIGNAL(sizeChanged()));
+ QObject::connect(waylandSurface, &QWaylandSurface::destinationSizeChanged, verifyComittedState);
+ QSignalSpy destinationSizeSpy(waylandSurface, SIGNAL(destinationSizeChanged()));
+
QObject::connect(waylandSurface, &QWaylandSurface::bufferScaleChanged, verifyComittedState);
QSignalSpy bufferScaleSpy(waylandSurface, SIGNAL(bufferScaleChanged()));
@@ -484,6 +491,7 @@ void tst_WaylandCompositor::mapSurfaceHiDpi()
// No state should be applied before the commit
QCOMPARE(waylandSurface->size(), QSize());
+ QCOMPARE(waylandSurface->destinationSize(), QSize());
QCOMPARE(waylandSurface->hasContent(), false);
QCOMPARE(waylandSurface->bufferScale(), 1);
QCOMPARE(offsetSpy.count(), 0);
@@ -492,6 +500,7 @@ void tst_WaylandCompositor::mapSurfaceHiDpi()
QTRY_COMPARE(hasContentSpy.count(), 1);
QTRY_COMPARE(sizeSpy.count(), 1);
+ QTRY_COMPARE(destinationSizeSpy.count(), 1);
QTRY_COMPARE(bufferScaleSpy.count(), 1);
QTRY_COMPARE(offsetSpy.count(), 1);
@@ -776,6 +785,33 @@ void tst_WaylandCompositor::inputRegion()
QVERIFY(!waylandSurface->inputRegionContains(QPoint(1, 2)));
}
+void tst_WaylandCompositor::defaultInputRegionHiDpi()
+{
+ TestCompositor compositor(true);
+ compositor.create();
+
+ MockClient client;
+ wl_surface *surface = client.createSurface();
+
+ int bufferScale = 2;
+ QSize surfaceSize(16, 16);
+ QSize bufferSize = surfaceSize * bufferScale;
+ ShmBuffer buffer(bufferSize, client.shm);
+ wl_surface_attach(surface, buffer.handle, 0, 0);
+ wl_surface_damage(surface, 0, 0, surfaceSize.width(), surfaceSize.height());
+ wl_surface_set_buffer_scale(surface, bufferScale);
+ wl_surface_commit(surface);
+
+ QTRY_COMPARE(compositor.surfaces.size(), 1);
+ QWaylandSurface *waylandSurface = compositor.surfaces.at(0);
+
+ QCOMPARE(waylandSurface->bufferScale(), bufferScale);
+ QVERIFY(waylandSurface->inputRegionContains(QPoint(0, 0)));
+ QVERIFY(waylandSurface->inputRegionContains(QPoint(15, 15)));
+ QVERIFY(!waylandSurface->inputRegionContains(QPoint(-1, -1)));
+ QVERIFY(!waylandSurface->inputRegionContains(QPoint(16, 16)));
+}
+
class XdgTestCompositor: public TestCompositor {
Q_OBJECT
public: