summaryrefslogtreecommitdiffstats
path: root/examples
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 /examples
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 'examples')
-rw-r--r--examples/wayland/custom-extension/compositor/qml/Screen.qml1
-rw-r--r--examples/wayland/minimal-cpp/compositor.cpp5
-rw-r--r--examples/wayland/minimal-qml/main.qml1
-rw-r--r--examples/wayland/multi-output/qml/GridScreen.qml1
-rw-r--r--examples/wayland/multi-output/qml/ShellScreen.qml1
-rw-r--r--examples/wayland/pure-qml/qml/Screen.qml1
-rw-r--r--examples/wayland/qwindow-compositor/compositor.cpp5
-rw-r--r--examples/wayland/server-buffer/compositor/main.cpp9
-rw-r--r--examples/wayland/spanning-screens/main.qml2
9 files changed, 16 insertions, 10 deletions
diff --git a/examples/wayland/custom-extension/compositor/qml/Screen.qml b/examples/wayland/custom-extension/compositor/qml/Screen.qml
index a6d5fbc7c..7a87951b7 100644
--- a/examples/wayland/custom-extension/compositor/qml/Screen.qml
+++ b/examples/wayland/custom-extension/compositor/qml/Screen.qml
@@ -45,6 +45,7 @@ import QtWayland.Compositor 1.0
WaylandOutput {
id: output
property alias surfaceArea: background
+ sizeFollowsWindow: true
window: Window {
id: screen
diff --git a/examples/wayland/minimal-cpp/compositor.cpp b/examples/wayland/minimal-cpp/compositor.cpp
index 5e46895c4..5a6249c9a 100644
--- a/examples/wayland/minimal-cpp/compositor.cpp
+++ b/examples/wayland/minimal-cpp/compositor.cpp
@@ -67,8 +67,11 @@ Compositor::~Compositor()
void Compositor::create()
{
- new QWaylandOutput(this, m_window);
+ QWaylandOutput *output = new QWaylandOutput(this, m_window);
+ QWaylandOutputMode mode(QSize(800, 600), 60000);
+ output->addMode(mode, true);
QWaylandCompositor::create();
+ output->setCurrentMode(mode);
connect(this, &QWaylandCompositor::surfaceCreated, this, &Compositor::onSurfaceCreated);
}
diff --git a/examples/wayland/minimal-qml/main.qml b/examples/wayland/minimal-qml/main.qml
index 3d6c3b7bb..d44d0c6a1 100644
--- a/examples/wayland/minimal-qml/main.qml
+++ b/examples/wayland/minimal-qml/main.qml
@@ -47,6 +47,7 @@ WaylandCompositor {
// The output defines the screen.
WaylandOutput {
compositor: wlcompositor
+ sizeFollowsWindow: true
window: Window {
width: 1024
height: 768
diff --git a/examples/wayland/multi-output/qml/GridScreen.qml b/examples/wayland/multi-output/qml/GridScreen.qml
index 3dab99d0a..2a48cf169 100644
--- a/examples/wayland/multi-output/qml/GridScreen.qml
+++ b/examples/wayland/multi-output/qml/GridScreen.qml
@@ -46,6 +46,7 @@ WaylandOutput {
id: output
property alias gridSurfaces: listModel
+ sizeFollowsWindow: true
window: Window {
width: 1024
height: 760
diff --git a/examples/wayland/multi-output/qml/ShellScreen.qml b/examples/wayland/multi-output/qml/ShellScreen.qml
index 9a6122118..7b8a48ff3 100644
--- a/examples/wayland/multi-output/qml/ShellScreen.qml
+++ b/examples/wayland/multi-output/qml/ShellScreen.qml
@@ -46,6 +46,7 @@ WaylandOutput {
id: output
property alias surfaceArea: background
+ sizeFollowsWindow: true
window: Window {
width: 1024
height: 760
diff --git a/examples/wayland/pure-qml/qml/Screen.qml b/examples/wayland/pure-qml/qml/Screen.qml
index 0920a8b95..a12f387fd 100644
--- a/examples/wayland/pure-qml/qml/Screen.qml
+++ b/examples/wayland/pure-qml/qml/Screen.qml
@@ -45,6 +45,7 @@ import QtWayland.Compositor 1.0
WaylandOutput {
id: output
property alias surfaceArea: background
+ sizeFollowsWindow: true
window: Window {
id: screen
diff --git a/examples/wayland/qwindow-compositor/compositor.cpp b/examples/wayland/qwindow-compositor/compositor.cpp
index a55bb3b72..4878c373e 100644
--- a/examples/wayland/qwindow-compositor/compositor.cpp
+++ b/examples/wayland/qwindow-compositor/compositor.cpp
@@ -139,8 +139,11 @@ Compositor::~Compositor()
void Compositor::create()
{
- new QWaylandOutput(this, m_window);
+ QWaylandOutput *output = new QWaylandOutput(this, m_window);
+ QWaylandOutputMode mode(QSize(800, 600), 60000);
+ output->addMode(mode, true);
QWaylandCompositor::create();
+ output->setCurrentMode(mode);
connect(this, &QWaylandCompositor::surfaceCreated, this, &Compositor::onSurfaceCreated);
connect(defaultSeat(), &QWaylandSeat::cursorSurfaceRequest, this, &Compositor::adjustCursorSurface);
diff --git a/examples/wayland/server-buffer/compositor/main.cpp b/examples/wayland/server-buffer/compositor/main.cpp
index 9c5ee42a1..8c43ce5c5 100644
--- a/examples/wayland/server-buffer/compositor/main.cpp
+++ b/examples/wayland/server-buffer/compositor/main.cpp
@@ -86,15 +86,13 @@ public:
m_view.setColor(Qt::black);
m_view.create();
m_output = new QWaylandQuickOutput(this, &m_view);
+ m_output->setSizeFollowsWindow(true);
connect(&m_view, &QQuickView::afterRendering, this, &QmlCompositor::sendCallbacks);
connect(&m_view, &QQuickView::sceneGraphInitialized, this, &QmlCompositor::initiateServerBuffer,Qt::DirectConnection);
connect(this, &QmlCompositor::serverBuffersCreated, this, &QmlCompositor::createServerBufferItems);
- connect(&m_view, &QWindow::widthChanged, this, &QmlCompositor::sizeAdjusted);
- connect(&m_view, &QWindow::heightChanged, this, &QmlCompositor::sizeAdjusted);
-
connect(this, SIGNAL(windowAdded(QVariant)), m_view.rootObject(), SLOT(windowAdded(QVariant)));
connect(this, SIGNAL(windowResized(QVariant)), m_view.rootObject(), SLOT(windowResized(QVariant)));
connect(this, SIGNAL(serverBufferItemCreated(QVariant)), m_view.rootObject(), SLOT(serverBufferItemCreated(QVariant)));
@@ -211,11 +209,6 @@ private slots:
}
}
protected:
- void sizeAdjusted()
- {
- defaultOutput()->setGeometry(QRect(QPoint(0, 0), m_view.size()));
- }
-
void onSurfaceCreated(QWaylandSurface *surface) {
QWaylandQuickItem *item = new QWaylandQuickItem();
item->setSurface(surface);
diff --git a/examples/wayland/spanning-screens/main.qml b/examples/wayland/spanning-screens/main.qml
index 00bf517fc..32dc11f33 100644
--- a/examples/wayland/spanning-screens/main.qml
+++ b/examples/wayland/spanning-screens/main.qml
@@ -47,6 +47,7 @@ WaylandCompositor {
WaylandOutput {
compositor: wlcompositor
+ sizeFollowsWindow: true
window: Window {
id: topSurfaceArea
width: 1024
@@ -59,6 +60,7 @@ WaylandCompositor {
WaylandOutput {
compositor: wlcompositor
+ sizeFollowsWindow: true
window: Window {
id: bottomSurfaceArea
width: 1024