summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJørgen Lind <jorgen.lind@theqtcompany.com>2015-09-07 11:08:29 +0200
committerJørgen Lind <jorgen.lind@theqtcompany.com>2015-09-10 08:20:22 +0000
commit762d384b806deb84072a5c7eb6b91afa1e150c1f (patch)
tree97affde5f9e57f4159edb903e2d84faa54d1f7ba
parentc0d77f8bb31d50b73543ef41875cdb4737aebb92 (diff)
Move the createDefaultSurface function to QWaylandCompositorPrivate
Its really not meant to be reimplemented by other classes than QWaylandCompositor or QWaylandQuickCompositor because of the createSurface signal. If someone really wants to use the virtual function then they can subclass the private Change-Id: Iad88fde3fc999ac18bdc57bd37864884865a962a Reviewed-by: Jørgen Lind <jorgen.lind@theqtcompany.com>
-rw-r--r--examples/wayland/qwindow-compositor/qwindowcompositor.cpp15
-rw-r--r--examples/wayland/qwindow-compositor/qwindowcompositor.h1
-rw-r--r--src/compositor/compositor_api/qwaylandcompositor.cpp27
-rw-r--r--src/compositor/compositor_api/qwaylandcompositor.h5
-rw-r--r--src/compositor/compositor_api/qwaylandcompositor_p.h1
-rw-r--r--src/compositor/compositor_api/qwaylandquickcompositor.cpp22
-rw-r--r--src/compositor/compositor_api/qwaylandquickcompositor.h4
7 files changed, 43 insertions, 32 deletions
diff --git a/examples/wayland/qwindow-compositor/qwindowcompositor.cpp b/examples/wayland/qwindow-compositor/qwindowcompositor.cpp
index fe2738f0..9f9a8e06 100644
--- a/examples/wayland/qwindow-compositor/qwindowcompositor.cpp
+++ b/examples/wayland/qwindow-compositor/qwindowcompositor.cpp
@@ -67,8 +67,8 @@ QT_BEGIN_NAMESPACE
class Surface : public QWaylandSurface
{
public:
- Surface()
- : QWaylandSurface()
+ Surface(QWaylandCompositor *compositor, QWaylandClient *client, uint id, int version)
+ : QWaylandSurface(compositor, client, id, version)
, shellSurface(Q_NULLPTR)
, extSurface(Q_NULLPTR)
, hasSentOnScreen(false)
@@ -151,6 +151,7 @@ void QWindowCompositor::create()
m_renderScheduler.setSingleShot(true);
connect(&m_renderScheduler, &QTimer::timeout, this, &QWindowCompositor::render);
+ connect(this, &QWaylandCompositor::createSurface, this, &QWindowCompositor::onCreateSurface);
connect(this, &QWaylandCompositor::surfaceCreated, this, &QWindowCompositor::onSurfaceCreated);
connect(defaultInputDevice(), &QWaylandInputDevice::cursorSurfaceRequest, this, &QWindowCompositor::adjustCursorSurface);
@@ -255,6 +256,11 @@ void QWindowCompositor::surfaceCommitted(QWaylandSurface *surface)
m_renderScheduler.start(0);
}
+void QWindowCompositor::onCreateSurface(QWaylandClient *client, uint id, int version)
+{
+ new Surface(this, client, id, version);
+}
+
void QWindowCompositor::onSurfaceCreated(QWaylandSurface *surface)
{
connect(surface, &QWaylandSurface::surfaceDestroyed, this, &QWindowCompositor::surfaceDestroyed);
@@ -319,11 +325,6 @@ void QWindowCompositor::adjustCursorSurface(QWaylandSurface *surface, int hotspo
m_cursorHotspotY = hotspotY;
}
-QWaylandSurface *QWindowCompositor::createDefaultSurfaceType()
-{
- return new Surface();
-}
-
QWaylandView *QWindowCompositor::viewAt(const QPointF &point, QPointF *local)
{
for (int i = m_visibleSurfaces.size() - 1; i >= 0; --i) {
diff --git a/examples/wayland/qwindow-compositor/qwindowcompositor.h b/examples/wayland/qwindow-compositor/qwindowcompositor.h
index 15ff3047..9e1eb080 100644
--- a/examples/wayland/qwindow-compositor/qwindowcompositor.h
+++ b/examples/wayland/qwindow-compositor/qwindowcompositor.h
@@ -76,6 +76,7 @@ private slots:
void surfacePosChanged();
void render();
+ void onCreateSurface(QWaylandClient *client, uint id, int version);
void onSurfaceCreated(QWaylandSurface *surface);
void onCreateShellSurface(QWaylandSurface *s, QWaylandClient *client, uint id);
diff --git a/src/compositor/compositor_api/qwaylandcompositor.cpp b/src/compositor/compositor_api/qwaylandcompositor.cpp
index 0a2b2871..6ccc8ee0 100644
--- a/src/compositor/compositor_api/qwaylandcompositor.cpp
+++ b/src/compositor/compositor_api/qwaylandcompositor.cpp
@@ -260,7 +260,7 @@ void QWaylandCompositorPrivate::compositor_create_surface(Resource *resource, ui
if (surfResource) {
surface = QWaylandSurface::fromResource(surfResource);
} else {
- surface = q->createDefaultSurfaceType();
+ surface = createDefaultSurface();
surface->initialize(q, client, id, resource->version());
}
Q_ASSERT(surface);
@@ -273,6 +273,16 @@ void QWaylandCompositorPrivate::compositor_create_region(Resource *resource, uin
new QtWayland::Region(resource->client(), id);
}
+/*!
+ \internal
+ Used to create a fallback QWaylandSurface when no surface was
+ created by emitting the QWaylandCompositor::createSurface signal.
+*/
+QWaylandSurface *QWaylandCompositorPrivate::createDefaultSurface()
+{
+ return new QWaylandSurface();
+}
+
void QWaylandCompositorPrivate::initializeHardwareIntegration()
{
@@ -348,6 +358,11 @@ QWaylandCompositor::QWaylandCompositor(QObject *parent)
{
}
+QWaylandCompositor::QWaylandCompositor(QWaylandCompositorPrivate &dptr, QObject *parent)
+ : QObject(dptr, parent)
+{
+}
+
QWaylandCompositor::~QWaylandCompositor()
{
}
@@ -507,16 +522,6 @@ void QWaylandCompositor::processWaylandEvents()
}
-/*!
- \internal
- Used to create a fallback QWaylandSurface when no surface was
- created by emitting the QWaylandCompositor::createSurface signal.
-*/
-QWaylandSurface *QWaylandCompositor::createDefaultSurfaceType()
-{
- return new QWaylandSurface();
-}
-
QWaylandInputDevice *QWaylandCompositor::createInputDevice()
{
return new QWaylandInputDevice(this);
diff --git a/src/compositor/compositor_api/qwaylandcompositor.h b/src/compositor/compositor_api/qwaylandcompositor.h
index d859ab34..f986c644 100644
--- a/src/compositor/compositor_api/qwaylandcompositor.h
+++ b/src/compositor/compositor_api/qwaylandcompositor.h
@@ -148,10 +148,7 @@ protected:
virtual QWaylandKeyboard *createKeyboardDevice(QWaylandInputDevice *inputDevice);
virtual QWaylandTouch *createTouchDevice(QWaylandInputDevice *inputDevice);
- QWaylandCompositor(QWaylandCompositorPrivate *dptr);
-
-private:
- virtual QWaylandSurface *createDefaultSurfaceType();
+ QWaylandCompositor(QWaylandCompositorPrivate &dptr, QObject *parent = 0);
};
QT_END_NAMESPACE
diff --git a/src/compositor/compositor_api/qwaylandcompositor_p.h b/src/compositor/compositor_api/qwaylandcompositor_p.h
index e6e3f584..1975bd87 100644
--- a/src/compositor/compositor_api/qwaylandcompositor_p.h
+++ b/src/compositor/compositor_api/qwaylandcompositor_p.h
@@ -96,6 +96,7 @@ protected:
void compositor_create_surface(Resource *resource, uint32_t id) Q_DECL_OVERRIDE;
void compositor_create_region(Resource *resource, uint32_t id) Q_DECL_OVERRIDE;
+ virtual QWaylandSurface *createDefaultSurface();
protected:
void initializeHardwareIntegration();
void initializeExtensions();
diff --git a/src/compositor/compositor_api/qwaylandquickcompositor.cpp b/src/compositor/compositor_api/qwaylandquickcompositor.cpp
index 8ebd1b6f..70afccb9 100644
--- a/src/compositor/compositor_api/qwaylandquickcompositor.cpp
+++ b/src/compositor/compositor_api/qwaylandquickcompositor.cpp
@@ -43,11 +43,26 @@
#include "qwaylandquickoutput.h"
#include "qwaylandquickitem.h"
#include "qwaylandoutput.h"
+#include <QtCompositor/private/qwaylandcompositor_p.h>
QT_BEGIN_NAMESPACE
+class QWaylandQuickCompositorPrivate : public QWaylandCompositorPrivate
+{
+public:
+ QWaylandQuickCompositorPrivate(QWaylandCompositor *compositor)
+ : QWaylandCompositorPrivate(compositor)
+ {
+ }
+protected:
+ QWaylandSurface *createDefaultSurface() Q_DECL_OVERRIDE
+ {
+ return new QWaylandQuickSurface();
+ }
+};
+
QWaylandQuickCompositor::QWaylandQuickCompositor(QObject *parent)
- : QWaylandCompositor(parent)
+ : QWaylandCompositor(*new QWaylandQuickCompositorPrivate(this), parent)
{
}
@@ -57,11 +72,6 @@ void QWaylandQuickCompositor::create()
}
-QWaylandSurface *QWaylandQuickCompositor::createDefaultSurfaceType()
-{
- return new QWaylandQuickSurface();
-}
-
void QWaylandQuickCompositor::classBegin()
{
}
diff --git a/src/compositor/compositor_api/qwaylandquickcompositor.h b/src/compositor/compositor_api/qwaylandquickcompositor.h
index 21778d2c..eff0b2f3 100644
--- a/src/compositor/compositor_api/qwaylandquickcompositor.h
+++ b/src/compositor/compositor_api/qwaylandquickcompositor.h
@@ -57,10 +57,6 @@ public:
protected:
void classBegin() Q_DECL_OVERRIDE;
void componentComplete() Q_DECL_OVERRIDE;
-
-private:
-
- QWaylandSurface *createDefaultSurfaceType() Q_DECL_OVERRIDE;
};
QT_END_NAMESPACE