on xenial help sign in
fix double click behavior, move it back to decoration where it belongs
223bd31Lukáš Tinkl
qml/Stages/DecoratedWindow.qml+2−4
@@ -54,6 +54,7 @@ FocusScope {
54 property alias overlayShown: decoration.overlayShown
54 property alias overlayShown: decoration.overlayShown
55 property alias stageWidth: moveHandler.stageWidth
55 property alias stageWidth: moveHandler.stageWidth
56 property alias stageHeight: moveHandler.stageHeight
56 property alias stageHeight: moveHandler.stageHeight
57+ readonly property alias moveHandler: moveHandler
57
58
58 signal closeClicked()
59 signal closeClicked()
59 signal maximizeClicked()
60 signal maximizeClicked()
@@ -113,9 +114,8 @@ FocusScope {
113 onMinimizeClicked: root.minimizeClicked();
114 onMinimizeClicked: root.minimizeClicked();
114 onPressed: root.decorationPressed();
115 onPressed: root.decorationPressed();
115
116
116− onDoubleClicked: moveHandler.handleDoubleClicked(mouse)
117 onPressedChanged: moveHandler.handlePressedChanged(pressed, pressedButtons, mouseX, mouseY)
117 onPressedChanged: moveHandler.handlePressedChanged(pressed, pressedButtons, mouseX, mouseY)
118− onPositionChanged: moveHandler.handlePositionChanged(mouseX, mouseY)
118+ onPositionChanged: moveHandler.handlePositionChanged(mouse)
119 onReleased: moveHandler.handleReleased(mouse)
119 onReleased: moveHandler.handleReleased(mouse)
120 }
120 }
121
121
@@ -134,8 +134,6 @@ FocusScope {
134 onFakeMaximizeBottomLeftAnimationRequested: root.fakeMaximizeBottomLeftAnimationRequested(progress)
134 onFakeMaximizeBottomLeftAnimationRequested: root.fakeMaximizeBottomLeftAnimationRequested(progress)
135 onFakeMaximizeBottomRightAnimationRequested: root.fakeMaximizeBottomRightAnimationRequested(progress)
135 onFakeMaximizeBottomRightAnimationRequested: root.fakeMaximizeBottomRightAnimationRequested(progress)
136 onStopFakeAnimation: root.stopFakeAnimation()
136 onStopFakeAnimation: root.stopFakeAnimation()
137−
138− onDoubleClicked: root.maximizeClicked()
139 }
137 }
140
138
141 ApplicationWindow {
139 ApplicationWindow {
qml/Stages/MoveHandler.qml+10−13
@@ -38,8 +38,6 @@ Item {
38 signal fakeMaximizeBottomRightAnimationRequested(real progress)
38 signal fakeMaximizeBottomRightAnimationRequested(real progress)
39 signal stopFakeAnimation()
39 signal stopFakeAnimation()
40
40
41− signal doubleClicked()
42−
43 QtObject {
41 QtObject {
44 id: priv
42 id: priv
45 property real distanceX
43 property real distanceX
@@ -80,14 +78,6 @@ Item {
80 property real progress: 0
78 property real progress: 0
81 }
79 }
82
80
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−
91 function handlePressedChanged(pressed, pressedButtons, mouseX, mouseY) {
81 function handlePressedChanged(pressed, pressedButtons, mouseX, mouseY) {
92 if (pressed && pressedButtons == Qt.LeftButton) {
82 if (pressed && pressedButtons == Qt.LeftButton) {
93 var pos = mapToItem(target, mouseX, mouseY);
83 var pos = mapToItem(target, mouseX, mouseY);
@@ -107,7 +97,7 @@ Item {
107 }
97 }
108 }
98 }
109
99
110− function handlePositionChanged(mouseX, mouseY) {
100+ function handlePositionChanged(mouse) {
111 if (priv.dragging) {
101 if (priv.dragging) {
112 Mir.cursorName = "grabbing";
102 Mir.cursorName = "grabbing";
113
103
@@ -116,14 +106,14 @@ Item {
116 target.restore(false, WindowStateStorage.WindowStateNormal);
106 target.restore(false, WindowStateStorage.WindowStateNormal);
117 }
107 }
118
108
119− var pos = mapToItem(target.parent, mouseX, mouseY);
109+ var pos = mapToItem(target.parent, mouse.x, mouse.y);
120 // Use integer coordinate values to ensure that target is left in a pixel-aligned
110 // Use integer coordinate values to ensure that target is left in a pixel-aligned
121 // position. Mouse movement could have subpixel precision, yielding a fractional
111 // position. Mouse movement could have subpixel precision, yielding a fractional
122 // mouse position.
112 // mouse position.
123 target.requestedX = Math.round(pos.x - priv.distanceX);
113 target.requestedX = Math.round(pos.x - priv.distanceX);
124 target.requestedY = Math.round(Math.max(pos.y - priv.distanceY, PanelState.panelHeight));
114 target.requestedY = Math.round(Math.max(pos.y - priv.distanceY, PanelState.panelHeight));
125
115
126− var globalPos = mapToItem(null, mouseX, mouseY);
116+ var globalPos = mapToItem(null, mouse.x, mouse.y);
127 var globalX = globalPos.x;
117 var globalX = globalPos.x;
128 var globalY = globalPos.y;
118 var globalY = globalPos.y;
129 if (globalX < priv.triggerArea && globalY < PanelState.panelHeight) { // top left
119 if (globalX < priv.triggerArea && globalY < PanelState.panelHeight) { // top left
@@ -197,18 +187,25 @@ Item {
197 root.stopFakeAnimation();
187 root.stopFakeAnimation();
198 } else if (priv.nearLeftEdge) {
188 } else if (priv.nearLeftEdge) {
199 target.maximizeLeft();
189 target.maximizeLeft();
190+ priv.resetEdges();
200 } else if (priv.nearTopEdge) {
191 } else if (priv.nearTopEdge) {
201 target.maximize();
192 target.maximize();
193+ priv.resetEdges();
202 } else if (priv.nearRightEdge) {
194 } else if (priv.nearRightEdge) {
203 target.maximizeRight();
195 target.maximizeRight();
196+ priv.resetEdges();
204 } else if (priv.nearTopLeftCorner) {
197 } else if (priv.nearTopLeftCorner) {
205 target.maximizeTopLeft();
198 target.maximizeTopLeft();
199+ priv.resetEdges();
206 } else if (priv.nearTopRightCorner) {
200 } else if (priv.nearTopRightCorner) {
207 target.maximizeTopRight();
201 target.maximizeTopRight();
202+ priv.resetEdges();
208 } else if (priv.nearBottomLeftCorner) {
203 } else if (priv.nearBottomLeftCorner) {
209 target.maximizeBottomLeft();
204 target.maximizeBottomLeft();
205+ priv.resetEdges();
210 } else if (priv.nearBottomRightCorner) {
206 } else if (priv.nearBottomRightCorner) {
211 target.maximizeBottomRight();
207 target.maximizeBottomRight();
208+ priv.resetEdges();
212 }
209 }
213 }
210 }
214}
211}
qml/Stages/WindowDecoration.qml+6
@@ -39,6 +39,12 @@ MouseArea {
39 signal maximizeHorizontallyClicked()
39 signal maximizeHorizontallyClicked()
40 signal maximizeVerticallyClicked()
40 signal maximizeVerticallyClicked()
41
41
42+ onDoubleClicked: {
43+ if (target.canBeMaximized && mouse.button == Qt.LeftButton) {
44+ root.maximizeClicked();
45+ }
46+ }
47+
42 // do not let unhandled wheel event pass thru the decoration
48 // do not let unhandled wheel event pass thru the decoration
43 onWheel: wheel.accepted = true;
49 onWheel: wheel.accepted = true;
44
50