summaryrefslogtreecommitdiffstats
path: root/tests/auto/compositor/compositor/tst_compositor.cpp
diff options
context:
space:
mode:
authorPier Luigi Fiorini <pierluigi.fiorini@gmail.com>2015-04-10 17:52:49 +0200
committerPier Luigi Fiorini <pierluigi.fiorini@hawaiios.org>2016-10-03 15:15:58 +0000
commit7ee4be6af2c92c345539bb4950dd48d7a740847d (patch)
tree2acbcfb9fd0a2dbc995cb0d700e7e14ad4afd759 /tests/auto/compositor/compositor/tst_compositor.cpp
parent59c8598958959de943a0782093f020ae1c348edf (diff)
Add mode support to QWaylandOutput
Outputs usually have more than one mode, add an API to support them. When sizeFollowsWindow is true, modes are replaced by one with the window size and refresh rate. In that circumstance the mode changes when the window is resized. The sizeFollowsWindow property default value is no longer true. The setGeometry() method is gone as it doesn't make sense now, the setWidth() and setHeight() methods are now private slots to resize the resolution as the window resizes (and sizeFollowsWindow is true). Refresh rate is expressed in mHz rather than Hz just like the Wayland protocol. A compositor implementation may choose to add modes if it has access to hardware information, it will call addMode() for each mode and then invoke the setCurrentMode() method that sends the modes list to the client. The preferred mode is indicated with a boolean parameter to the addMode() method. Change-Id: Iffed4784ccef695c276ebd800172957f4cff3324 Task-number: QTBUG-49814 Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io> Reviewed-by: Johan Helsing <johan.helsing@qt.io>
Diffstat (limited to 'tests/auto/compositor/compositor/tst_compositor.cpp')
-rw-r--r--tests/auto/compositor/compositor/tst_compositor.cpp58
1 files changed, 55 insertions, 3 deletions
diff --git a/tests/auto/compositor/compositor/tst_compositor.cpp b/tests/auto/compositor/compositor/tst_compositor.cpp
index 16aedd8e..393b9f5b 100644
--- a/tests/auto/compositor/compositor/tst_compositor.cpp
+++ b/tests/auto/compositor/compositor/tst_compositor.cpp
@@ -35,6 +35,7 @@
#include "qwaylandbufferref.h"
#include "qwaylandseat.h"
+#include <QtGui/QScreen>
#include <QtWaylandCompositor/QWaylandXdgShellV5>
#include <QtWaylandCompositor/QWaylandIviApplication>
#include <QtWaylandCompositor/QWaylandIviSurface>
@@ -58,6 +59,8 @@ private slots:
void singleClient();
void multipleClients();
void geometry();
+ void modes();
+ void sizeFollowsWindow();
void mapSurface();
void frameCallback();
@@ -202,12 +205,61 @@ void tst_WaylandCompositor::geometry()
TestCompositor compositor;
compositor.create();
- QRect geometry(0, 0, 4096, 3072);
- compositor.defaultOutput()->setGeometry(geometry);
+ QWaylandOutputMode mode(QSize(4096, 3072), 60000);
+ compositor.defaultOutput()->setPosition(QPoint(1024, 0));
+ compositor.defaultOutput()->addMode(mode, true);
+ compositor.defaultOutput()->setCurrentMode(mode);
MockClient client;
- QTRY_COMPARE(client.geometry, geometry);
+ QTRY_COMPARE(client.geometry, QRect(QPoint(1024, 0), QSize(4096, 3072)));
+ QTRY_COMPARE(client.resolution, QSize(4096, 3072));
+ QTRY_COMPARE(client.refreshRate, 60000);
+}
+
+void tst_WaylandCompositor::modes()
+{
+ TestCompositor compositor;
+ compositor.create();
+
+ // mode3 is current, mode4 is preferred
+ QWaylandOutputMode mode1(QSize(800, 600), 120000);
+ QWaylandOutputMode mode2(QSize(1024, 768), 100000);
+ QWaylandOutputMode mode3(QSize(1920, 1080), 60000);
+ QWaylandOutputMode mode4(QSize(2560, 1440), 59000);
+ compositor.defaultOutput()->addMode(mode1);
+ compositor.defaultOutput()->addMode(mode2, true);
+ compositor.defaultOutput()->addMode(mode3);
+ compositor.defaultOutput()->addMode(mode4, true);
+ compositor.defaultOutput()->setCurrentMode(mode3);
+
+ MockClient client;
+
+ QTRY_COMPARE(client.modes.size(), 4);
+ QTRY_COMPARE(client.currentMode, mode3);
+ QTRY_COMPARE(client.preferredMode, mode4);
+ QTRY_COMPARE(client.geometry, QRect(QPoint(0, 0), QSize(1920, 1080)));
+}
+
+void tst_WaylandCompositor::sizeFollowsWindow()
+{
+ TestCompositor compositor;
+
+ QWindow window;
+ window.resize(800, 600);
+
+ auto output = new QWaylandOutput(&compositor, &window);
+ output->setSizeFollowsWindow(true);
+
+ compositor.create();
+
+ QWaylandOutputMode mode(window.size(), qFloor(window.screen()->refreshRate() * 1000));
+
+ MockClient client;
+
+ QTRY_COMPARE(client.modes.size(), 1);
+ QTRY_COMPARE(client.currentMode, mode);
+ QTRY_COMPARE(client.preferredMode, mode);
}
void tst_WaylandCompositor::mapSurface()