summaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
authorJørgen Lind <jorgen.lind@theqtcompany.com>2015-08-27 12:29:52 +0200
committerJørgen Lind <jorgen.lind@theqtcompany.com>2015-08-28 13:10:33 +0200
commitc45c1e13c95426116b2b9cc945939bb0b9598079 (patch)
treeac0b71232e0899b757affa82c19f0086e2ef5098 /examples
parentc9500b6eff3dc8fbcc6e9fc569b2e246541a2a05 (diff)
Make it possible to create the shell surface from qml
Diffstat (limited to 'examples')
-rw-r--r--examples/wayland/pure-qml/qml/main.qml23
-rw-r--r--examples/wayland/qwindow-compositor/qwindowcompositor.cpp15
-rw-r--r--examples/wayland/qwindow-compositor/qwindowcompositor.h6
3 files changed, 27 insertions, 17 deletions
diff --git a/examples/wayland/pure-qml/qml/main.qml b/examples/wayland/pure-qml/qml/main.qml
index 30c7a63bf..642a60325 100644
--- a/examples/wayland/pure-qml/qml/main.qml
+++ b/examples/wayland/pure-qml/qml/main.qml
@@ -58,11 +58,17 @@ WaylandCompositor {
extensions: [
DefaultShell {
+ id: defaultShell
- onShellSurfaceCreated: {
- var item = chromeComponent.createObject(primarySurfacesArea);
- item.surface = surface;
- shellSurface.view = item.view;
+ Component {
+ id: shellSurfaceComponent
+ DefaultShellSurface { }
+ }
+
+ onCreateShellSurface: {
+ var item = chromeComponent.createObject(primarySurfacesArea, { "surface": surface } );
+ var shellSurface = shellSurfaceComponent.createObject();
+ shellSurface.initialize(defaultShell, surface, item.view, client, id);
}
Component.onCompleted: {
@@ -71,14 +77,15 @@ WaylandCompositor {
}
]
- Component.onCompleted: {
- addScreen();
- }
-
function addScreen() {
var screen = screenComponent.createObject(0, { "compositor" : compositor } );
primarySurfacesArea = screen.surfacesArea;
var output = compositor.primaryOutputSpace.addOutputWindow(screen, "", "");
output.automaticFrameCallbacks = true;
}
+
+ Component.onCompleted: {
+ addScreen();
+ }
+
}
diff --git a/examples/wayland/qwindow-compositor/qwindowcompositor.cpp b/examples/wayland/qwindow-compositor/qwindowcompositor.cpp
index 152902c1c..fad92510a 100644
--- a/examples/wayland/qwindow-compositor/qwindowcompositor.cpp
+++ b/examples/wayland/qwindow-compositor/qwindowcompositor.cpp
@@ -121,6 +121,7 @@ QWindowCompositor::QWindowCompositor(CompositorWindow *window)
, m_cursorHotspotX(0)
, m_cursorHotspotY(0)
, m_modifiers(Qt::NoModifier)
+ , m_shell(new QWaylandShell(this))
{
m_window->makeCurrent();
@@ -130,8 +131,11 @@ QWindowCompositor::QWindowCompositor(CompositorWindow *window)
QOpenGLFunctions *functions = m_window->context()->functions();
functions->glGenFramebuffers(1, &m_surface_fbo);
- QWaylandShell *shell = new QWaylandShell(this);
- connect(shell, &QWaylandShell::shellSurfaceCreated, this, &QWindowCompositor::onShellSurfaceCreated);
+ connect(m_shell, &QWaylandShell::createShellSurface, this, &QWindowCompositor::onCreateShellSurface);
+
+ QtWayland::SurfaceExtensionGlobal *extSurfGlob = new QtWayland::SurfaceExtensionGlobal(this);
+ connect(extSurfGlob, &QtWayland::SurfaceExtensionGlobal::extendedSurfaceReady, this, &QWindowCompositor::extendedSurfaceCreated);
+
}
QWindowCompositor::~QWindowCompositor()
@@ -150,9 +154,6 @@ void QWindowCompositor::create()
connect(this, &QWaylandCompositor::surfaceCreated, this, &QWindowCompositor::onSurfaceCreated);
connect(this, &QWaylandCompositor::currentCurserSurfaceRequest, this, &QWindowCompositor::adjustCursorSurface);
- QtWayland::SurfaceExtensionGlobal *extSurfGlob = QtWayland::SurfaceExtensionGlobal::findIn(this);
- connect(extSurfGlob, &QtWayland::SurfaceExtensionGlobal::extendedSurfaceReady, this, &QWindowCompositor::extendedSurfaceCreated);
-
m_window->installEventFilter(this);
setRetainedSelectionEnabled(true);
@@ -261,13 +262,13 @@ void QWindowCompositor::onSurfaceCreated(QWaylandSurface *surface)
connect(surface, &QWaylandSurface::redraw, this, &QWindowCompositor::surfaceCommittedSlot);
}
-void QWindowCompositor::onShellSurfaceCreated(QWaylandSurface *s, QWaylandShellSurface *shellSurface)
+void QWindowCompositor::onCreateShellSurface(QWaylandSurface *s, QWaylandClient *client, uint id)
{
Surface *surface = static_cast<Surface *>(s);
SurfaceView *newView = new SurfaceView();
newView->setSurface(surface);
newView->setOutput(output(m_window));
- shellSurface->setView(newView);
+ QWaylandShellSurface *shellSurface = new QWaylandShellSurface(m_shell, surface, newView, client, id);
surface->shellSurface = shellSurface;
m_renderScheduler.start(0);
}
diff --git a/examples/wayland/qwindow-compositor/qwindowcompositor.h b/examples/wayland/qwindow-compositor/qwindowcompositor.h
index a65f25621..e4c4cbe66 100644
--- a/examples/wayland/qwindow-compositor/qwindowcompositor.h
+++ b/examples/wayland/qwindow-compositor/qwindowcompositor.h
@@ -58,7 +58,7 @@ namespace QtWayland {
}
class QWaylandView;
-class QWaylandShellSurface;
+class QWaylandShell;
class QOpenGLTexture;
class QWindowCompositor : public QWaylandCompositor
@@ -77,7 +77,8 @@ private slots:
void render();
void onSurfaceCreated(QWaylandSurface *surface);
- void onShellSurfaceCreated(QWaylandSurface *surface, QWaylandShellSurface *shellSurface);
+ void onCreateShellSurface(QWaylandSurface *s, QWaylandClient *client, uint id);
+
protected:
QWaylandSurface *createSurface(QWaylandClient *client, quint32 id, int version) Q_DECL_OVERRIDE;
void surfaceCommitted(QWaylandSurface *surface);
@@ -120,6 +121,7 @@ private:
int m_cursorHotspotY;
Qt::KeyboardModifiers m_modifiers;
+ QWaylandShell *m_shell;
};
QT_END_NAMESPACE