on xenial help sign in
drop the locking behavior of double-tap-and-hold
commitace44c04a43f3166446dbdf78b26c42b097f9468 authorMichael Zanetti <michael.zanetti@canonical.com> dateTue 26 Jan 2016, 16:28 (11 years ago) parentba3fb28
2 files changed+12−7
qml/Components/VirtualTouchPad.qml+9−6 tests/qmltests/Components/tst_VirtualTouchPad.qml+3−1
qml/Components/VirtualTouchPad.qml+9−6
@@ -33,7 +33,8 @@ Item {
3333 // FIXME: Once we have Qt DPR support, this should be Qt.styleHints.startDragDistance
3434 readonly property int clickThreshold: units.gu(1.5)
3535 property bool isClick: false
36− property bool pressed: false
36+ property bool isDoubleClick: false
37+ property bool isDrag: false
3738
3839 onPressed: {
3940 // If double-tapping *really* fast, it could happen that we end up having only point2 pressed
@@ -42,7 +43,7 @@ Item {
4243 && clickTimer.running) {
4344 clickTimer.stop();
4445 uinput.pressMouse(UInput.ButtonLeft)
45− pressed = true;
46+ isDoubleClick = true;
4647 }
4748 isClick = true;
4849 }
@@ -59,14 +60,15 @@ Item {
5960 }
6061
6162 onReleased: {
63+ if (isDoubleClick || isDrag) {
64+ uinput.releaseMouse(UInput.ButtonLeft)
65+ isDoubleClick = false;
66+ }
6267 if (isClick) {
63− if (pressed) {
64− uinput.releaseMouse(UInput.ButtonLeft)
65− pressed = false;
66− }
6768 clickTimer.scheduleClick(point1.pressed ? UInput.ButtonRight : UInput.ButtonLeft)
6869 }
6970 isClick = false;
71+ isDrag = false;
7072 }
7173
7274 Timer {
@@ -90,6 +92,7 @@ Item {
9092 (Math.abs(tp.x - tp.startX) > clickThreshold ||
9193 Math.abs(tp.y - tp.startY) > clickThreshold)) {
9294 isClick = false;
95+ isDrag = true;
9396 }
9497
9598 uinput.moveMouse(tp.x - tp.previousX, tp.y - tp.previousY);
tests/qmltests/Components/tst_VirtualTouchPad.qml+3−1
@@ -101,12 +101,14 @@ Item {
101101
102102 var touchPadArea = findChild(touchScreenPad, "touchPadArea");
103103
104− tap(touchPadArea)
104+ mouseClick(touchPadArea)
105105 mousePress(touchPadArea)
106+ mouseMove(touchPadArea, touchPadArea.width / 4, touchPadArea.height / 4)
106107
107108 tryCompare(mouseEventSpy1, "count", 1)
108109 tryCompare(mouseEventSpy2, "count", 0)
109110 mouseRelease(touchPadArea)
111+ tryCompare(mouseEventSpy2, "count", 1)
110112 }
111113
112114 function test_twoFingerScroll() {