@@ -27,65 +27,92 @@ Item {
2727 property real topMarginProgress
2828 property bool interactive: true
2929 property real maximizedAppTopMargin
30− property var application: ApplicationManager.get(index)
3130 property bool dropShadow: true
3231
3332 // FIXME: This really should be invisible to QML code.
3433 // e.g. Create a SurfaceItem {} in C++ which we just use without any imperative hacks.
35− property var surface: application ? application.surface : null
36− onSurfaceChanged: {
34+ readonly property var surface: model.surface
35+ onSurfaceChanged: { print("SURFACE!!", model.surface)
3736 if (surface) {
37+ if (!priv.appHasCreatedASurface) {
38+ surface.visible = false; // hide until splash screen removed
39+ priv.appHasCreatedASurface = true;
40+ }
41+
3842 surface.parent = root;
43+ surface.anchors.fill = root;
44+ priv.checkFullscreen(surface);
3945 surface.z = 1;
4046 }
4147 }
4248
49+ QtObject {
50+ id: priv
51+ property bool appHasCreatedASurface: false
52+
53+ function checkFullscreen(surface) {
54+ if (surface.state === MirSurfaceItem.Fullscreen) {
55+ surface.anchors.topMargin = 0;
56+ } else {
57+ surface.anchors.topMargin = maximizedAppTopMargin;
58+ }
59+ }
60+
61+ function revealSurface() {
62+ surface.visible = true;
63+ splashLoader.source = "";
64+ }
65+ }
66+
67+ Timer { //FIXME - need to delay removing splash screen to allow surface resize to complete
68+ id: surfaceRevealDelay
69+ interval: 100
70+ onTriggered: priv.revealSurface()
71+ }
72+
4373 Binding {
4474 target: surface
4575 property: "enabled"
4676 value: root.interactive
4777 }
4878
49− state: {
50− if (surface) {
51− if (surface.state === MirSurfaceItem.Fullscreen) {
52− "fullscreen";
53− } else {
54− "maximized";
55− }
56− } else {
57− return "empty"
58− }
79+ Connections {
80+ target: surface
81+ onStateChanged: priv.checkFullscreen(surface);
5982 }
60− states: [
61− State {
62− name: "fullscreen"
63− PropertyChanges {
64− target: surface
65− x: 0
66− y: 0
67− width: root.width
68− height: root.height
69− }
70− },
71− State {
72− name: "maximized"
73− PropertyChanges {
74− target: surface
75− x: 0
76− y: maximizedAppTopMargin
77− width: root.width
78− height: root.height - y
83+
84+ StateGroup {
85+ id: appSurfaceState
86+ states: [
87+ State {
88+ name: "noSurfaceYet"
89+ when: !priv.appHasCreatedASurface
90+ StateChangeScript {
91+ script: {splashLoader.setSource("Splash.qml", { "name": model.name, "image": model.icon }); }
92+ }
93+ },
94+ State {
95+ name: "hasSurface"
96+ when: priv.appHasCreatedASurface && (root.surface !== null)
97+ StateChangeScript { script: { surfaceRevealDelay.start(); } }
98+ },
99+ State {
100+ name: "surfaceLostButAppStillAlive"
101+ when: priv.appHasCreatedASurface && (root.surface === null)
102+ // TODO - use app snapshot
79103 }
80− },
81− State {
82− name: "empty"
83− }
84− ]
104+ ]
105+ state: "noSurfaceYet"
106+ }
107+
108+ Loader {
109+ id: splashLoader
110+ anchors.fill: parent
111+ }
85112
86113 BorderImage {
87114 id: dropShadowImage
88− anchors.fill: surface
115+ anchors.fill: parent
89116 anchors.margins: -units.gu(2)
90117 source: "graphics/dropshadow.png"
91118 border { left: 50; right: 50; top: 50; bottom: 50 }