@@ -806,7 +806,7 @@ FocusScope {
806806 maximizedTopLeft || maximizedTopRight || maximizedBottomLeft || maximizedBottomRight
807807
808808 readonly property bool minimized: windowState & WindowStateStorage.WindowStateMinimized
809− readonly property bool fullscreen: window.state === Mir.FullscreenState
809+ readonly property bool fullscreen: windowState === WindowStateStorage.WindowStateFullscreen
810810
811811 readonly property bool canBeMaximized: canBeMaximizedHorizontally && canBeMaximizedVertically
812812 readonly property bool canBeMaximizedLeftRight: (maximumWidth == 0 || maximumWidth >= appContainer.width/2) &&
@@ -818,6 +818,7 @@ FocusScope {
818818 readonly property alias orientationChangesEnabled: decoratedWindow.orientationChangesEnabled
819819
820820 property int windowState: WindowStateStorage.WindowStateNormal
821+ property int prevWindowState: WindowStateStorage.WindowStateRestored
821822 property bool animationsEnabled: true
822823 property alias title: decoratedWindow.title
823824 readonly property string appName: model.application ? model.application.name : ""
@@ -922,7 +923,14 @@ FocusScope {
922923 } else if (model.window.state === Mir.MaximizedBottomRightState) {
923924 appDelegate.maximizeBottomRight();
924925 } else if (model.window.state === Mir.RestoredState) {
925− appDelegate.restore();
926+ if (appDelegate.fullscreen && appDelegate.prevWindowState != WindowStateStorage.WindowStateRestored) {
927+ model.window.requestState(WindowStateStorage.toMirState(appDelegate.prevWindowState));
928+ } else {
929+ appDelegate.restore();
930+ }
931+ } else if (model.window.state === Mir.FullscreenState) {
932+ appDelegate.prevWindowState = appDelegate.windowState;
933+ appDelegate.windowState = WindowStateStorage.WindowStateFullscreen;
926934 }
927935 }
928936 }
@@ -1024,6 +1032,7 @@ FocusScope {
10241032 animationsEnabled = (animated === undefined) || animated;
10251033 windowState = state || WindowStateStorage.WindowStateRestored;
10261034 windowState &= ~WindowStateStorage.WindowStateMinimized; // clear the minimized bit
1035+ prevWindowState = windowState;
10271036 }
10281037
10291038 function playFocusAnimation() {