@@ -85,7 +85,7 @@ AbstractStage {
8585 GlobalShortcut {
8686 id: showSpreadShortcut
8787 shortcut: Qt.MetaModifier|Qt.Key_W
88− onTriggered: state = "altTab"
88+ onTriggered: priv.goneToSpread = true
8989 }
9090
9191 GlobalShortcut {
@@ -183,6 +183,9 @@ AbstractStage {
183183 }
184184 }
185185
186+ readonly property bool sideStageEnabled: root.shellOrientation == Qt.LandscapeOrientation ||
187+ root.shellOrientation == Qt.InvertedLandscapeOrientation
188+
186189 property var mainStageDelegate: null
187190 property var sideStageDelegate: null
188191 property int mainStageItemId: 0
@@ -431,7 +434,7 @@ AbstractStage {
431434 id: appContainer
432435 objectName: "appContainer"
433436 anchors.fill: parent
434− focus: root.state !== "altTab"
437+ focus: root.state !== "spread"
435438
436439 CrossFadeImage {
437440 id: wallpaper
@@ -618,8 +621,8 @@ AbstractStage {
618621 angleDiff = (360 + angleDiff) % 360;
619622 if (angleDiff === 90 || angleDiff === 270) {
620623 var aux = decoratedWindow.requestedHeight;
621− decoratedWindow.requestedHeight = decoratedWindow.requestedWidth + decoratedWindow.visibleDecorationHeight;
622− decoratedWindow.requestedWidth = aux - decoratedWindow.visibleDecorationHeight;
624+ decoratedWindow.requestedHeight = decoratedWindow.requestedWidth + decoratedWindow.decorationHeight;
625+ decoratedWindow.requestedWidth = aux - decoratedWindow.decorationHeight;
623626 }
624627 }
625628 decoratedWindow.surfaceOrientationAngle = shellOrientationAngle;
@@ -628,6 +631,10 @@ AbstractStage {
628631 }
629632 }
630633 }
634+ Connections {
635+ target: priv
636+ onSideStageEnabledChanged: refreshStage()
637+ }
631638
632639 readonly property alias application: decoratedWindow.application
633640 readonly property alias minimumWidth: decoratedWindow.minimumWidth
@@ -728,6 +735,9 @@ AbstractStage {
728735 print("focusing because of creation")
729736 focus = true;
730737 }
738+
739+ refreshStage();
740+ _constructing = false;
731741 }
732742 Component.onDestruction: {
733743 if (!root.parent) {
@@ -754,6 +764,7 @@ AbstractStage {
754764
755765 onVisuallyMaximizedChanged: priv.updateForegroundMaximizedApp()
756766
767+ property bool _constructing: true;
757768 onStageChanged: {
758769 if (!_constructing) {
759770 priv.updateMainAndSideStageIndexes();
@@ -843,6 +854,25 @@ AbstractStage {
843854 }
844855 }
845856
857+ function refreshStage() {
858+ var newStage = ApplicationInfoInterface.MainStage;
859+ if (priv.sideStageEnabled) { // we're in lanscape rotation.
860+ if (!isDash && application && application.supportedOrientations & (Qt.PortraitOrientation|Qt.InvertedPortraitOrientation)) {
861+ var defaultStage = ApplicationInfoInterface.SideStage; // if application supports portrait, it defaults to sidestage.
862+ if (application.supportedOrientations & (Qt.LandscapeOrientation|Qt.InvertedLandscapeOrientation)) {
863+ // if it supports lanscape, it defaults to mainstage.
864+ defaultStage = ApplicationInfoInterface.MainStage;
865+ }
866+ newStage = WindowStateStorage.getStage(application.appId, defaultStage);
867+ }
868+ }
869+
870+ stage = newStage;
871+ if (focus && stage == ApplicationInfoInterface.SideStage && !sideStage.shown) {
872+ sideStage.show();
873+ }
874+ }
875+
846876 UbuntuNumberAnimation {
847877 id: focusAnimation
848878 target: appDelegate