on xenial help sign in
Fix resize of top/left borders for slow surfaces
dd7cd9fDaniel d'Andrada
qml/Stages/WindowResizeArea.qml+28−2
@@ -59,6 +59,18 @@ MouseArea {
59 property bool topBorder: false
59 property bool topBorder: false
60 property bool bottomBorder: false
60 property bool bottomBorder: false
61
61
62+ // true - A change in surface size will cause the left border of the window to move accordingly.
63+ // The window's right border will stay in the same position.
64+ // false - a change in surface size will cause the right border of the window to move accordingly.
65+ // The window's left border will stay in the same position.
66+ property bool moveLeftBorder: false
67+
68+ // true - A change in surface size will cause the top border of the window to move accordingly.
69+ // The window's bottom border will stay in the same position.
70+ // false - a change in surface size will cause the bottom border of the window to move accordingly.
71+ // The window's top border will stay in the same position.
72+ property bool moveTopBorder: false
73+
62 property bool dragging: false
74 property bool dragging: false
63 property real startMousePosX
75 property real startMousePosX
64 property real startMousePosY
76 property real startMousePosY
@@ -106,11 +118,24 @@ MouseArea {
106 }
118 }
107 }
119 }
108
120
121+ Timer {
122+ id: resetBordersToMoveTimer
123+ interval: 2000
124+ onTriggered: {
125+ d.moveLeftBorder = false;
126+ d.moveTopBorder = false;
127+ }
128+ }
129+
109 onPressedChanged: {
130 onPressedChanged: {
110 var pos = mapToItem(target.parent, mouseX, mouseY);
131 var pos = mapToItem(target.parent, mouseX, mouseY);
111
132
112 if (pressed) {
133 if (pressed) {
113 d.updateBorders();
134 d.updateBorders();
135+ resetBordersToMoveTimer.stop();
136+ d.moveLeftBorder = d.leftBorder;
137+ d.moveTopBorder = d.topBorder;
138+
114 var pos = mapToItem(root.target.parent, mouseX, mouseY);
139 var pos = mapToItem(root.target.parent, mouseX, mouseY);
115 d.startMousePosX = pos.x;
140 d.startMousePosX = pos.x;
116 d.startMousePosY = pos.y;
141 d.startMousePosY = pos.y;
@@ -122,6 +147,7 @@ MouseArea {
122 d.currentHeight = target.height;
147 d.currentHeight = target.height;
123 d.dragging = true;
148 d.dragging = true;
124 } else {
149 } else {
150+ resetBordersToMoveTimer.start();
125 d.dragging = false;
151 d.dragging = false;
126 if (containsMouse) {
152 if (containsMouse) {
127 d.updateBorders();
153 d.updateBorders();
@@ -185,13 +211,13 @@ MouseArea {
185 Connections {
211 Connections {
186 target: root.target
212 target: root.target
187 onWidthChanged: {
213 onWidthChanged: {
188− if (root.pressed && d.leftBorder) {
214+ if (d.moveLeftBorder) {
189 target.x += d.currentWidth - target.width;
215 target.x += d.currentWidth - target.width;
190 }
216 }
191 d.currentWidth = target.width;
217 d.currentWidth = target.width;
192 }
218 }
193 onHeightChanged: {
219 onHeightChanged: {
194− if (root.pressed && d.topBorder) {
220+ if (d.moveTopBorder) {
195 target.y += d.currentHeight - target.height;
221 target.y += d.currentHeight - target.height;
196 }
222 }
197 d.currentHeight = target.height;
223 d.currentHeight = target.height;