@@ -118,6 +118,7 @@ AbstractStage {
118118
119119 property var focusedAppDelegate: null
120120 onFocusedAppDelegateChanged: {
121+ print("focusedAppDelegate changed", focusedAppDelegate.objectName)
121122 if (root.state == "spread") {
122123 goneToSpread = false;
123124 }
@@ -154,6 +155,7 @@ AbstractStage {
154155 for (var i = 0; i < appRepeater.count; i++) {
155156 var appDelegate = appRepeater.itemAt(i);
156157 if (appDelegate && !appDelegate.minimized) {
158+ print("***** focusing because of focusNext() call", appDelegate.application.appId)
157159 appDelegate.focus = true;
158160 return;
159161 }
@@ -168,6 +170,7 @@ AbstractStage {
168170 onMaximize: { if (priv.focusedAppDelegate) { priv.focusedAppDelegate.restoreFromMaximized(); } }
169171 onFocusMaximizedApp: {
170172 if (priv.foregroundMaximizedAppDelegate) {
173+ print("***** focusing because of Panel request", model.application.appId)
171174 priv.foregroundMaximizedAppDelegate.focus = true;
172175 }
173176 }
@@ -324,14 +327,17 @@ AbstractStage {
324327 property real angle: 0
325328
326329 function claimFocus() {
327− if (spread.state == "altTab") {
328− spread.cancel();
329− }
330− appDelegate.restore();
330+// if (spread.state == "altTab") {
331+// spread.cancel();
332+// }
333+// appDelegate.restore();
331334 }
332335 Connections {
333336 target: model.surface
334− onFocusRequested: claimFocus();
337+ onFocusRequested: {
338+ print("model surface requesting focus", model.application.appId)
339+ claimFocus();
340+ }
335341 }
336342 Connections {
337343 target: model.application
@@ -351,11 +357,14 @@ AbstractStage {
351357 return;
352358
353359 if (focus) {
360+ print("app surface gained focus:", model.application.appId)
361+ print("setting focusedAppDelegate to", appDelegate.application.appId)
354362 priv.focusedAppDelegate = appDelegate;
355363
356364 // If we're orphan (!parent) it means this stage is no longer the current one
357365 // and will be deleted shortly. So we should no longer have a say over the model
358366 if (root.parent) {
367+ print("raising surface in model", model.id)
359368 topLevelSurfaceList.raiseId(model.id);
360369 }
361370 } else if (!focus && priv.focusedAppDelegate === appDelegate) {
@@ -370,6 +379,7 @@ AbstractStage {
370379 if (!appRepeater.startingUp) {
371380 // a top level window is always the focused one when it first appears, unfocusing
372381 // any preexisting one
382+ print("***** focusing after starting up", model.application.appId)
373383 focus = true;
374384 }
375385 }
@@ -388,6 +398,7 @@ AbstractStage {
388398 for (var i = 0; i < appRepeater.count; i++) {
389399 var appDelegate = appRepeater.itemAt(i);
390400 if (appDelegate && !appDelegate.minimized && i != index) {
401+ print("***** focusing because of previously focused window disappeared", appDelegate.application.appId)
391402 appDelegate.focus = true;
392403 return;
393404 }
@@ -397,13 +408,13 @@ AbstractStage {
397408
398409 onVisuallyMaximizedChanged: priv.updateForegroundMaximizedApp()
399410
400− visible: (
401− !visuallyMinimized
402− && !greeter.fullyShown
403− && (priv.foregroundMaximizedAppDelegate === null || priv.foregroundMaximizedAppDelegate.normalZ <= z)
404− )
405− || decoratedWindow.fullscreen
406− // || (root.state == "altTab" && index === spread.highlightedIndex)
411+// visible: (
412+// !visuallyMinimized
413+// && !greeter.fullyShown
414+// && (priv.foregroundMaximizedAppDelegate === null || priv.foregroundMaximizedAppDelegate.normalZ <= z)
415+// )
416+// || decoratedWindow.fullscreen
417+// // || (root.state == "altTab" && index === spread.highlightedIndex)
407418
408419 function close() {
409420 model.surface.close();
@@ -449,6 +460,7 @@ AbstractStage {
449460 else if (maximizedRight)
450461 maximizeRight();
451462
463+ print("***** focusing because of window restore", model.application.appId)
452464 focus = true;
453465 }
454466
@@ -495,6 +507,7 @@ AbstractStage {
495507 }
496508 ]
497509
510+ onXChanged: if (model.application.appId == "unity8-dash") print("dash moved to", x)
498511 onRequestedWidthChanged: if (index == 0) print("requestedWidth", requestedWidth)
499512 states: [
500513 State {
@@ -506,6 +519,7 @@ AbstractStage {
506519 angle: spreadMaths.animatedAngle
507520 }
508521 PropertyChanges { target: decoratedWindow; showDecoration: false }
522+ PropertyChanges { target: inputBlocker; enabled: true }
509523 },
510524 State {
511525 name: "stagedrightedge"; when: root.state == "stagedrightedge"
@@ -528,13 +542,18 @@ AbstractStage {
528542 name: "staged"; when: root.state == "staged"
529543 PropertyChanges {
530544 target: appDelegate
531− x: 0; y: 0
545+ x: appDelegate.focus ? 0 : root.width; y: appDelegate.fullscreen ? 0 : PanelState.panelHeight
532546 visuallyMaximized: true
533547 }
534548 PropertyChanges {
535549 target: decoratedWindow
536550 requestedWidth: appContainer.width - root.leftMargin;
537551 requestedHeight: appContainer.height;
552+ showDecoration: false
553+ }
554+ PropertyChanges {
555+ target: resizeArea
556+ enabled: false
538557 }
539558 },
540559 State {
@@ -656,10 +675,17 @@ AbstractStage {
656675 PropertyAnimation { target: appDelegate; properties: "x,y,width,height"; duration: UbuntuAnimation.FastDuration }
657676 },
658677 Transition {
678+ from: "spread"; to: "staged"
679+ PropertyAnimation {
680+ target: appDelegate
681+ properties: "x,y,angle"
682+ duration: 4000
683+ }
684+ },
685+ Transition { // Ordering is important. This generic case needs to be after spread -> staged
659686 to: "staged";
660687 PropertyAnimation { target: appDelegate; properties: "x,y,width,height"; duration: UbuntuAnimation.FastDuration }
661688 }
662−
663689 ]
664690
665691// Binding {
@@ -682,7 +708,10 @@ AbstractStage {
682708 screenHeight: appContainer.height
683709 leftMargin: root.leftMargin
684710
685− onPressed: { appDelegate.focus = true; }
711+ onPressed: {
712+ print("***** focusing because of resize area press", model.application.appId)
713+ appDelegate.focus = true;
714+ }
686715
687716 Component.onCompleted: {
688717 loadWindowState();
@@ -722,7 +751,10 @@ AbstractStage {
722751 onMaximize: appDelegate.maximized || appDelegate.maximizedLeft || appDelegate.maximizedRight
723752 ? appDelegate.restoreFromMaximized() : appDelegate.maximize()
724753 onMinimize: appDelegate.minimize()
725− onDecorationPressed: { appDelegate.focus = true; }
754+ onDecorationPressed: {
755+ print("***** focusing because of decoration press", model.application.appId)
756+ appDelegate.focus = true;
757+ }
726758 }
727759
728760 WindowedFullscreenPolicy {
@@ -730,6 +762,15 @@ AbstractStage {
730762 active: true
731763 surface: model.surface
732764 }
765+
766+ MouseArea {
767+ id: inputBlocker
768+ enabled: false
769+ onClicked: {
770+ print("focusing because of inputBlocker click")
771+ appDelegate.focus = true
772+ }
773+ }
733774 }
734775 }
735776 }
@@ -760,6 +801,7 @@ AbstractStage {
760801 FloatingFlickable {
761802 id: floatingFlickable
762803 anchors.fill: parent
804+ enabled: false
763805
764806 property int minContentWidth: 6 * Math.min(height / 4, width / 5)
765807 contentWidth: Math.max(6, appRepeater.count) * Math.min(height / 4, width / 5)
@@ -777,7 +819,7 @@ AbstractStage {
777819 property real progress: -touchX / root.width
778820 onProgressChanged: print("dda progress", progress, root.width, touchX, root.width + touchX)
779821
780− Rectangle { color: "blue"; anchors.fill: parent }
822+// Rectangle { color: "blue"; anchors.fill: parent }
781823 onTouchXChanged: {
782824 if (dragging) {
783825 // Gesture recognized. Let's move the spreadView with the finger