@@ -117,8 +117,7 @@ FocusScope {
117117 }
118118 }
119119
120− property Item itemConfiningMouseCursor: !spreadShown && priv.focusedAppDelegate && priv.focusedAppDelegate.surface &&
121− priv.focusedAppDelegate.surface.confinesMousePointer ?
120+ property Item itemConfiningMouseCursor: !spreadShown && priv.focusedAppDelegate && priv.focusedAppDelegate.window.confinesMousePointer ?
122121 priv.focusedAppDelegate.clientAreaItem : null;
123122
124123 signal itemSnapshotRequested(Item item)
@@ -184,29 +183,34 @@ FocusScope {
184183 GlobalShortcut {
185184 id: maximizeWindowShortcut
186185 shortcut: Qt.MetaModifier|Qt.ControlModifier|Qt.Key_Up
187− onTriggered: priv.focusedAppDelegate.maximize()
186+ onTriggered: priv.focusedAppDelegate.requestMaximize()
188187 active: root.state == "windowed" && priv.focusedAppDelegate && priv.focusedAppDelegate.canBeMaximized
189188 }
190189
191190 GlobalShortcut {
192191 id: maximizeWindowLeftShortcut
193192 shortcut: Qt.MetaModifier|Qt.ControlModifier|Qt.Key_Left
194− onTriggered: priv.focusedAppDelegate.maximizeLeft()
193+ onTriggered: priv.focusedAppDelegate.requestMaximizeLeft()
195194 active: root.state == "windowed" && priv.focusedAppDelegate && priv.focusedAppDelegate.canBeMaximizedLeftRight
196195 }
197196
198197 GlobalShortcut {
199198 id: maximizeWindowRightShortcut
200199 shortcut: Qt.MetaModifier|Qt.ControlModifier|Qt.Key_Right
201− onTriggered: priv.focusedAppDelegate.maximizeRight()
200+ onTriggered: priv.focusedAppDelegate.requestMaximizeRight()
202201 active: root.state == "windowed" && priv.focusedAppDelegate && priv.focusedAppDelegate.canBeMaximizedLeftRight
203202 }
204203
205204 GlobalShortcut {
206205 id: minimizeRestoreShortcut
207206 shortcut: Qt.MetaModifier|Qt.ControlModifier|Qt.Key_Down
208− onTriggered: priv.focusedAppDelegate.anyMaximized
209− ? priv.focusedAppDelegate.restoreFromMaximized() : priv.focusedAppDelegate.minimize()
207+ onTriggered: {
208+ if (priv.focusedAppDelegate.anyMaximized) {
209+ priv.focusedAppDelegate.requestRestore();
210+ } else {
211+ priv.focusedAppDelegate.requestMinimize();
212+ }
213+ }
210214 active: root.state == "windowed" && priv.focusedAppDelegate
211215 }
212216
@@ -242,20 +246,10 @@ FocusScope {
242246 }
243247
244248 function minimizeAllWindows() {
245− for (var i = 0; i < appRepeater.count; i++) {
246− var appDelegate = appRepeater.itemAt(i);
247− if (appDelegate && !appDelegate.minimized) {
248− appDelegate.minimize();
249− }
250− }
251− }
252−
253− function focusNext() {
254− for (var i = 0; i < appRepeater.count; i++) {
249+ for (var i = appRepeater.count - 1; i >= 0; i--) {
255250 var appDelegate = appRepeater.itemAt(i);
256251 if (appDelegate && !appDelegate.minimized) {
257− appDelegate.focus = true;
258− return;
252+ appDelegate.requestMinimize();
259253 }
260254 }
261255 }
@@ -356,8 +350,8 @@ FocusScope {
356350 Connections {
357351 target: PanelState
358352 onCloseClicked: { if (priv.focusedAppDelegate) { priv.focusedAppDelegate.close(); } }
359− onMinimizeClicked: { if (priv.focusedAppDelegate) { priv.focusedAppDelegate.minimize(); } }
360− onRestoreClicked: { if (priv.focusedAppDelegate) { priv.focusedAppDelegate.restoreFromMaximized(); } }
353+ onMinimizeClicked: { if (priv.focusedAppDelegate) { priv.focusedAppDelegate.requestMinimize(); } }
354+ onRestoreClicked: { if (priv.focusedAppDelegate) { priv.focusedAppDelegate.requestRestore(); } }
361355 }
362356
363357 Binding {
@@ -432,13 +426,6 @@ FocusScope {
432426 }
433427 }
434428
435− Binding {
436− target: MirFocusController
437− property: "focusedSurface"
438− value: priv.focusedAppDelegate ? priv.focusedAppDelegate.focusedSurface : null
439− when: !appRepeater.startingUp && root.parent
440− }
441−
442429 states: [
443430 State {
444431 name: "spread"; when: priv.goneToSpread
@@ -631,7 +618,7 @@ FocusScope {
631618
632619 onShownChanged: {
633620 if (!shown && priv.mainStageDelegate && !root.spreadShown) {
634− priv.mainStageDelegate.claimFocus();
621+ priv.mainStageDelegate.activate();
635622 }
636623 }
637624
@@ -664,14 +651,23 @@ FocusScope {
664651 }
665652 }
666653
667− TopLevelSurfaceRepeater {
654+ Repeater {
668655 id: appRepeater
669656 model: topLevelSurfaceList
670657 objectName: "appRepeater"
671658
659+ function indexOf(delegateItem) {
660+ for (var i = 0; i < count; i++) {
661+ if (itemAt(i) === delegateItem) {
662+ return i;
663+ }
664+ }
665+ return -1;
666+ }
667+
672668 delegate: FocusScope {
673669 id: appDelegate
674− objectName: "appDelegate_" + model.id
670+ objectName: "appDelegate_" + model.window.id
675671 property int itemIndex: index // We need this from outside the repeater
676672 // z might be overriden in some cases by effects, but we need z ordering
677673 // to calculate occlusion detection
@@ -683,11 +679,11 @@ FocusScope {
683679 }
684680 z: normalZ
685681
686− // Normally we want x/y where we request it to be. Width/height of our delegate will
682+ // Normally we want x/y where the surface thinks it is. Width/height of our delegate will
687683 // match what the actual surface size is.
688684 // Don't write to those, they will be set by states
689− x: requestedX
690− y: requestedY
685+ x: model.window.position.x - clientAreaItem.x
686+ y: model.window.position.y - clientAreaItem.y
691687 width: decoratedWindow.implicitWidth
692688 height: decoratedWindow.implicitHeight
693689
@@ -697,6 +693,12 @@ FocusScope {
697693 property real requestedY: windowedY
698694 property real requestedWidth: windowedWidth
699695 property real requestedHeight: windowedHeight
696+ Binding {
697+ target: model.window; property: "requestedPosition"
698+ // miral doesn't know about our window decorations. So we have to deduct them
699+ value: Qt.point(appDelegate.requestedX + appDelegate.clientAreaItem.x,
700+ appDelegate.requestedY + appDelegate.clientAreaItem.y)
701+ }
700702
701703 // In those are for windowed mode. Those values basically store the window's properties
702704 // when having a floating window. If you want to move/resize a window in normal mode, this is what you want to write to.
@@ -788,7 +790,7 @@ FocusScope {
788790 maximizedTopLeft || maximizedTopRight || maximizedBottomLeft || maximizedBottomRight
789791
790792 readonly property bool minimized: windowState & WindowStateStorage.WindowStateMinimized
791− readonly property bool fullscreen: surface ? surface.state === Mir.FullscreenState : application.fullscreen
793+ readonly property bool fullscreen: window.state === Mir.FullscreenState
792794
793795 readonly property bool canBeMaximized: canBeMaximizedHorizontally && canBeMaximizedVertically
794796 readonly property bool canBeMaximizedLeftRight: (maximumWidth == 0 || maximumWidth >= appContainer.width/2) &&
@@ -814,7 +816,9 @@ FocusScope {
814816 priv.updateMainAndSideStageIndexes()
815817 }
816818
817− readonly property var surface: model.surface
819+ readonly property var surface: model.window.surface
820+ readonly property var window: model.window
821+
818822 readonly property alias resizeArea: resizeArea
819823 readonly property alias focusedSurface: decoratedWindow.focusedSurface
820824 readonly property bool dragging: touchControls.overlayShown ? touchControls.dragging : decoratedWindow.dragging
@@ -823,6 +827,25 @@ FocusScope {
823827 readonly property bool isDash: appId == "unity8-dash"
824828 readonly property alias clientAreaItem: decoratedWindow.clientAreaItem
825829
830+ function activate() {
831+ if (model.window.focused) {
832+ updateQmlFocusFromMirSurfaceFocus();
833+ } else {
834+ model.window.activate();
835+ }
836+ }
837+ function requestMaximize() { model.window.requestState(Mir.MaximizedState); }
838+ function requestMaximizeVertically() { model.window.requestState(Mir.VertMaximizedState); }
839+ function requestMaximizeHorizontally() { model.window.requestState(Mir.HorizMaximizedState); }
840+ function requestMaximizeLeft() { model.window.requestState(Mir.MaximizedLeftState); }
841+ function requestMaximizeRight() { model.window.requestState(Mir.MaximizedRightState); }
842+ function requestMaximizeTopLeft() { model.window.requestState(Mir.MaximizedTopLeftState); }
843+ function requestMaximizeTopRight() { model.window.requestState(Mir.MaximizedTopRightState); }
844+ function requestMaximizeBottomLeft() { model.window.requestState(Mir.MaximizedBottomLeftState); }
845+ function requestMaximizeBottomRight() { model.window.requestState(Mir.MaximizedBottomRightState); }
846+ function requestMinimize() { model.window.requestState(Mir.MinimizedState); }
847+ function requestRestore() { model.window.requestState(Mir.RestoredState); }
848+
826849 function claimFocus() {
827850 if (root.state == "spread") {
828851 spreadItem.highlightedIndex = index
@@ -834,43 +857,16 @@ FocusScope {
834857 }
835858 priv.updateMainAndSideStageIndexes();
836859 }
837−
838860 if (root.mode == "windowed") {
839861 appDelegate.restore(true /* animated */, appDelegate.windowState);
840− } else {
841− appDelegate.focus = true;
842− }
843− }
844− Connections {
845− target: model.surface
846− onFocusRequested: {
847− claimFocus();
848− }
849− }
850− Connections {
851− target: model.application
852− onFocusRequested: {
853− if (!model.surface) {
854− // when an app has no surfaces, we assume there's only one entry representing it:
855− // this delegate.
856− claimFocus();
857− } else {
858− // if the application has surfaces, focus request should be at surface-level.
859− }
860862 }
863+ appDelegate.focus = true;
861864 }
862865
863− onFocusChanged: {
864− if (appRepeater.startingUp)
865− return;
866−
867− if (focus) {
868− topLevelSurfaceList.raiseId(model.id);
866+ function updateQmlFocusFromMirSurfaceFocus() {
867+ if (model.window.focused) {
868+ claimFocus();
869869 priv.focusedAppDelegate = appDelegate;
870− } else if (!focus && priv.focusedAppDelegate === appDelegate && root.state != "spread") {
871− priv.focusedAppDelegate = null;
872− // FIXME: No idea why the Binding{} doens't update when focusedAppDelegate turns null
873− MirFocusController.focusedSurface = null;
874870 }
875871 }
876872
@@ -883,6 +879,41 @@ FocusScope {
883879 minimumY: PanelState.panelHeight
884880 }
885881
882+ Connections {
883+ target: model.window
884+ onFocusedChanged: {
885+ updateQmlFocusFromMirSurfaceFocus();
886+ }
887+ onFocusRequested: {
888+ appDelegate.activate();
889+ }
890+ onStateChanged: {
891+ if (model.window.state === Mir.MinimizedState) {
892+ appDelegate.minimize();
893+ } else if (model.window.state === Mir.MaximizedState) {
894+ appDelegate.maximize();
895+ } else if (model.window.state === Mir.VertMaximizedState) {
896+ appDelegate.maximizeVertically();
897+ } else if (model.window.state === Mir.HorizMaximizedState) {
898+ appDelegate.maximizeHorizontally();
899+ } else if (model.window.state === Mir.MaximizedLeftState) {
900+ appDelegate.maximizeLeft();
901+ } else if (model.window.state === Mir.MaximizedRightState) {
902+ appDelegate.maximizeRight();
903+ } else if (model.window.state === Mir.MaximizedTopLeftState) {
904+ appDelegate.maximizeTopLeft();
905+ } else if (model.window.state === Mir.MaximizedTopRightState) {
906+ appDelegate.maximizeTopRight();
907+ } else if (model.window.state === Mir.MaximizedBottomLeftState) {
908+ appDelegate.maximizeBottomLeft();
909+ } else if (model.window.state === Mir.MaximizedBottomRightState) {
910+ appDelegate.maximizeBottomRight();
911+ } else if (model.window.state === Mir.RestoredState) {
912+ appDelegate.restore();
913+ }
914+ }
915+ }
916+
886917 Component.onCompleted: {
887918 if (application && application.rotatesWindowContents) {
888919 decoratedWindow.surfaceOrientationAngle = shellOrientationAngle;
@@ -895,17 +926,9 @@ FocusScope {
895926 windowedY = priv.focusedAppDelegate ? priv.focusedAppDelegate.windowedY + units.gu(3) : normalZ * units.gu(3)
896927 // Now load any saved state. This needs to happen *after* the cascading!
897928 windowStateSaver.load();
929+ model.window.requestState(WindowStateStorage.toMirState(windowState));
898930
899− // NB: We're differentiating if this delegate was created in response to a new entry in the model
900− // or if the Repeater is just populating itself with delegates to match the model it received.
901− if (!appRepeater.startingUp) {
902− // a top level window is always the focused one when it first appears, unfocusing
903− // any preexisting one
904− if (root.state == "spread") {
905− spreadItem.highlightedIndex = index;
906− }
907− claimFocus();
908− }
931+ updateQmlFocusFromMirSurfaceFocus();
909932
910933 refreshStage();
911934 _constructing = false;
@@ -921,17 +944,6 @@ FocusScope {
921944 if (visuallyMaximized) {
922945 priv.updateForegroundMaximizedApp();
923946 }
924−
925− if (focus) {
926− // focus some other window
927− for (var i = 0; i < appRepeater.count; i++) {
928− var appDelegate = appRepeater.itemAt(i);
929− if (appDelegate && !appDelegate.minimized && i != index) {
930− appDelegate.focus = true;
931− return;
932− }
933− }
934− }
935947 }
936948
937949 onVisuallyMaximizedChanged: priv.updateForegroundMaximizedApp()
@@ -952,7 +964,7 @@ FocusScope {
952964 || focusAnimation.running || rightEdgeFocusAnimation.running || hidingAnimation.running
953965
954966 function close() {
955− model.surface.close();
967+ model.window.close();
956968 }
957969
958970 function maximize(animated) {
@@ -995,15 +1007,10 @@ FocusScope {
9951007 animationsEnabled = (animated === undefined) || animated;
9961008 windowState |= WindowStateStorage.WindowStateMinimized; // add the minimized bit
9971009 }
998− function restoreFromMaximized(animated) {
999− animationsEnabled = (animated === undefined) || animated;
1000− windowState = WindowStateStorage.WindowStateRestored;
1001− }
10021010 function restore(animated,state) {
10031011 animationsEnabled = (animated === undefined) || animated;
10041012 windowState = state || WindowStateStorage.WindowStateRestored;
10051013 windowState &= ~WindowStateStorage.WindowStateMinimized; // clear the minimized bit
1006− focus = true;
10071014 }
10081015
10091016 function playFocusAnimation() {
@@ -1017,7 +1024,7 @@ FocusScope {
10171024 rightEdgeFocusAnimation.start()
10181025 }
10191026 } else if (state == "windowedRightEdge" || state == "windowed") {
1020− claimFocus();
1027+ activate();
10211028 } else {
10221029 focusAnimation.start()
10231030 }
@@ -1055,10 +1062,10 @@ FocusScope {
10551062 to: 1
10561063 duration: UbuntuAnimation.SnapDuration
10571064 onStarted: {
1058− topLevelSurfaceList.raiseId(model.id);
1065+ topLevelSurfaceList.raiseId(model.window.id);
10591066 }
10601067 onStopped: {
1061− appDelegate.claimFocus();
1068+ appDelegate.activate();
10621069 }
10631070 }
10641071 ParallelAnimation {
@@ -1068,7 +1075,7 @@ FocusScope {
10681075 UbuntuNumberAnimation { target: decoratedWindow; properties: "angle"; to: 0; duration: priv.animationDuration }
10691076 UbuntuNumberAnimation { target: decoratedWindow; properties: "itemScale"; to: 1; duration: priv.animationDuration }
10701077 onStopped: {
1071− appDelegate.focus = true
1078+ appDelegate.activate();
10721079 }
10731080 }
10741081 ParallelAnimation {
@@ -1318,15 +1325,9 @@ FocusScope {
13181325 windowedY: restoredY;
13191326 }
13201327 },
1321− State {
1322− name: "semiMaximized"
1323− PropertyChanges { target: touchControls; enabled: true }
1324− PropertyChanges { target: resizeArea; enabled: true }
1325− PropertyChanges { target: decoratedWindow; shadowOpacity: .3 }
1326− },
13271328 State {
13281329 name: "maximizedLeft"; when: appDelegate.maximizedLeft && !appDelegate.minimized
1329− extend: "semiMaximized"
1330+ extend: "normal"
13301331 PropertyChanges {
13311332 target: appDelegate
13321333 windowedX: root.leftMargin
@@ -1345,7 +1346,7 @@ FocusScope {
13451346 },
13461347 State {
13471348 name: "maximizedTopLeft"; when: appDelegate.maximizedTopLeft && !appDelegate.minimized
1348− extend: "semiMaximized"
1349+ extend: "normal"
13491350 PropertyChanges {
13501351 target: appDelegate
13511352 windowedX: root.leftMargin
@@ -1364,7 +1365,7 @@ FocusScope {
13641365 },
13651366 State {
13661367 name: "maximizedBottomLeft"; when: appDelegate.maximizedBottomLeft && !appDelegate.minimized
1367− extend: "semiMaximized"
1368+ extend: "normal"
13681369 PropertyChanges {
13691370 target: appDelegate
13701371 windowedX: root.leftMargin
@@ -1383,15 +1384,15 @@ FocusScope {
13831384 },
13841385 State {
13851386 name: "maximizedHorizontally"; when: appDelegate.maximizedHorizontally && !appDelegate.minimized
1386− extend: "semiMaximized"
1387− PropertyChanges { target: appDelegate; requestedX: root.leftMargin; requestedY: windowedY;
1388− requestedWidth: appContainer.width - root.leftMargin; requestedHeight: appDelegate.windowedHeight }
1387+ extend: "normal"
1388+ PropertyChanges { target: appDelegate; windowedX: root.leftMargin; windowedY: windowedY;
1389+ windowedWidth: appContainer.width - root.leftMargin; windowedHeight: windowedHeight }
13891390 },
13901391 State {
13911392 name: "maximizedVertically"; when: appDelegate.maximizedVertically && !appDelegate.minimized
1392− extend: "semiMaximized"
1393− PropertyChanges { target: appDelegate; requestedX: windowedX; requestedY: PanelState.panelHeight;
1394− requestedWidth: appDelegate.windowedWidth; requestedHeight: appContainer.height - PanelState.panelHeight }
1393+ extend: "normal"
1394+ PropertyChanges { target: appDelegate; windowedX: windowedX; windowedY: PanelState.panelHeight;
1395+ windowedWidth: windowedWidth; windowedHeight: appContainer.height - PanelState.panelHeight }
13951396 },
13961397 State {
13971398 name: "minimized"; when: appDelegate.minimized
@@ -1417,14 +1418,6 @@ FocusScope {
14171418 to: "staged,stagedWithSideStage"
14181419 UbuntuNumberAnimation { target: appDelegate; properties: "x,y,requestedX,requestedY,requestedWidth,requestedHeight"; duration: priv.animationDuration}
14191420 },
1420− Transition {
1421− from: "maximized,maximizedHorizontally,maximizedVertically,maximizedLeft,maximizedRight,maximizedTopLeft,maximizedBottomLeft,maximizedTopRight,maximizedBottomRight,minimized";
1422− to: "normal,restored"
1423− enabled: appDelegate.animationsEnabled
1424− PropertyAction { target: appDelegate; properties: "visuallyMinimized,visuallyMaximized" }
1425− UbuntuNumberAnimation { target: appDelegate; properties: "requestedX,requestedY,windowedX,windowedY,requestedWidth,requestedHeight,windowedWidth,windowedHeight,scale";
1426− duration: priv.animationDuration }
1427− },
14281421 Transition {
14291422 to: "minimized"
14301423 enabled: appDelegate.animationsEnabled
@@ -1432,14 +1425,6 @@ FocusScope {
14321425 SequentialAnimation {
14331426 UbuntuNumberAnimation { target: appDelegate; properties: "requestedX,requestedY,opacity,scale,requestedWidth,requestedHeight" }
14341427 PropertyAction { target: appDelegate; property: "visuallyMinimized" }
1435− ScriptAction {
1436− script: {
1437− if (appDelegate.minimized) {
1438− appDelegate.focus = false;
1439− priv.focusNext();
1440− }
1441− }
1442− }
14431428 }
14441429 },
14451430 Transition {
@@ -1492,8 +1477,8 @@ FocusScope {
14921477 },
14931478 Transition {
14941479 id: windowedTransition
1495− from: "normal,restored,maximized,maximizedLeft,maximizedRight,maximizedTop,maximizedBottom,maximizedTopLeft,maximizedTopRight,maximizedBottomLeft,maximizedBottomRight,maximizedHorizontally,maximizedVertically,fullscreen"
1496− to: "normal,restored,maximized,maximizedLeft,maximizedRight,maximizedTop,maximizedBottom,maximizedTopLeft,maximizedTopRight,maximizedBottomLeft,maximizedBottomRight,maximizedHorizontally,maximizedVertically,fullscreen"
1480+ from: ",normal,restored,maximized,maximizedLeft,maximizedRight,maximizedTopLeft,maximizedTopRight,maximizedBottomLeft,maximizedBottomRight,maximizedHorizontally,maximizedVertically,fullscreen,minimized"
1481+ to: ",normal,restored,maximized,maximizedLeft,maximizedRight,maximizedTopLeft,maximizedTopRight,maximizedBottomLeft,maximizedBottomRight,maximizedHorizontally,maximizedVertically,fullscreen"
14971482 enabled: appDelegate.animationsEnabled
14981483 SequentialAnimation {
14991484 PropertyAction { target: appDelegate; property: "visuallyMinimized" }
@@ -1529,7 +1514,7 @@ FocusScope {
15291514 visible: enabled
15301515
15311516 onPressed: {
1532− appDelegate.focus = true;
1517+ appDelegate.activate();
15331518 }
15341519 }
15351520
@@ -1539,7 +1524,7 @@ FocusScope {
15391524 anchors.left: appDelegate.left
15401525 anchors.top: appDelegate.top
15411526 application: model.application
1542− surface: model.surface
1527+ surface: model.window.surface
15431528 active: appDelegate.focus
15441529 focus: true
15451530 interactive: root.interactive
@@ -1564,21 +1549,21 @@ FocusScope {
15641549 onCloseClicked: { appDelegate.close(); }
15651550 onMaximizeClicked: {
15661551 if (appDelegate.canBeMaximized) {
1567− appDelegate.anyMaximized ? appDelegate.restoreFromMaximized() : appDelegate.maximize();
1552+ appDelegate.anyMaximized ? appDelegate.requestRestore() : appDelegate.requestMaximize();
15681553 }
15691554 }
15701555 onMaximizeHorizontallyClicked: {
15711556 if (appDelegate.canBeMaximizedHorizontally) {
1572− appDelegate.maximizedHorizontally ? appDelegate.restoreFromMaximized() : appDelegate.maximizeHorizontally()
1557+ appDelegate.maximizedHorizontally ? appDelegate.requestRestore() : appDelegate.requestMaximizeHorizontally()
15731558 }
15741559 }
15751560 onMaximizeVerticallyClicked: {
15761561 if (appDelegate.canBeMaximizedVertically) {
1577− appDelegate.maximizedVertically ? appDelegate.restoreFromMaximized() : appDelegate.maximizeVertically()
1562+ appDelegate.maximizedVertically ? appDelegate.requestRestore() : appDelegate.requestMaximizeVertically()
15781563 }
15791564 }
1580− onMinimizeClicked: appDelegate.minimize()
1581− onDecorationPressed: { appDelegate.focus = true; }
1565+ onMinimizeClicked: { appDelegate.requestMinimize(); }
1566+ onDecorationPressed: { appDelegate.activate(); }
15821567 onDecorationReleased: fakeRectangle.commit();
15831568
15841569 property real angle: 0
@@ -1625,12 +1610,12 @@ FocusScope {
16251610 WindowedFullscreenPolicy {
16261611 id: windowedFullscreenPolicy
16271612 active: root.mode == "windowed"
1628− surface: model.surface
1613+ surface: model.window.surface
16291614 }
16301615 StagedFullscreenPolicy {
16311616 id: stagedFullscreenPolicy
16321617 active: root.mode == "staged" || root.mode == "stagedWithSideStage"
1633− surface: model.surface
1618+ surface: model.window.surface
16341619 }
16351620
16361621 SpreadDelegateInputArea {
@@ -1643,16 +1628,13 @@ FocusScope {
16431628 onClicked: {
16441629 spreadItem.highlightedIndex = index;
16451630 if (distance == 0) {
1631+ model.window.activate();
16461632 priv.goneToSpread = false;
16471633 }
16481634 }
16491635 onClose: {
16501636 priv.closingIndex = index
1651− if (model.surface) { // could be stopped by OOM
1652− model.surface.close()
1653− } else if (model.application) {
1654− root.applicationManager.stopApplication(model.application.appId);
1655− }
1637+ model.window.close();
16561638 }
16571639 }
16581640