@@ -32,9 +32,21 @@ Item {
3232 // e.g. Create a SurfaceItem {} in C++ which we just use without any imperative hacks.
3333 property var surface: application ? application.surface : null
3434 onSurfaceChanged: {
35− if (surface) {
36− surface.parent = root;
37− surface.z = 1;
35+ if (surface && !priv.appHasCreatedASurface) {
36+ priv.appHasCreatedASurface = true;
37+ }
38+ }
39+
40+ QtObject {
41+ id: priv
42+ property bool appHasCreatedASurface: false
43+
44+ function checkFullscreen(surface) {
45+ if (surface.state === MirSurfaceItem.Fullscreen) {
46+ surface.anchors.topMargin = 0;
47+ } else {
48+ surface.anchors.topMargin = maximizedAppTopMargin;
49+ }
3850 }
3951 }
4052
@@ -44,42 +56,42 @@ Item {
4456 value: root.interactive
4557 }
4658
47− state: {
48− if (surface) {
49− if (surface.state === MirSurfaceItem.Fullscreen) {
50− "fullscreen";
51− } else {
52− "maximized";
53− }
54− } else {
55− return "empty"
56− }
59+ Connections {
60+ target: surface
61+ onStateChanged: priv.checkFullScreen(surface);
5762 }
58− states: [
59− State {
60− name: "fullscreen"
61− PropertyChanges {
62− target: surface
63− x: 0
64− y: 0
65− width: root.width
66− height: root.height
67− }
68− },
69− State {
70− name: "maximized"
71− PropertyChanges {
72− target: surface
73− x: 0
74− y: maximizedAppTopMargin
75− width: root.width
76− height: root.height - y
63+
64+ StateGroup {
65+ id: appSurfaceState
66+ states: [
67+ State {
68+ name: "noSurfaceYet"
69+ when: !priv.appHasCreatedASurface
70+ StateChangeScript {
71+ script: {splashLoader.setSource("Splash.qml", { "name": application.name, "image": application.icon }); print("SPLASH!!")}
72+ }
73+ },
74+ State {
75+ name: "hasSurface"
76+ when: priv.appHasCreatedASurface && (root.surface !== null)
77+ PropertyChanges { target: root.surface; parent: root; anchors.fill: parent; z: 1 }
78+ StateChangeScript { script: priv.checkFullscreen(root.surface); }
79+ PropertyChanges { target: splashLoader; source: "" }
80+ },
81+ State {
82+ name: "surfaceLostButAppStillAlive"
83+ when: priv.appHasCreatedASurface && (root.surface === null)
84+ // TODO - use app snapshot
7785 }
78− },
79− State {
80− name: "empty"
81− }
82− ]
86+ ]
87+ state: "noSurfaceYet"
88+ }
89+
90+ Loader {
91+ id: splashLoader
92+ anchors.fill: parent
93+ onLoaded: print("Splash loaded!!")
94+ }
8395
8496 BorderImage {
8597 id: dropShadow
@@ -100,4 +112,7 @@ Item {
100112 root.clicked()
101113 }
102114 }
115+
116+ Component.onCompleted: print("SpreadDelegate created", root, application)
117+ Component.onDestruction: print("SpreadDelegate destroyed", root, application)
103118}