on xenial help sign in
drop the locking behavior of double-tap-and-hold
ace44c0Michael Zanetti
qml/Components/VirtualTouchPad.qml+9−6
@@ -33,7 +33,8 @@ Item {
33 // FIXME: Once we have Qt DPR support, this should be Qt.styleHints.startDragDistance
33 // FIXME: Once we have Qt DPR support, this should be Qt.styleHints.startDragDistance
34 readonly property int clickThreshold: units.gu(1.5)
34 readonly property int clickThreshold: units.gu(1.5)
35 property bool isClick: false
35 property bool isClick: false
36− property bool pressed: false
36+ property bool isDoubleClick: false
37+ property bool isDrag: false
37
38
38 onPressed: {
39 onPressed: {
39 // If double-tapping *really* fast, it could happen that we end up having only point2 pressed
40 // If double-tapping *really* fast, it could happen that we end up having only point2 pressed
@@ -42,7 +43,7 @@ Item {
42 && clickTimer.running) {
43 && clickTimer.running) {
43 clickTimer.stop();
44 clickTimer.stop();
44 uinput.pressMouse(UInput.ButtonLeft)
45 uinput.pressMouse(UInput.ButtonLeft)
45− pressed = true;
46+ isDoubleClick = true;
46 }
47 }
47 isClick = true;
48 isClick = true;
48 }
49 }
@@ -59,14 +60,15 @@ Item {
59 }
60 }
60
61
61 onReleased: {
62 onReleased: {
63+ if (isDoubleClick || isDrag) {
64+ uinput.releaseMouse(UInput.ButtonLeft)
65+ isDoubleClick = false;
66+ }
62 if (isClick) {
67 if (isClick) {
63− if (pressed) {
64− uinput.releaseMouse(UInput.ButtonLeft)
65− pressed = false;
66− }
67 clickTimer.scheduleClick(point1.pressed ? UInput.ButtonRight : UInput.ButtonLeft)
68 clickTimer.scheduleClick(point1.pressed ? UInput.ButtonRight : UInput.ButtonLeft)
68 }
69 }
69 isClick = false;
70 isClick = false;
71+ isDrag = false;
70 }
72 }
71
73
72 Timer {
74 Timer {
@@ -90,6 +92,7 @@ Item {
90 (Math.abs(tp.x - tp.startX) > clickThreshold ||
92 (Math.abs(tp.x - tp.startX) > clickThreshold ||
91 Math.abs(tp.y - tp.startY) > clickThreshold)) {
93 Math.abs(tp.y - tp.startY) > clickThreshold)) {
92 isClick = false;
94 isClick = false;
95+ isDrag = true;
93 }
96 }
94
97
95 uinput.moveMouse(tp.x - tp.previousX, tp.y - tp.previousY);
98 uinput.moveMouse(tp.x - tp.previousX, tp.y - tp.previousY);
tests/qmltests/Components/tst_VirtualTouchPad.qml+3−1
@@ -101,12 +101,14 @@ Item {
101
101
102 var touchPadArea = findChild(touchScreenPad, "touchPadArea");
102 var touchPadArea = findChild(touchScreenPad, "touchPadArea");
103
103
104− tap(touchPadArea)
104+ mouseClick(touchPadArea)
105 mousePress(touchPadArea)
105 mousePress(touchPadArea)
106+ mouseMove(touchPadArea, touchPadArea.width / 4, touchPadArea.height / 4)
106
107
107 tryCompare(mouseEventSpy1, "count", 1)
108 tryCompare(mouseEventSpy1, "count", 1)
108 tryCompare(mouseEventSpy2, "count", 0)
109 tryCompare(mouseEventSpy2, "count", 0)
109 mouseRelease(touchPadArea)
110 mouseRelease(touchPadArea)
111+ tryCompare(mouseEventSpy2, "count", 1)
110 }
112 }
111
113
112 function test_twoFingerScroll() {
114 function test_twoFingerScroll() {