From 44f4395879ec9464c0a6dd3a7635fad05ad14118 Mon Sep 17 00:00:00 2001 From: Johan Klokkhammer Helsing Date: Mon, 11 Apr 2016 12:51:21 +0200 Subject: Simplify ShellSurfaceItem creation Use onShellSurfaceCreated instead of onCreateShellSurface. A QWaylandWlShellSurface is no longer created in QWaylandWlShellSurfaceItem::componentComplete Change-Id: I7a0dbbacddc17ab32ed0e4d16e717fcefb221947 Reviewed-by: Pier Luigi Fiorini Reviewed-by: Erik Larsson --- examples/wayland/custom-extension/compositor/qml/main.qml | 5 ++--- examples/wayland/multi-output/qml/main.qml | 7 +++---- examples/wayland/pure-qml/qml/main.qml | 6 ++---- .../extensions/qwaylandquickwlshellsurfaceitem.cpp | 13 +------------ src/compositor/extensions/qwaylandquickwlshellsurfaceitem.h | 2 -- 5 files changed, 8 insertions(+), 25 deletions(-) diff --git a/examples/wayland/custom-extension/compositor/qml/main.qml b/examples/wayland/custom-extension/compositor/qml/main.qml index 54d0707ac..dcba2bb70 100644 --- a/examples/wayland/custom-extension/compositor/qml/main.qml +++ b/examples/wayland/custom-extension/compositor/qml/main.qml @@ -78,9 +78,8 @@ WaylandCompositor { WlShell { id: defaultShell - onCreateShellSurface: { - var item = chromeComponent.createObject(defaultOutput.surfaceArea, { "surface": surface } ); - item.shellSurface.initialize(defaultShell, surface, resource); + onShellSurfaceCreated: { + var item = chromeComponent.createObject(defaultOutput.surfaceArea, { "shellSurface": shellSurface } ); lastItem = item; } diff --git a/examples/wayland/multi-output/qml/main.qml b/examples/wayland/multi-output/qml/main.qml index 9e11d3613..ccb3d418b 100644 --- a/examples/wayland/multi-output/qml/main.qml +++ b/examples/wayland/multi-output/qml/main.qml @@ -85,10 +85,9 @@ WaylandCompositor { WlShell { id: defaultShell - onCreateShellSurface: { - var item = chromeComponent.createObject(defaultOutput.surfaceArea, { "surface": surface } ); - item.shellSurface.initialize(defaultShell, surface, resource); - surface.activated.connect(item.raise); + onShellSurfaceCreated: { + var item = chromeComponent.createObject(defaultOutput.surfaceArea, { "shellSurface": shellSurface } ); + item.surface.activated.connect(item.raise); } Component.onCompleted: { diff --git a/examples/wayland/pure-qml/qml/main.qml b/examples/wayland/pure-qml/qml/main.qml index d706945e2..a8a3985de 100644 --- a/examples/wayland/pure-qml/qml/main.qml +++ b/examples/wayland/pure-qml/qml/main.qml @@ -66,10 +66,8 @@ WaylandCompositor { WlShell { id: defaultShell - - onCreateShellSurface: { - var item = chromeComponent.createObject(defaultOutput.surfaceArea, { "surface": surface } ); - item.shellSurface.initialize(defaultShell, surface, resource); + onShellSurfaceCreated: { + chromeComponent.createObject(defaultOutput.surfaceArea, { "shellSurface": shellSurface } ); } Component.onCompleted: { diff --git a/src/compositor/extensions/qwaylandquickwlshellsurfaceitem.cpp b/src/compositor/extensions/qwaylandquickwlshellsurfaceitem.cpp index fc6d856d8..a385e5e4e 100644 --- a/src/compositor/extensions/qwaylandquickwlshellsurfaceitem.cpp +++ b/src/compositor/extensions/qwaylandquickwlshellsurfaceitem.cpp @@ -110,6 +110,7 @@ void QWaylandQuickWlShellSurfaceItem::setShellSurface(QWaylandWlShellSurface *sh connect(d->shellSurface, &QWaylandWlShellSurface::startMove, this, &QWaylandQuickWlShellSurfaceItem::handleStartMove); connect(d->shellSurface, &QWaylandWlShellSurface::startResize, this, &QWaylandQuickWlShellSurfaceItem::handleStartResize); } + setSurface(shellSurface ? shellSurface->surface() : nullptr); emit shellSurfaceChanged(); } @@ -226,16 +227,4 @@ void QWaylandQuickWlShellSurfaceItem::surfaceChangedEvent(QWaylandSurface *newSu connect(newSurface, &QWaylandSurface::offsetForNextFrame, this, &QWaylandQuickWlShellSurfaceItem::adjustOffsetForNextFrame); } -/*! - * \internal - */ -void QWaylandQuickWlShellSurfaceItem::componentComplete() -{ - Q_D(QWaylandQuickWlShellSurfaceItem); - if (!d->shellSurface) - setShellSurface(new QWaylandWlShellSurface()); - - QWaylandQuickItem::componentComplete(); -} - QT_END_NAMESPACE diff --git a/src/compositor/extensions/qwaylandquickwlshellsurfaceitem.h b/src/compositor/extensions/qwaylandquickwlshellsurfaceitem.h index 626926f85..7f32c9f39 100644 --- a/src/compositor/extensions/qwaylandquickwlshellsurfaceitem.h +++ b/src/compositor/extensions/qwaylandquickwlshellsurfaceitem.h @@ -77,8 +77,6 @@ protected: void mouseReleaseEvent(QMouseEvent *event) Q_DECL_OVERRIDE; void surfaceChangedEvent(QWaylandSurface *newSurface, QWaylandSurface *oldSurface) Q_DECL_OVERRIDE; - - void componentComplete() Q_DECL_OVERRIDE; }; QT_END_NAMESPACE -- cgit v1.2.3