on xenial help sign in
Live surfaces & sessions
commitbd9428ee3323948631f16d06f525100df47c9e5a authorNick Dedekind <nick.dedekind@canonical.com> dateFri 29 Aug 2014, 15:50 (12 years ago) parent4979650
12 files changed+61−26
qml/Stages/Animations/SwipeFromBottomAnimation.qml+1−1 qml/Stages/SessionContainer.qml+7−4 qml/Stages/SurfaceContainer.qml+3−10 tests/mocks/Unity/Application/ApplicationTestInterface.cpp+13−4 tests/mocks/Unity/Application/ApplicationTestInterface.h+1 tests/mocks/Unity/Application/MirSurfaceItem.cpp+9 tests/mocks/Unity/Application/MirSurfaceItem.h+5−3 tests/mocks/Unity/Application/Session.cpp+9 tests/mocks/Unity/Application/Session.h+6−1 tests/mocks/Unity/Application/SessionManager.cpp+2 tests/mocks/Unity/Application/SurfaceManager.cpp+2 tests/qmltests/Stages/RecursingChildSessionControl.qml+3−3
qml/Stages/Animations/SwipeFromBottomAnimation.qml+1−1
@@ -27,7 +27,7 @@ BaseSessionAnimation {
2727 AnchorAnimation { easing: UbuntuAnimation.StandardEasing; duration: UbuntuAnimation.BriskDuration }
2828 PropertyAction { target: surfaceContainer; property: "visible"; value: !sessionContainer.removing }
2929 PropertyAction { target: sessionContainer; property: "clip"; value: false }
30− ScriptAction { script: { if (sessionContainer.removing) sessionContainer.session.release(); } }
30+ ScriptAction { script: { sessionContainer.session.release(); } }
3131 }
3232 ]
3333
qml/Stages/SessionContainer.qml+7−4
@@ -22,7 +22,6 @@ Item {
2222 objectName: "sessionContainer"
2323 property QtObject session
2424 property var childSessions: session ? session.childSessions : 0
25− property bool removing: false
2625 property alias surface: _surfaceContainer.surface
2726 property bool interactive: true
2827
@@ -58,6 +57,9 @@ Item {
5857 onLoaded: {
5958 item.session = modelData;
6059 item.interactive = Qt.binding(function() { return root.interactive; } );
60+ if (!modelData.live) {
61+ modelData.release();
62+ }
6163 if (modelData.surface) {
6264 item.animateIn(swipeFromBottom);
6365 }
@@ -70,9 +72,10 @@ Item {
7072 item.animateIn();
7173 }
7274 }
73− onRemoved: {
74− item.removing = true;
75− item.animateOut();
75+ onLiveChanged: {
76+ if (!modelData.live) {
77+ item.animateOut();
78+ }
7679 }
7780 }
7881 }
qml/Stages/SurfaceContainer.qml+3−10
@@ -22,12 +22,9 @@ Item {
2222 id: root
2323 objectName: "surfaceContainer"
2424 property Item surface: null
25− property bool surfaceRemoved: false
2625
2726 onSurfaceChanged: {
2827 if (surface) {
29− surfaceRemoved = false;
30− surface.removed.connect(onRemoved);
3128 surface.parent = root;
3229 }
3330 }
@@ -36,19 +33,15 @@ Item {
3633 property: "anchors.fill"; value: root
3734 }
3835
39− function onRemoved() {
40− surfaceRemoved = true;
41− }
42−
4336 states: [
4437 State {
45− name: "removed"
46− when: surfaceRemoved
38+ name: "zombie"
39+ when: surface && !surface.live
4740 }
4841 ]
4942 transitions: [
5043 Transition {
51− from: ""; to: "removed"
44+ from: ""; to: "zombie"
5245 SequentialAnimation {
5346 UbuntuNumberAnimation { target: surface; property: "opacity"; to: 0.0
5447 duration: UbuntuAnimation.BriskDuration }
tests/mocks/Unity/Application/ApplicationTestInterface.cpp+13−4
@@ -56,7 +56,18 @@ Session* ApplicationTestInterface::addChildSession(Session* existingSession, con
5656
5757void ApplicationTestInterface::removeSession(Session* existingSession)
5858{
59− Q_EMIT existingSession->removed();
59+ qDebug() << "ApplicationTestInterface::removeSession - " << existingSession;
60+
61+ if (existingSession)
62+ existingSession->setLive(false);
63+}
64+
65+void ApplicationTestInterface::removeSurface(MirSurfaceItem* existingSurface)
66+{
67+ qDebug() << "ApplicationTestInterface::removeSurface - " << existingSurface;
68+
69+ if (existingSurface)
70+ existingSurface->setLive(false);
6071}
6172
6273quint32 ApplicationTestInterface::addChildSession(const QString& appId, quint32 existingSessionId, const QString& surfaceImage)
@@ -97,12 +108,10 @@ quint32 ApplicationTestInterface::addChildSession(const QString& appId, quint32
97108
98109void ApplicationTestInterface::removeSession(quint32 sessionId)
99110{
100− qDebug() << "ApplicationTestInterface::removeSession - " << sessionId;
101−
102111 if (!m_childSessions.contains(sessionId)) {
103112 qDebug() << "ApplicationTestInterface::removeSession - No added session for " << sessionId;
104113 return;
105114 }
106115 Session* session = m_childSessions.take(sessionId);
107− Q_EMIT session->removed();
116+ removeSession(session);
108117}
tests/mocks/Unity/Application/ApplicationTestInterface.h+1
@@ -32,6 +32,7 @@ public:
3232
3333 Q_INVOKABLE Session* addChildSession(Session* existingSession, const QString& surfaceImage);
3434 Q_INVOKABLE void removeSession(Session* existingSession);
35+ Q_INVOKABLE void removeSurface(MirSurfaceItem* existingSurface);
3536
3637public Q_SLOTS:
3738 quint32 addChildSession(const QString& appId, quint32 existingSessionId, const QString& surfaceImage);
tests/mocks/Unity/Application/MirSurfaceItem.cpp+9
@@ -38,6 +38,7 @@ MirSurfaceItem::MirSurfaceItem(const QString& name,
3838 , m_name(name)
3939 , m_type(type)
4040 , m_state(state)
41+ , m_live(true)
4142 , m_qmlItem(nullptr)
4243 , m_screenshotUrl(screenshot)
4344{
@@ -121,6 +122,14 @@ void MirSurfaceItem::setScreenshot(const QUrl& screenshot)
121122 }
122123}
123124
125+void MirSurfaceItem::setLive(bool live)
126+{
127+ if (m_live != live) {
128+ m_live = live;
129+ Q_EMIT liveChanged(m_live);
130+ }
131+}
132+
124133void MirSurfaceItem::onQmlWantInputMethodChanged()
125134{
126135 QQmlProperty prop(m_qmlItem, "wantInputMethod");
tests/mocks/Unity/Application/MirSurfaceItem.h+5−3
@@ -33,6 +33,7 @@ class MirSurfaceItem : public QQuickItem
3333 Q_PROPERTY(Type type READ type NOTIFY typeChanged)
3434 Q_PROPERTY(State state READ state NOTIFY stateChanged)
3535 Q_PROPERTY(QString name READ name CONSTANT)
36+ Q_PROPERTY(bool live READ live NOTIFY liveChanged)
3637
3738public:
3839 enum Type {
@@ -62,9 +63,11 @@ public:
6263 Type type() const { return m_type; }
6364 State state() const { return m_state; }
6465 QString name() const { return m_name; }
66+ bool live() const { return m_live; }
6567
6668 void setSession(Session* item);
6769 void setScreenshot(const QUrl& screenshot);
70+ void setLive(bool live);
6871
6972 Q_INVOKABLE void setState(State newState);
7073 Q_INVOKABLE void release();
@@ -72,9 +75,7 @@ public:
7275Q_SIGNALS:
7376 void typeChanged(Type);
7477 void stateChanged(State);
75− void parentSurfaceChanged(MirSurfaceItem*);
76−
77− void removed();
78+ void liveChanged(bool isLive);
7879
7980 void inputMethodRequested();
8081 void inputMethodDismissed();
@@ -102,6 +103,7 @@ private:
102103 const QString m_name;
103104 const Type m_type;
104105 State m_state;
106+ bool m_live;
105107
106108 QQmlComponent *m_qmlContentComponent;
107109 QQuickItem *m_qmlItem;
tests/mocks/Unity/Application/Session.cpp+9
@@ -28,6 +28,7 @@ Session::Session(const QString &name,
2828 QObject *parent)
2929 : QObject(parent)
3030 , m_name(name)
31+ , m_live(true)
3132 , m_screenshot(screenshot)
3233 , m_application(nullptr)
3334 , m_surface(nullptr)
@@ -113,6 +114,14 @@ void Session::setScreenshot(const QUrl& screenshot)
113114 }
114115}
115116
117+void Session::setLive(bool live)
118+{
119+ if (m_live != live) {
120+ m_live = live;
121+ Q_EMIT liveChanged(m_live);
122+ }
123+}
124+
116125void Session::setParentSession(Session* session)
117126{
118127 if (m_parentSession == session || session == this)
tests/mocks/Unity/Application/Session.h+6−1
@@ -31,6 +31,7 @@ class Session : public QObject
3131 Q_PROPERTY(MirSurfaceItem* surface READ surface NOTIFY surfaceChanged)
3232 Q_PROPERTY(Session* parentSession READ parentSession NOTIFY parentSessionChanged DESIGNABLE false)
3333 Q_PROPERTY(SessionModel* childSessions READ childSessions DESIGNABLE false CONSTANT)
34+ Q_PROPERTY(bool live READ live NOTIFY liveChanged)
3435
3536public:
3637 explicit Session(const QString &name,
@@ -42,6 +43,7 @@ public:
4243
4344 //getters
4445 QString name() const { return m_name; }
46+ bool live() const { return m_live; }
4547 ApplicationInfo* application() const { return m_application; }
4648 MirSurfaceItem* surface() const { return m_surface; }
4749 Session* parentSession() const { return m_parentSession; }
@@ -49,6 +51,7 @@ public:
4951 void setApplication(ApplicationInfo* item);
5052 void setSurface(MirSurfaceItem* surface);
5153 void setScreenshot(const QUrl& m_screenshot);
54+ void setLive(bool live);
5255
5356 Q_INVOKABLE void addChildSession(Session* session);
5457 void insertChildSession(uint index, Session* session);
@@ -57,7 +60,8 @@ public:
5760Q_SIGNALS:
5861 void surfaceChanged(MirSurfaceItem*);
5962 void parentSessionChanged(Session*);
60− void removed();
63+ void liveChanged(bool isLive);
64+
6165 // internal mock use
6266 void deregister();
6367
@@ -69,6 +73,7 @@ private:
6973 void setParentSession(Session* session);
7074
7175 QString m_name;
76+ bool m_live;
7277 QUrl m_screenshot;
7378 ApplicationInfo* m_application;
7479 MirSurfaceItem* m_surface;
tests/mocks/Unity/Application/SessionManager.cpp+2
@@ -48,6 +48,8 @@ void SessionManager::registerSession(Session *session)
4848 Session* session = qobject_cast<Session*>(sender());
4949
5050 disconnect(session, 0, this, 0);
51+
52+ session->setLive(false);
5153 Q_EMIT sessionStopping(session);
5254 });
5355}
tests/mocks/Unity/Application/SurfaceManager.cpp+2
@@ -53,6 +53,8 @@ void SurfaceManager::registerSurface(MirSurfaceItem *surface)
5353 connect(surface, &MirSurfaceItem::deregister, this, [this] {
5454 MirSurfaceItem* surface = qobject_cast<MirSurfaceItem*>(sender());
5555 disconnect(surface, 0, this, 0);
56+
57+ surface->setLive(false);
5658 Q_EMIT surfaceDestroyed(surface);
5759 });
5860 connect(surface, &MirSurfaceItem::inputMethodRequested,
tests/qmltests/Stages/RecursingChildSessionControl.qml+3−3
@@ -94,7 +94,7 @@ ColumnLayout {
9494 if (checked) {
9595 root.session.createSurface();
9696 } else if (root.session.surface) {
97− root.session.surface.removed();
97+ ApplicationTest.removeSurface(root.session.surface);
9898 }
9999 }
100100
@@ -121,8 +121,8 @@ ColumnLayout {
121121 onClicked: {
122122 if (removable) {
123123 // release the surface first. simulates mir app closing
124− if (root.session.surface) root.session.surface.removed();
125− root.session.removed();
124+ if (root.session.surface) ApplicationTest.removeSurface(root.session.surface);
125+ ApplicationTest.removeSession(root.session);
126126 } else {
127127 root.session.release();
128128 }