summaryrefslogtreecommitdiffstats
path: root/src/compositor/compositor_api/qwaylandcompositor.cpp
diff options
context:
space:
mode:
authorJørgen Lind <jorgen.lind@theqtcompany.com>2015-07-29 13:51:25 +0200
committerJørgen Lind <jorgen.lind@theqtcompany.com>2015-08-28 13:09:41 +0200
commit42c1bf3208e75b131aac2923da397de054cbbe13 (patch)
tree3900195214c0eafffc0ae411d2ed39de8747f5bf /src/compositor/compositor_api/qwaylandcompositor.cpp
parent7c65f7e9618a104b1304ec1a7a1cf7ee31527c87 (diff)
Make QWaylandCompositor inherit QObject
And remove the constructor arguments, and just having parent as a constructor argument. This requires QWaylandCompositor to have a create semantic familiar from QWindow and QOpenGLContext. On create the native wayland socket is created and initialized. Also the virtual functions surfaceCreated and surfaceAboutToBeDestroyed have been converted to signals, removing the need to subclass QWaylandCompositor Examples have been changed to avoid having two super classes inheriting QObject. This is done by either making the QWindow subclass a member or making the QWaylandCompositor a member. Change-Id: I317d37e2adca15bfe4e1904e20ab0d83943b2d45
Diffstat (limited to 'src/compositor/compositor_api/qwaylandcompositor.cpp')
-rw-r--r--src/compositor/compositor_api/qwaylandcompositor.cpp62
1 files changed, 40 insertions, 22 deletions
diff --git a/src/compositor/compositor_api/qwaylandcompositor.cpp b/src/compositor/compositor_api/qwaylandcompositor.cpp
index 3a269ce30..112d49923 100644
--- a/src/compositor/compositor_api/qwaylandcompositor.cpp
+++ b/src/compositor/compositor_api/qwaylandcompositor.cpp
@@ -61,24 +61,54 @@
QT_BEGIN_NAMESPACE
-QWaylandCompositor::QWaylandCompositor(const char *socketName, ExtensionFlags extensions)
- : m_compositor(new QtWayland::Compositor(this, extensions))
+QWaylandCompositor::QWaylandCompositor(QObject *parent)
+ : QObject(parent)
+ , m_compositor(new QtWayland::Compositor(this))
{
- m_compositor->m_socket_name = socketName;
- m_compositor->init();
}
-QWaylandCompositor::QWaylandCompositor(const char *socketName, QtWayland::Compositor *dptr)
- : m_compositor(dptr)
+QWaylandCompositor::~QWaylandCompositor()
+{
+ qDeleteAll(m_compositor->m_globals);
+ delete m_compositor;
+}
+
+void QWaylandCompositor::create()
{
- m_compositor->m_socket_name = socketName;
m_compositor->init();
}
-QWaylandCompositor::~QWaylandCompositor()
+bool QWaylandCompositor::isCreated() const
{
- qDeleteAll(m_compositor->m_globals);
- delete m_compositor;
+ return m_compositor->m_initialized;
+}
+
+void QWaylandCompositor::setSocketName(const QByteArray &name)
+{
+ if (m_compositor->m_initialized) {
+ qWarning("%s: It is not supported to alter the compostors socket name after the compositor is initialized\n", Q_FUNC_INFO);
+ return;
+ }
+ m_compositor->m_socket_name = name;
+}
+
+QByteArray QWaylandCompositor::socketName() const
+{
+ return m_compositor->m_socket_name;
+}
+
+void QWaylandCompositor::setExtensionFlags(QWaylandCompositor::ExtensionFlags flags)
+{
+ if (m_compositor->m_initialized) {
+ qWarning("%s: It is not supported to alter the extension flags after the compositor is initialized\n", Q_FUNC_INFO);
+ return;
+ }
+ m_compositor->m_extensions = flags;
+}
+
+QWaylandCompositor::ExtensionFlags QWaylandCompositor::extensionFlags() const
+{
+ return m_compositor->extensions();
}
void QWaylandCompositor::addGlobalInterface(QWaylandGlobalInterface *interface)
@@ -172,11 +202,6 @@ void QWaylandCompositor::cleanupGraphicsResources()
m_compositor->cleanupGraphicsResources();
}
-void QWaylandCompositor::surfaceAboutToBeDestroyed(QWaylandSurface *surface)
-{
- Q_UNUSED(surface);
-}
-
QWaylandSurfaceView *QWaylandCompositor::pickView(const QPointF &globalPosition) const
{
Q_FOREACH (QWaylandOutput *output, outputs()) {
@@ -240,13 +265,6 @@ void QWaylandCompositor::setClientFullScreenHint(bool value)
m_compositor->setClientFullScreenHint(value);
}
-const char *QWaylandCompositor::socketName() const
-{
- if (m_compositor->m_socket_name.isEmpty())
- return 0;
- return m_compositor->m_socket_name.constData();
-}
-
#if QT_DEPRECATED_SINCE(5, 5)
/*!
Set the screen orientation based on accelerometer data or similar.