@@ -255,8 +255,8 @@ AbstractStage {
255255 focus: appId === priv.focusedAppId
256256 width: decoratedWindow.width
257257 height: decoratedWindow.height
258− property alias requestedWidth: decoratedWindow.requestedWidth
259− property alias requestedHeight: decoratedWindow.requestedHeight
258+ property int requestedWidth: -1
259+ property int requestedHeight: -1
260260 property alias minimumWidth: decoratedWindow.minimumWidth
261261 property alias minimumHeight: decoratedWindow.minimumHeight
262262 property alias maximumWidth: decoratedWindow.maximumWidth
@@ -388,20 +388,40 @@ AbstractStage {
388388 PropertyChanges {
389389 target: appDelegate;
390390 x: root.leftMargin; y: 0;
391− requestedWidth: appContainer.width - root.leftMargin; requestedHeight: appContainer.height;
392391 visuallyMinimized: false;
393392 visuallyMaximized: true
394393 }
394+ PropertyChanges {
395+ target: decoratedWindow
396+ requestedWidth: root.width;
397+ requestedHeight: root.height;
398+ }
395399 },
396400 State {
397401 name: "maximizedLeft"; when: appDelegate.maximizedLeft && !appDelegate.minimized
398− PropertyChanges { target: appDelegate; x: root.leftMargin; y: PanelState.panelHeight;
399− requestedWidth: (appContainer.width - root.leftMargin)/2; requestedHeight: appContainer.height - PanelState.panelHeight }
402+ PropertyChanges {
403+ target: appDelegate
404+ x: root.leftMargin
405+ y: PanelState.panelHeight
406+ }
407+ PropertyChanges {
408+ target: decoratedWindow
409+ requestedWidth: (appContainer.width - root.leftMargin)/2
410+ requestedHeight: appContainer.height - PanelState.panelHeight
411+ }
400412 },
401413 State {
402414 name: "maximizedRight"; when: appDelegate.maximizedRight && !appDelegate.minimized
403− PropertyChanges { target: appDelegate; x: (appContainer.width + root.leftMargin)/2; y: PanelState.panelHeight;
404− requestedWidth: (appContainer.width - root.leftMargin)/2; requestedHeight: appContainer.height - PanelState.panelHeight }
415+ PropertyChanges {
416+ target: appDelegate;
417+ x: (appContainer.width + root.leftMargin)/2
418+ y: PanelState.panelHeight
419+ }
420+ PropertyChanges {
421+ target: decoratedWindow
422+ requestedWidth: (appContainer.width - root.leftMargin)/2
423+ requestedHeight: appContainer.height - PanelState.panelHeight
424+ }
405425 },
406426 State {
407427 name: "minimized"; when: appDelegate.minimized
@@ -421,13 +441,17 @@ AbstractStage {
421441 enabled: appDelegate.animationsEnabled
422442 PropertyAction { target: appDelegate; properties: "visuallyMinimized,visuallyMaximized" }
423443 UbuntuNumberAnimation { target: appDelegate; properties: "x,y,opacity,requestedWidth,requestedHeight,scale"; duration: UbuntuAnimation.FastDuration }
444+ UbuntuNumberAnimation { target: decoratedWindow; properties: "requestedWidth,requestedHeight"; duration: UbuntuAnimation.FastDuration }
424445 },
425446 Transition {
426447 to: "minimized"
427448 enabled: appDelegate.animationsEnabled
428449 PropertyAction { target: appDelegate; property: "visuallyMaximized" }
429450 SequentialAnimation {
430− UbuntuNumberAnimation { target: appDelegate; properties: "x,y,opacity,requestedWidth,requestedHeight,scale"; duration: UbuntuAnimation.FastDuration }
451+ ParallelAnimation {
452+ UbuntuNumberAnimation { target: appDelegate; properties: "x,y,opacity,scale"; duration: UbuntuAnimation.FastDuration }
453+ UbuntuNumberAnimation { target: decoratedWindow; properties: "requestedWidth,requestedHeight"; duration: UbuntuAnimation.FastDuration }
454+ }
431455 PropertyAction { target: appDelegate; property: "visuallyMinimized" }
432456 ScriptAction {
433457 script: {
@@ -443,7 +467,10 @@ AbstractStage {
443467 enabled: appDelegate.animationsEnabled
444468 PropertyAction { target: appDelegate; property: "visuallyMinimized" }
445469 SequentialAnimation {
446− UbuntuNumberAnimation { target: appDelegate; properties: "x,y,opacity,requestedWidth,requestedHeight,scale"; duration: UbuntuAnimation.FastDuration }
470+ ParallelAnimation {
471+ UbuntuNumberAnimation { target: appDelegate; properties: "x,y,opacity,scale"; duration: UbuntuAnimation.FastDuration }
472+ UbuntuNumberAnimation { target: decoratedWindow; properties: "requestedWidth,requestedHeight"; duration: UbuntuAnimation.FastDuration }
473+ }
447474 PropertyAction { target: appDelegate; property: "visuallyMaximized" }
448475 }
449476 }
@@ -458,6 +485,7 @@ AbstractStage {
458485 }
459486
460487 WindowResizeArea {
488+ id: resizeArea
461489 objectName: "windowResizeArea"
462490 target: appDelegate
463491 minWidth: units.gu(10)
@@ -469,6 +497,21 @@ AbstractStage {
469497 leftMargin: root.leftMargin
470498
471499 onPressed: { ApplicationManager.focusApplication(model.appId) }
500+
501+ property bool saveStateOnDestruction: true
502+ Connections {
503+ target: root
504+ onStageAboutToBeUnloaded: {
505+ resizeArea.saveWindowState();
506+ resizeArea.saveStateOnDestruction = false;
507+ fullscreenPolicy.active = false;
508+ }
509+ }
510+ Component.onDestruction: {
511+ if (saveStateOnDestruction) {
512+ saveWindowState();
513+ }
514+ }
472515 }
473516
474517 DecoratedWindow {
@@ -480,12 +523,21 @@ AbstractStage {
480523 active: ApplicationManager.focusedApplicationId === model.appId
481524 focus: true
482525
526+ requestedWidth: appDelegate.requestedWidth
527+ requestedHeight: appDelegate.requestedHeight
528+
483529 onClose: ApplicationManager.stopApplication(model.appId)
484530 onMaximize: appDelegate.maximized || appDelegate.maximizedLeft || appDelegate.maximizedRight
485531 ? appDelegate.restoreFromMaximized() : appDelegate.maximize()
486532 onMinimize: appDelegate.minimize()
487533 onDecorationPressed: { ApplicationManager.focusApplication(model.appId) }
488534 }
535+
536+ WindowedFullscreenPolicy {
537+ id: fullscreenPolicy
538+ active: true
539+ application: decoratedWindow.application
540+ }
489541 }
490542 }
491543 }