summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohan Klokkhammer Helsing <johan.helsing@qt.io>2016-11-24 13:52:53 +0100
committerPaul Olav Tvete <paul.tvete@qt.io>2016-12-06 08:42:54 +0000
commitac505a6b8b6e19d1d8ac8c8f0bcb4aab003b0060 (patch)
tree8232d71a0d81b8a640465f71e1db4bb2876ecc81
parente2f856d9da896c202d98b179b9482fe7e7b57222 (diff)
Try to find compositor among parents for QWaylandQuickOutput
And simplify the minimal-qml and ivi-compositor examples Change-Id: Ic445349c9d7845813b6700414464a688aac40e73 Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
-rw-r--r--examples/wayland/ivi-compositor/main.qml2
-rw-r--r--examples/wayland/minimal-qml/main.qml2
-rw-r--r--src/compositor/compositor_api/qwaylandquickoutput.cpp16
-rw-r--r--src/compositor/compositor_api/qwaylandquickoutput.h5
4 files changed, 20 insertions, 5 deletions
diff --git a/examples/wayland/ivi-compositor/main.qml b/examples/wayland/ivi-compositor/main.qml
index 6535296b6..1f2420bf9 100644
--- a/examples/wayland/ivi-compositor/main.qml
+++ b/examples/wayland/ivi-compositor/main.qml
@@ -43,9 +43,7 @@ import QtWayland.Compositor 1.0
import QtQuick.Window 2.2
WaylandCompositor {
- id: wlcompositor
WaylandOutput {
- compositor: wlcompositor
sizeFollowsWindow: true
window: Window {
width: 1024
diff --git a/examples/wayland/minimal-qml/main.qml b/examples/wayland/minimal-qml/main.qml
index d44d0c6a1..732e2ccad 100644
--- a/examples/wayland/minimal-qml/main.qml
+++ b/examples/wayland/minimal-qml/main.qml
@@ -43,10 +43,8 @@ import QtQuick.Window 2.2
import QtWayland.Compositor 1.0
WaylandCompositor {
- id: wlcompositor
// The output defines the screen.
WaylandOutput {
- compositor: wlcompositor
sizeFollowsWindow: true
window: Window {
width: 1024
diff --git a/src/compositor/compositor_api/qwaylandquickoutput.cpp b/src/compositor/compositor_api/qwaylandquickoutput.cpp
index 0e25362fc..af21bd0cc 100644
--- a/src/compositor/compositor_api/qwaylandquickoutput.cpp
+++ b/src/compositor/compositor_api/qwaylandquickoutput.cpp
@@ -72,6 +72,22 @@ void QWaylandQuickOutput::initialize()
this, &QWaylandQuickOutput::doFrameCallbacks);
}
+void QWaylandQuickOutput::classBegin()
+{
+}
+
+void QWaylandQuickOutput::componentComplete()
+{
+ if (!compositor()) {
+ for (QObject *p = parent(); p != nullptr; p = p->parent()) {
+ if (auto c = qobject_cast<QWaylandCompositor *>(p)) {
+ setCompositor(c);
+ break;
+ }
+ }
+ }
+}
+
void QWaylandQuickOutput::update()
{
if (!m_updateScheduled) {
diff --git a/src/compositor/compositor_api/qwaylandquickoutput.h b/src/compositor/compositor_api/qwaylandquickoutput.h
index 2cef03282..37a47b844 100644
--- a/src/compositor/compositor_api/qwaylandquickoutput.h
+++ b/src/compositor/compositor_api/qwaylandquickoutput.h
@@ -46,8 +46,9 @@ QT_BEGIN_NAMESPACE
class QWaylandQuickCompositor;
class QQuickWindow;
-class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandQuickOutput : public QWaylandOutput
+class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandQuickOutput : public QWaylandOutput, public QQmlParserStatus
{
+ Q_INTERFACES(QQmlParserStatus)
Q_OBJECT
Q_PROPERTY(bool automaticFrameCallback READ automaticFrameCallback WRITE setAutomaticFrameCallback NOTIFY automaticFrameCallbackChanged)
public:
@@ -69,6 +70,8 @@ Q_SIGNALS:
protected:
void initialize() Q_DECL_OVERRIDE;
+ void classBegin() override;
+ void componentComplete() override;
private:
void doFrameCallbacks();