on xenial help sign in
fix window sizes
commit3ef0af1f1a038191385d18c47d47200b7139f2c9 authorNick Dedekind <nick.dedekind@canonical.com> dateTue 16 Feb 2016, 18:45 (11 years ago) parent982fabe
4 files changed+63−13
qml/Shell.qml+5−1 qml/Stages/AbstractStage.qml+2 qml/Stages/DesktopStage.qml+54−11 qml/Stages/WindowResizeArea.qml+2−1
qml/Shell.qml+5−1
@@ -242,7 +242,7 @@ Item {
242242 property string usageScenario: shell.usageScenario === "phone" || greeter.hasLockedApp
243243 ? "phone"
244244 : shell.usageScenario
245− source: {
245+ property string qmlComponent: {
246246 if(shell.mode === "greeter") {
247247 return "Stages/ShimStage.qml"
248248 } else if (applicationsDisplayLoader.usageScenario === "phone") {
@@ -253,6 +253,10 @@ Item {
253253 return "Stages/DesktopStage.qml";
254254 }
255255 }
256+ onQmlComponentChanged: {
257+ if (item) item.saveWindowState();
258+ source = qmlComponent;
259+ }
256260
257261 property bool interactive: tutorial.spreadEnabled
258262 && (!greeter || !greeter.shown)
qml/Stages/AbstractStage.qml+2
@@ -50,6 +50,8 @@ Rectangle {
5050 | Qt.InvertedPortraitOrientation
5151 | Qt.InvertedLandscapeOrientation
5252
53+ signal saveWindowState
54+
5355 // Shared code for use in stage implementations
5456 GSettings {
5557 id: lifecycleExceptions
qml/Stages/DesktopStage.qml+54−11
@@ -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;
qml/Stages/WindowResizeArea.qml+2−1
@@ -40,6 +40,7 @@ MouseArea {
4040 property int defaultHeight: units.gu(50)
4141 property int screenWidth: 0
4242 property int screenHeight: 0
43+ property bool saveStateOnDestruction: true
4344
4445 QtObject {
4546 id: priv
@@ -84,7 +85,7 @@ MouseArea {
8485 priv.updateNormalGeometry();
8586 }
8687
87− Component.onDestruction: {
88+ function saveWindowState() {
8889 windowStateStorage.saveState(root.windowId, target.state == "maximized" ? WindowStateStorage.WindowStateMaximized : WindowStateStorage.WindowStateNormal)
8990 windowStateStorage.saveGeometry(root.windowId, Qt.rect(priv.normalX, priv.normalY, priv.normalWidth, priv.normalHeight))
9091 }