on xenial help sign in
Move the normalFoo properties around
cbad34dDaniel d'Andrada
qml/Stage/MoveHandler.qml+2−2
@@ -85,8 +85,8 @@ QtObject {
85 if (target.anyMaximized) {
85 if (target.anyMaximized) {
86 // keep distanceX relative to the normal window width minus the window control buttons (+spacing)
86 // keep distanceX relative to the normal window width minus the window control buttons (+spacing)
87 // so that dragging it back doesn't make the window jump around to weird positions, away from the mouse pointer
87 // so that dragging it back doesn't make the window jump around to weird positions, away from the mouse pointer
88− priv.distanceX = MathUtils.clampAndProject(pos.x, 0, target.width, buttonsWidth, target.resizeArea.normalWidth);
88+ priv.distanceX = MathUtils.clampAndProject(pos.x, 0, target.width, buttonsWidth, target.normalWidth);
89− priv.distanceY = MathUtils.clampAndProject(pos.y, 0, target.height, 0, target.resizeArea.normalHeight);
89+ priv.distanceY = MathUtils.clampAndProject(pos.y, 0, target.height, 0, target.normalHeight);
90 } else {
90 } else {
91 priv.distanceX = pos.x;
91 priv.distanceX = pos.x;
92 priv.distanceY = pos.y;
92 priv.distanceY = pos.y;
qml/Stage/Stage.qml+23
@@ -707,6 +707,29 @@ FocusScope {
707 property real restoredX
707 property real restoredX
708 property real restoredY
708 property real restoredY
709
709
710+ // Keeps track of the window geometry while in normal or restored state
711+ // Useful when returning from some maxmized state or when saving the geometry while maximized
712+ // FIXME: find a better solution
713+ property real normalX: 0
714+ property real normalY: 0
715+ property real normalWidth: 0
716+ property real normalHeight: 0
717+ function updateNormalGeometry() {
718+ if (appDelegate.state == "normal" || appDelegate.state == "restored") {
719+ normalX = appDelegate.requestedX;
720+ normalY = appDelegate.requestedY;
721+ normalWidth = appDelegate.width;
722+ normalHeight = appDelegate.height;
723+ }
724+ }
725+ Connections {
726+ target: appDelegate
727+ onXChanged: appDelegate.updateNormalGeometry();
728+ onYChanged: appDelegate.updateNormalGeometry();
729+ onWidthChanged: appDelegate.updateNormalGeometry();
730+ onHeightChanged: appDelegate.updateNormalGeometry();
731+ }
732+
710 Binding {
733 Binding {
711 target: appDelegate
734 target: appDelegate
712 property: "y"
735 property: "y"
qml/Stage/WindowResizeArea.qml−33
@@ -27,8 +27,6 @@ MouseArea {
27 hoverEnabled: target && !target.maximized // don't grab the resize under the panel
27 hoverEnabled: target && !target.maximized // don't grab the resize under the panel
28
28
29 readonly property alias dragging: d.dragging
29 readonly property alias dragging: d.dragging
30− readonly property alias normalWidth: priv.normalWidth
31− readonly property alias normalHeight: priv.normalHeight
32
30
33 // The target item managed by this. Must be a parent or a sibling
31 // The target item managed by this. Must be a parent or a sibling
34 // The area will anchor to it and manage resize events
32 // The area will anchor to it and manage resize events
@@ -38,37 +36,6 @@ MouseArea {
38 property int minWidth: 0
36 property int minWidth: 0
39 property int minHeight: 0
37 property int minHeight: 0
40
38
41− function init() {
42− priv.updateNormalGeometry();
43− }
44−
45− QtObject {
46− id: priv
47− objectName: "priv"
48−
49− property int normalX: 0
50− property int normalY: 0
51− property int normalWidth: 0
52− property int normalHeight: 0
53−
54− function updateNormalGeometry() {
55− if (root.target.state == "normal" || root.target.state == "restored") {
56− normalX = root.target.requestedX
57− normalY = root.target.requestedY
58− normalWidth = root.target.width
59− normalHeight = root.target.height
60− }
61− }
62− }
63−
64− Connections {
65− target: root.target
66− onXChanged: priv.updateNormalGeometry();
67− onYChanged: priv.updateNormalGeometry();
68− onWidthChanged: priv.updateNormalGeometry();
69− onHeightChanged: priv.updateNormalGeometry();
70− }
71−
72 QtObject {
39 QtObject {
73 id: d
40 id: d
74
41
qml/Stage/WindowStateSaver.qml+5−4
@@ -44,9 +44,11 @@ QtObject {
44 var windowState = WindowStateStorage.getState(target.appId, WindowStateStorage.WindowStateNormal)
44 var windowState = WindowStateStorage.getState(target.appId, WindowStateStorage.WindowStateNormal)
45 target.restore(false /* animated */, windowState);
45 target.restore(false /* animated */, windowState);
46
46
47+ target.updateNormalGeometry();
48+
47 // initialize the x/y to restore to
49 // initialize the x/y to restore to
48− target.restoredX = windowGeometry.x;
50+ target.restoredX = target.normalX;
49− target.restoredY = windowGeometry.y;
51+ target.restoredY = target.normalY;
50 }
52 }
51
53
52 function save() {
54 function save() {
@@ -56,7 +58,6 @@ QtObject {
56 }
58 }
57
59
58 WindowStateStorage.saveState(target.appId, state & ~WindowStateStorage.WindowStateMinimized); // clear the minimized bit when saving
60 WindowStateStorage.saveState(target.appId, state & ~WindowStateStorage.WindowStateMinimized); // clear the minimized bit when saving
59− WindowStateStorage.saveGeometry(target.appId, Qt.rect(target.windowedX, target.windowedY,
61+ WindowStateStorage.saveGeometry(target.appId, Qt.rect(target.normalX, target.normalY, target.normalWidth, target.normalHeight));
60− target.windowedWidth, target.windowedHeight));
61 }
62 }
62}
63}