on xenial help sign in
Cancel the drag as soon as we're entering the spread (LP: #1668642)
89290b0Lukáš Tinkl
qml/Stage/DecoratedWindow.qml+4
@@ -80,6 +80,10 @@ FocusScope {
80 signal decorationPressed()
80 signal decorationPressed()
81 signal decorationReleased()
81 signal decorationReleased()
82
82
83+ function cancelDrag() {
84+ moveHandler.cancelDrag();
85+ }
86+
83 QtObject {
87 QtObject {
84 id: d
88 id: d
85 property int requestedDecorationHeight: root.hasDecoration ? decoration.height : 0
89 property int requestedDecorationHeight: root.hasDecoration ? decoration.height : 0
qml/Stage/MoveHandler.qml+9
@@ -190,4 +190,13 @@ QtObject {
190 target.restoredY = target.y;
190 target.restoredY = target.y;
191 }
191 }
192 }
192 }
193+
194+ function cancelDrag() {
195+ priv.dragging = false;
196+ root.stopFakeAnimation();
197+ priv.mouseDownTimer.stop();
198+ Mir.cursorName = "";
199+ priv.progress = 0;
200+ priv.resetEdges();
201+ }
193}
202}
qml/Stage/Stage.qml+2
@@ -1188,6 +1188,7 @@ FocusScope {
1188 states: [
1188 states: [
1189 State {
1189 State {
1190 name: "spread"; when: root.state == "spread"
1190 name: "spread"; when: root.state == "spread"
1191+ StateChangeScript { script: { decoratedWindow.cancelDrag(); } }
1191 PropertyChanges {
1192 PropertyChanges {
1192 target: decoratedWindow;
1193 target: decoratedWindow;
1193 showDecoration: false;
1194 showDecoration: false;
@@ -1214,6 +1215,7 @@ FocusScope {
1214 }
1215 }
1215 PropertyChanges { target: dragArea; enabled: true }
1216 PropertyChanges { target: dragArea; enabled: true }
1216 PropertyChanges { target: windowInfoItem; opacity: spreadMaths.tileInfoOpacity; visible: spreadMaths.itemVisible }
1217 PropertyChanges { target: windowInfoItem; opacity: spreadMaths.tileInfoOpacity; visible: spreadMaths.itemVisible }
1218+ PropertyChanges { target: touchControls; enabled: false }
1217 },
1219 },
1218 State {
1220 State {
1219 name: "stagedRightEdge"
1221 name: "stagedRightEdge"
tests/qmltests/Stage/tst_DesktopStage.qml+26
@@ -771,6 +771,32 @@ Item {
771 tryCompareFunction(function(){return posBefore == posAfter;}, data.button !== Qt.LeftButton ? true : false);
771 tryCompareFunction(function(){return posBefore == posAfter;}, data.button !== Qt.LeftButton ? true : false);
772 }
772 }
773
773
774+ function test_spreadDisablesWindowDrag() {
775+ var appDelegate = startApplication("dialer-app");
776+ verify(appDelegate);
777+ var decoration = findChild(appDelegate, "appWindowDecoration");
778+ verify(decoration);
779+
780+ // grab the decoration
781+ mousePress(decoration);
782+
783+ // enter the spread
784+ keyPress(Qt.Key_W, Qt.MetaModifier)
785+ tryCompare(stage, "state", "spread");
786+
787+ // try to drag the window
788+ mouseMove(decoration, 10, 10, 200);
789+
790+ // verify it's not moving even before we release the decoration drag
791+ tryCompare(appDelegate, "dragging", false);
792+
793+ // cleanup
794+ mouseRelease(decoration);
795+ keyRelease(Qt.Key_W, Qt.MetaModifier);
796+ stage.closeSpread();
797+ tryCompare(stage, "state", "windowed");
798+ }
799+
774 // regression test for https://bugs.launchpad.net/ubuntu/+source/unity8/+bug/1627281
800 // regression test for https://bugs.launchpad.net/ubuntu/+source/unity8/+bug/1627281
775 function test_doubleTapToMaximizeWindow() {
801 function test_doubleTapToMaximizeWindow() {
776 var dialerAppDelegate = startApplication("dialer-app");
802 var dialerAppDelegate = startApplication("dialer-app");