@@ -254,8 +254,8 @@ AbstractStage {
254254 focus: appId === priv.focusedAppId
255255 width: decoratedWindow.width
256256 height: decoratedWindow.height
257− property alias requestedWidth: decoratedWindow.requestedWidth
258− property alias requestedHeight: decoratedWindow.requestedHeight
257+ property int requestedWidth: -1
258+ property int requestedHeight: -1
259259 property alias minimumWidth: decoratedWindow.minimumWidth
260260 property alias minimumHeight: decoratedWindow.minimumHeight
261261 property alias maximumWidth: decoratedWindow.maximumWidth
@@ -372,20 +372,40 @@ AbstractStage {
372372 PropertyChanges {
373373 target: appDelegate;
374374 x: 0; y: 0;
375− requestedWidth: root.width; requestedHeight: root.height;
376375 visuallyMinimized: false;
377376 visuallyMaximized: true
378377 }
378+ PropertyChanges {
379+ target: decoratedWindow
380+ requestedWidth: root.width;
381+ requestedHeight: root.height;
382+ }
379383 },
380384 State {
381385 name: "maximizedLeft"; when: appDelegate.maximizedLeft && !appDelegate.minimized
382− PropertyChanges { target: appDelegate; x: 0; y: PanelState.panelHeight;
383− requestedWidth: root.width/2; requestedHeight: root.height - PanelState.panelHeight }
386+ PropertyChanges {
387+ target: appDelegate;
388+ x: 0;
389+ y: PanelState.panelHeight;
390+ }
391+ PropertyChanges {
392+ target: decoratedWindow
393+ requestedWidth: root.width/2
394+ requestedHeight: root.height - PanelState.panelHeight
395+ }
384396 },
385397 State {
386398 name: "maximizedRight"; when: appDelegate.maximizedRight && !appDelegate.minimized
387− PropertyChanges { target: appDelegate; x: root.width/2; y: PanelState.panelHeight;
388− requestedWidth: root.width/2; requestedHeight: root.height - PanelState.panelHeight }
399+ PropertyChanges {
400+ target: appDelegate;
401+ x: root.width/2;
402+ y: PanelState.panelHeight
403+ }
404+ PropertyChanges {
405+ target: decoratedWindow
406+ requestedWidth: root.width/2;
407+ requestedHeight: root.height - PanelState.panelHeight
408+ }
389409 },
390410 State {
391411 name: "minimized"; when: appDelegate.minimized
@@ -405,13 +425,17 @@ AbstractStage {
405425 enabled: appDelegate.animationsEnabled
406426 PropertyAction { target: appDelegate; properties: "visuallyMinimized,visuallyMaximized" }
407427 UbuntuNumberAnimation { target: appDelegate; properties: "x,y,opacity,requestedWidth,requestedHeight,scale"; duration: UbuntuAnimation.FastDuration }
428+ UbuntuNumberAnimation { target: decoratedWindow; properties: "requestedWidth,requestedHeight"; duration: UbuntuAnimation.FastDuration }
408429 },
409430 Transition {
410431 to: "minimized"
411432 enabled: appDelegate.animationsEnabled
412433 PropertyAction { target: appDelegate; property: "visuallyMaximized" }
413434 SequentialAnimation {
414− UbuntuNumberAnimation { target: appDelegate; properties: "x,y,opacity,requestedWidth,requestedHeight,scale"; duration: UbuntuAnimation.FastDuration }
435+ ParallelAnimation {
436+ UbuntuNumberAnimation { target: appDelegate; properties: "x,y,opacity,scale"; duration: UbuntuAnimation.FastDuration }
437+ UbuntuNumberAnimation { target: decoratedWindow; properties: "requestedWidth,requestedHeight"; duration: UbuntuAnimation.FastDuration }
438+ }
415439 PropertyAction { target: appDelegate; property: "visuallyMinimized" }
416440 ScriptAction {
417441 script: {
@@ -427,7 +451,10 @@ AbstractStage {
427451 enabled: appDelegate.animationsEnabled
428452 PropertyAction { target: appDelegate; property: "visuallyMinimized" }
429453 SequentialAnimation {
430− UbuntuNumberAnimation { target: appDelegate; properties: "x,y,opacity,requestedWidth,requestedHeight,scale"; duration: UbuntuAnimation.FastDuration }
454+ ParallelAnimation {
455+ UbuntuNumberAnimation { target: appDelegate; properties: "x,y,opacity,scale"; duration: UbuntuAnimation.FastDuration }
456+ UbuntuNumberAnimation { target: decoratedWindow; properties: "requestedWidth,requestedHeight"; duration: UbuntuAnimation.FastDuration }
457+ }
431458 PropertyAction { target: appDelegate; property: "visuallyMaximized" }
432459 }
433460 }
@@ -448,6 +475,7 @@ AbstractStage {
448475 }
449476
450477 WindowResizeArea {
478+ id: resizeArea
451479 objectName: "windowResizeArea"
452480 target: appDelegate
453481 minWidth: units.gu(10)
@@ -458,6 +486,20 @@ AbstractStage {
458486 screenHeight: root.height
459487
460488 onPressed: { ApplicationManager.focusApplication(model.appId) }
489+
490+ property bool saveStateOnDestruction: true
491+ Connections {
492+ target: root
493+ onSaveWindowState: {
494+ resizeArea.saveWindowState();
495+ resizeArea.saveStateOnDestruction = false;
496+ }
497+ }
498+ Component.onDestruction: {
499+ if (saveStateOnDestruction) {
500+ saveWindowState();
501+ }
502+ }
461503 }
462504
463505 DecoratedWindow {
@@ -470,6 +512,9 @@ AbstractStage {
470512 focus: true
471513 fullscreen: application.fullscreen
472514
515+ requestedWidth: appDelegate.requestedWidth
516+ requestedHeight: appDelegate.requestedHeight
517+
473518 onClose: ApplicationManager.stopApplication(model.appId)
474519 onMaximize: appDelegate.maximized || appDelegate.maximizedLeft || appDelegate.maximizedRight
475520 ? appDelegate.restoreFromMaximized() : appDelegate.maximize()
@@ -485,8 +530,6 @@ AbstractStage {
485530 if (!firstTimeSurface) return;
486531 firstTimeSurface = false;
487532
488− console.log("FULLSCREEN CHECK", lastSurface.state, lastSurface.shellChrome)
489−
490533 if (lastSurface.state === Mir.FullscreenState &&
491534 lastSurface.shellChrome === Mir.LowChrome) {
492535 lastSurface.state = Mir.RestoredState;