on xenial help sign in
fix double click behavior, move it back to decoration where it belongs
commit223bd318b2572defd96bcd5cf5c54a35e6a2f40e authorLukáš Tinkl <lukas.tinkl@canonical.com> dateWed 24 Aug 2016, 12:38 (10 years ago) parent8bfb5eb
3 files changed+18−17
qml/Stages/DecoratedWindow.qml+2−4 qml/Stages/MoveHandler.qml+10−13 qml/Stages/WindowDecoration.qml+6
qml/Stages/DecoratedWindow.qml+2−4
@@ -54,6 +54,7 @@ FocusScope {
5454 property alias overlayShown: decoration.overlayShown
5555 property alias stageWidth: moveHandler.stageWidth
5656 property alias stageHeight: moveHandler.stageHeight
57+ readonly property alias moveHandler: moveHandler
5758
5859 signal closeClicked()
5960 signal maximizeClicked()
@@ -113,9 +114,8 @@ FocusScope {
113114 onMinimizeClicked: root.minimizeClicked();
114115 onPressed: root.decorationPressed();
115116
116− onDoubleClicked: moveHandler.handleDoubleClicked(mouse)
117117 onPressedChanged: moveHandler.handlePressedChanged(pressed, pressedButtons, mouseX, mouseY)
118− onPositionChanged: moveHandler.handlePositionChanged(mouseX, mouseY)
118+ onPositionChanged: moveHandler.handlePositionChanged(mouse)
119119 onReleased: moveHandler.handleReleased(mouse)
120120 }
121121
@@ -134,8 +134,6 @@ FocusScope {
134134 onFakeMaximizeBottomLeftAnimationRequested: root.fakeMaximizeBottomLeftAnimationRequested(progress)
135135 onFakeMaximizeBottomRightAnimationRequested: root.fakeMaximizeBottomRightAnimationRequested(progress)
136136 onStopFakeAnimation: root.stopFakeAnimation()
137−
138− onDoubleClicked: root.maximizeClicked()
139137 }
140138
141139 ApplicationWindow {
qml/Stages/MoveHandler.qml+10−13
@@ -38,8 +38,6 @@ Item {
3838 signal fakeMaximizeBottomRightAnimationRequested(real progress)
3939 signal stopFakeAnimation()
4040
41− signal doubleClicked()
42−
4341 QtObject {
4442 id: priv
4543 property real distanceX
@@ -80,14 +78,6 @@ Item {
8078 property real progress: 0
8179 }
8280
83− function handleDoubleClicked(mouse) {
84− priv.resetEdges();
85− if (target.canBeMaximized && mouse.button == Qt.LeftButton) {
86− priv.dragging = false; // do not interfere with a quick double click followed by a mouse move/drag
87− root.doubleClicked();
88− }
89− }
90−
9181 function handlePressedChanged(pressed, pressedButtons, mouseX, mouseY) {
9282 if (pressed && pressedButtons == Qt.LeftButton) {
9383 var pos = mapToItem(target, mouseX, mouseY);
@@ -107,7 +97,7 @@ Item {
10797 }
10898 }
10999
110− function handlePositionChanged(mouseX, mouseY) {
100+ function handlePositionChanged(mouse) {
111101 if (priv.dragging) {
112102 Mir.cursorName = "grabbing";
113103
@@ -116,14 +106,14 @@ Item {
116106 target.restore(false, WindowStateStorage.WindowStateNormal);
117107 }
118108
119− var pos = mapToItem(target.parent, mouseX, mouseY);
109+ var pos = mapToItem(target.parent, mouse.x, mouse.y);
120110 // Use integer coordinate values to ensure that target is left in a pixel-aligned
121111 // position. Mouse movement could have subpixel precision, yielding a fractional
122112 // mouse position.
123113 target.requestedX = Math.round(pos.x - priv.distanceX);
124114 target.requestedY = Math.round(Math.max(pos.y - priv.distanceY, PanelState.panelHeight));
125115
126− var globalPos = mapToItem(null, mouseX, mouseY);
116+ var globalPos = mapToItem(null, mouse.x, mouse.y);
127117 var globalX = globalPos.x;
128118 var globalY = globalPos.y;
129119 if (globalX < priv.triggerArea && globalY < PanelState.panelHeight) { // top left
@@ -197,18 +187,25 @@ Item {
197187 root.stopFakeAnimation();
198188 } else if (priv.nearLeftEdge) {
199189 target.maximizeLeft();
190+ priv.resetEdges();
200191 } else if (priv.nearTopEdge) {
201192 target.maximize();
193+ priv.resetEdges();
202194 } else if (priv.nearRightEdge) {
203195 target.maximizeRight();
196+ priv.resetEdges();
204197 } else if (priv.nearTopLeftCorner) {
205198 target.maximizeTopLeft();
199+ priv.resetEdges();
206200 } else if (priv.nearTopRightCorner) {
207201 target.maximizeTopRight();
202+ priv.resetEdges();
208203 } else if (priv.nearBottomLeftCorner) {
209204 target.maximizeBottomLeft();
205+ priv.resetEdges();
210206 } else if (priv.nearBottomRightCorner) {
211207 target.maximizeBottomRight();
208+ priv.resetEdges();
212209 }
213210 }
214211}
qml/Stages/WindowDecoration.qml+6
@@ -39,6 +39,12 @@ MouseArea {
3939 signal maximizeHorizontallyClicked()
4040 signal maximizeVerticallyClicked()
4141
42+ onDoubleClicked: {
43+ if (target.canBeMaximized && mouse.button == Qt.LeftButton) {
44+ root.maximizeClicked();
45+ }
46+ }
47+
4248 // do not let unhandled wheel event pass thru the decoration
4349 onWheel: wheel.accepted = true;
4450