on xenial help sign in
fix window sizes
3ef0af1Nick Dedekind
qml/Shell.qml+5−1
@@ -242,7 +242,7 @@ Item {
242 property string usageScenario: shell.usageScenario === "phone" || greeter.hasLockedApp
242 property string usageScenario: shell.usageScenario === "phone" || greeter.hasLockedApp
243 ? "phone"
243 ? "phone"
244 : shell.usageScenario
244 : shell.usageScenario
245− source: {
245+ property string qmlComponent: {
246 if(shell.mode === "greeter") {
246 if(shell.mode === "greeter") {
247 return "Stages/ShimStage.qml"
247 return "Stages/ShimStage.qml"
248 } else if (applicationsDisplayLoader.usageScenario === "phone") {
248 } else if (applicationsDisplayLoader.usageScenario === "phone") {
@@ -253,6 +253,10 @@ Item {
253 return "Stages/DesktopStage.qml";
253 return "Stages/DesktopStage.qml";
254 }
254 }
255 }
255 }
256+ onQmlComponentChanged: {
257+ if (item) item.saveWindowState();
258+ source = qmlComponent;
259+ }
256
260
257 property bool interactive: tutorial.spreadEnabled
261 property bool interactive: tutorial.spreadEnabled
258 && (!greeter || !greeter.shown)
262 && (!greeter || !greeter.shown)
qml/Stages/AbstractStage.qml+2
@@ -50,6 +50,8 @@ Rectangle {
50 | Qt.InvertedPortraitOrientation
50 | Qt.InvertedPortraitOrientation
51 | Qt.InvertedLandscapeOrientation
51 | Qt.InvertedLandscapeOrientation
52
52
53+ signal saveWindowState
54+
53 // Shared code for use in stage implementations
55 // Shared code for use in stage implementations
54 GSettings {
56 GSettings {
55 id: lifecycleExceptions
57 id: lifecycleExceptions
qml/Stages/DesktopStage.qml+54−11
@@ -254,8 +254,8 @@ AbstractStage {
254 focus: appId === priv.focusedAppId
254 focus: appId === priv.focusedAppId
255 width: decoratedWindow.width
255 width: decoratedWindow.width
256 height: decoratedWindow.height
256 height: decoratedWindow.height
257− property alias requestedWidth: decoratedWindow.requestedWidth
257+ property int requestedWidth: -1
258− property alias requestedHeight: decoratedWindow.requestedHeight
258+ property int requestedHeight: -1
259 property alias minimumWidth: decoratedWindow.minimumWidth
259 property alias minimumWidth: decoratedWindow.minimumWidth
260 property alias minimumHeight: decoratedWindow.minimumHeight
260 property alias minimumHeight: decoratedWindow.minimumHeight
261 property alias maximumWidth: decoratedWindow.maximumWidth
261 property alias maximumWidth: decoratedWindow.maximumWidth
@@ -372,20 +372,40 @@ AbstractStage {
372 PropertyChanges {
372 PropertyChanges {
373 target: appDelegate;
373 target: appDelegate;
374 x: 0; y: 0;
374 x: 0; y: 0;
375− requestedWidth: root.width; requestedHeight: root.height;
376 visuallyMinimized: false;
375 visuallyMinimized: false;
377 visuallyMaximized: true
376 visuallyMaximized: true
378 }
377 }
378+ PropertyChanges {
379+ target: decoratedWindow
380+ requestedWidth: root.width;
381+ requestedHeight: root.height;
382+ }
379 },
383 },
380 State {
384 State {
381 name: "maximizedLeft"; when: appDelegate.maximizedLeft && !appDelegate.minimized
385 name: "maximizedLeft"; when: appDelegate.maximizedLeft && !appDelegate.minimized
386+ PropertyChanges {
387+ target: appDelegate;
388+ x: 0;
382− PropertyChanges { target: appDelegate; x: 0; y: PanelState.panelHeight;
389+ y: PanelState.panelHeight;
390+ }
391+ PropertyChanges {
392+ target: decoratedWindow
393+ requestedWidth: root.width/2
383− requestedWidth: root.width/2; requestedHeight: root.height - PanelState.panelHeight }
394+ requestedHeight: root.height - PanelState.panelHeight
395+ }
384 },
396 },
385 State {
397 State {
386 name: "maximizedRight"; when: appDelegate.maximizedRight && !appDelegate.minimized
398 name: "maximizedRight"; when: appDelegate.maximizedRight && !appDelegate.minimized
399+ PropertyChanges {
400+ target: appDelegate;
401+ x: root.width/2;
387− PropertyChanges { target: appDelegate; x: root.width/2; y: PanelState.panelHeight;
402+ y: PanelState.panelHeight
403+ }
404+ PropertyChanges {
405+ target: decoratedWindow
406+ requestedWidth: root.width/2;
388− requestedWidth: root.width/2; requestedHeight: root.height - PanelState.panelHeight }
407+ requestedHeight: root.height - PanelState.panelHeight
408+ }
389 },
409 },
390 State {
410 State {
391 name: "minimized"; when: appDelegate.minimized
411 name: "minimized"; when: appDelegate.minimized
@@ -405,13 +425,17 @@ AbstractStage {
405 enabled: appDelegate.animationsEnabled
425 enabled: appDelegate.animationsEnabled
406 PropertyAction { target: appDelegate; properties: "visuallyMinimized,visuallyMaximized" }
426 PropertyAction { target: appDelegate; properties: "visuallyMinimized,visuallyMaximized" }
407 UbuntuNumberAnimation { target: appDelegate; properties: "x,y,opacity,requestedWidth,requestedHeight,scale"; duration: UbuntuAnimation.FastDuration }
427 UbuntuNumberAnimation { target: appDelegate; properties: "x,y,opacity,requestedWidth,requestedHeight,scale"; duration: UbuntuAnimation.FastDuration }
428+ UbuntuNumberAnimation { target: decoratedWindow; properties: "requestedWidth,requestedHeight"; duration: UbuntuAnimation.FastDuration }
408 },
429 },
409 Transition {
430 Transition {
410 to: "minimized"
431 to: "minimized"
411 enabled: appDelegate.animationsEnabled
432 enabled: appDelegate.animationsEnabled
412 PropertyAction { target: appDelegate; property: "visuallyMaximized" }
433 PropertyAction { target: appDelegate; property: "visuallyMaximized" }
413 SequentialAnimation {
434 SequentialAnimation {
435+ ParallelAnimation {
436+ UbuntuNumberAnimation { target: appDelegate; properties: "x,y,opacity,scale"; duration: UbuntuAnimation.FastDuration }
414− UbuntuNumberAnimation { target: appDelegate; properties: "x,y,opacity,requestedWidth,requestedHeight,scale"; duration: UbuntuAnimation.FastDuration }
437+ UbuntuNumberAnimation { target: decoratedWindow; properties: "requestedWidth,requestedHeight"; duration: UbuntuAnimation.FastDuration }
438+ }
415 PropertyAction { target: appDelegate; property: "visuallyMinimized" }
439 PropertyAction { target: appDelegate; property: "visuallyMinimized" }
416 ScriptAction {
440 ScriptAction {
417 script: {
441 script: {
@@ -427,7 +451,10 @@ AbstractStage {
427 enabled: appDelegate.animationsEnabled
451 enabled: appDelegate.animationsEnabled
428 PropertyAction { target: appDelegate; property: "visuallyMinimized" }
452 PropertyAction { target: appDelegate; property: "visuallyMinimized" }
429 SequentialAnimation {
453 SequentialAnimation {
454+ ParallelAnimation {
455+ UbuntuNumberAnimation { target: appDelegate; properties: "x,y,opacity,scale"; duration: UbuntuAnimation.FastDuration }
430− UbuntuNumberAnimation { target: appDelegate; properties: "x,y,opacity,requestedWidth,requestedHeight,scale"; duration: UbuntuAnimation.FastDuration }
456+ UbuntuNumberAnimation { target: decoratedWindow; properties: "requestedWidth,requestedHeight"; duration: UbuntuAnimation.FastDuration }
457+ }
431 PropertyAction { target: appDelegate; property: "visuallyMaximized" }
458 PropertyAction { target: appDelegate; property: "visuallyMaximized" }
432 }
459 }
433 }
460 }
@@ -448,6 +475,7 @@ AbstractStage {
448 }
475 }
449
476
450 WindowResizeArea {
477 WindowResizeArea {
478+ id: resizeArea
451 objectName: "windowResizeArea"
479 objectName: "windowResizeArea"
452 target: appDelegate
480 target: appDelegate
453 minWidth: units.gu(10)
481 minWidth: units.gu(10)
@@ -458,6 +486,20 @@ AbstractStage {
458 screenHeight: root.height
486 screenHeight: root.height
459
487
460 onPressed: { ApplicationManager.focusApplication(model.appId) }
488 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+ }
461 }
503 }
462
504
463 DecoratedWindow {
505 DecoratedWindow {
@@ -470,6 +512,9 @@ AbstractStage {
470 focus: true
512 focus: true
471 fullscreen: application.fullscreen
513 fullscreen: application.fullscreen
472
514
515+ requestedWidth: appDelegate.requestedWidth
516+ requestedHeight: appDelegate.requestedHeight
517+
473 onClose: ApplicationManager.stopApplication(model.appId)
518 onClose: ApplicationManager.stopApplication(model.appId)
474 onMaximize: appDelegate.maximized || appDelegate.maximizedLeft || appDelegate.maximizedRight
519 onMaximize: appDelegate.maximized || appDelegate.maximizedLeft || appDelegate.maximizedRight
475 ? appDelegate.restoreFromMaximized() : appDelegate.maximize()
520 ? appDelegate.restoreFromMaximized() : appDelegate.maximize()
@@ -485,8 +530,6 @@ AbstractStage {
485 if (!firstTimeSurface) return;
530 if (!firstTimeSurface) return;
486 firstTimeSurface = false;
531 firstTimeSurface = false;
487
532
488− console.log("FULLSCREEN CHECK", lastSurface.state, lastSurface.shellChrome)
489−
490 if (lastSurface.state === Mir.FullscreenState &&
533 if (lastSurface.state === Mir.FullscreenState &&
491 lastSurface.shellChrome === Mir.LowChrome) {
534 lastSurface.shellChrome === Mir.LowChrome) {
492 lastSurface.state = Mir.RestoredState;
535 lastSurface.state = Mir.RestoredState;
qml/Stages/WindowResizeArea.qml+2−1
@@ -40,6 +40,7 @@ MouseArea {
40 property int defaultHeight: units.gu(50)
40 property int defaultHeight: units.gu(50)
41 property int screenWidth: 0
41 property int screenWidth: 0
42 property int screenHeight: 0
42 property int screenHeight: 0
43+ property bool saveStateOnDestruction: true
43
44
44 QtObject {
45 QtObject {
45 id: priv
46 id: priv
@@ -84,7 +85,7 @@ MouseArea {
84 priv.updateNormalGeometry();
85 priv.updateNormalGeometry();
85 }
86 }
86
87
87− Component.onDestruction: {
88+ function saveWindowState() {
88 windowStateStorage.saveState(root.windowId, target.state == "maximized" ? WindowStateStorage.WindowStateMaximized : WindowStateStorage.WindowStateNormal)
89 windowStateStorage.saveState(root.windowId, target.state == "maximized" ? WindowStateStorage.WindowStateMaximized : WindowStateStorage.WindowStateNormal)
89 windowStateStorage.saveGeometry(root.windowId, Qt.rect(priv.normalX, priv.normalY, priv.normalWidth, priv.normalHeight))
90 windowStateStorage.saveGeometry(root.windowId, Qt.rect(priv.normalX, priv.normalY, priv.normalWidth, priv.normalHeight))
90 }
91 }