on xenial help sign in
Cancel the drag as soon as we're entering the spread (LP: #1668642)

Approved by: Michael Zanetti, Unity8 CI Bot

commit89290b06b8ac95fa94e2091eaa0ca9e0ac60120d authorLukáš Tinkl <lukas.tinkl@canonical.com> dateWed 8 Mar 2017, 09:51 (10 years ago) parentbb4ca35b316dd1
4 files changed+41
qml/Stage/DecoratedWindow.qml+4 qml/Stage/MoveHandler.qml+9 qml/Stage/Stage.qml+2 tests/qmltests/Stage/tst_DesktopStage.qml+26
qml/Stage/DecoratedWindow.qml+4
@@ -80,6 +80,10 @@ FocusScope {
8080 signal decorationPressed()
8181 signal decorationReleased()
8282
83+ function cancelDrag() {
84+ moveHandler.cancelDrag();
85+ }
86+
8387 QtObject {
8488 id: d
8589 property int requestedDecorationHeight: root.hasDecoration ? decoration.height : 0
qml/Stage/MoveHandler.qml+9
@@ -190,4 +190,13 @@ QtObject {
190190 target.restoredY = target.y;
191191 }
192192 }
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+ }
193202}
qml/Stage/Stage.qml+2
@@ -1188,6 +1188,7 @@ FocusScope {
11881188 states: [
11891189 State {
11901190 name: "spread"; when: root.state == "spread"
1191+ StateChangeScript { script: { decoratedWindow.cancelDrag(); } }
11911192 PropertyChanges {
11921193 target: decoratedWindow;
11931194 showDecoration: false;
@@ -1214,6 +1215,7 @@ FocusScope {
12141215 }
12151216 PropertyChanges { target: dragArea; enabled: true }
12161217 PropertyChanges { target: windowInfoItem; opacity: spreadMaths.tileInfoOpacity; visible: spreadMaths.itemVisible }
1218+ PropertyChanges { target: touchControls; enabled: false }
12171219 },
12181220 State {
12191221 name: "stagedRightEdge"
tests/qmltests/Stage/tst_DesktopStage.qml+26
@@ -771,6 +771,32 @@ Item {
771771 tryCompareFunction(function(){return posBefore == posAfter;}, data.button !== Qt.LeftButton ? true : false);
772772 }
773773
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+
774800 // regression test for https://bugs.launchpad.net/ubuntu/+source/unity8/+bug/1627281
775801 function test_doubleTapToMaximizeWindow() {
776802 var dialerAppDelegate = startApplication("dialer-app");