on xenial help sign in
hide the mouse pointer on touch, reveal it again on mouse move
e28150aLukáš Tinkl
plugins/Cursor/MousePointer.cpp+4
@@ -42,6 +42,10 @@ void MousePointer::handleMouseEvent(ulong timestamp, QPointF movement, Qt::Mouse
42 return;
42 return;
43 }
43 }
44
44
45+ if (!movement.isNull()) {
46+ Q_EMIT mouseMoved();
47+ }
48+
45 qreal newX = x() + movement.x();
49 qreal newX = x() + movement.x();
46 if (newX < 0) {
50 if (newX < 0) {
47 Q_EMIT pushedLeftBoundary(qAbs(newX), buttons);
51 Q_EMIT pushedLeftBoundary(qAbs(newX), buttons);
plugins/Cursor/MousePointer.h+1
@@ -48,6 +48,7 @@ public Q_SLOTS:
48Q_SIGNALS:
48Q_SIGNALS:
49 void pushedLeftBoundary(qreal amount, Qt::MouseButtons buttons);
49 void pushedLeftBoundary(qreal amount, Qt::MouseButtons buttons);
50 void pushedRightBoundary(qreal amount, Qt::MouseButtons buttons);
50 void pushedRightBoundary(qreal amount, Qt::MouseButtons buttons);
51+ void mouseMoved();
51
52
52protected:
53protected:
53 void itemChange(ItemChange change, const ItemChangeData &value) override;
54 void itemChange(ItemChange change, const ItemChangeData &value) override;
plugins/Utils/HomeKeyWatcher.cpp+7
@@ -86,11 +86,18 @@ void HomeKeyWatcher::update(QEvent *event)
86
86
87 m_activationTimer->stop();
87 m_activationTimer->stop();
88 m_windowBeingTouched = true;
88 m_windowBeingTouched = true;
89+ Q_EMIT windowTouched();
89
90
90 } else if (event->type() == QEvent::TouchEnd) {
91 } else if (event->type() == QEvent::TouchEnd) {
91
92
92 m_windowBeingTouched = false;
93 m_windowBeingTouched = false;
93 m_windowLastTouchedTimer->start();
94 m_windowLastTouchedTimer->start();
95+
96+ QTouchEvent * touchEv = static_cast<QTouchEvent *>(event);
97+ if (touchEv && !touchEv->touchPoints().isEmpty()) {
98+ const QPointF pos = touchEv->touchPoints().last().screenPos();
99+ Q_EMIT windowReleased(pos);
100+ }
94 }
101 }
95}
102}
96
103
plugins/Utils/HomeKeyWatcher.h+3
@@ -59,6 +59,9 @@ Q_SIGNALS:
59 // Emitted when the home key has been intentionally tapped
59 // Emitted when the home key has been intentionally tapped
60 void activated();
60 void activated();
61
61
62+ void windowTouched();
63+ void windowReleased(const QPointF &pos);
64+
62private Q_SLOTS:
65private Q_SLOTS:
63 void setupFilterOnWindow(QQuickWindow *window);
66 void setupFilterOnWindow(QQuickWindow *window);
64 void emitActivatedIfNoTouchesAround();
67 void emitActivatedIfNoTouchesAround();
qml/Shell.qml+30
@@ -132,6 +132,24 @@ Item {
132 shell.activateApplication(app);
132 shell.activateApplication(app);
133 }
133 }
134
134
135+ QtObject {
136+ id: cursorPriv
137+ property bool touchDetected: false;
138+
139+ function hideCursor() {
140+ touchDetected = true;
141+ shell.cursorVisible = false;
142+ }
143+
144+ function revealCursor() {
145+ if (touchDetected) {
146+ touchDetected = false;
147+ Mir.cursorName = "";
148+ shell.cursorVisible = true;
149+ }
150+ }
151+ }
152+
135 Binding {
153 Binding {
136 target: LauncherModel
154 target: LauncherModel
137 property: "applicationManager"
155 property: "applicationManager"
@@ -147,6 +165,7 @@ Item {
147 }
165 }
148
166
149 LightDM{id: lightDM} // Provide backend access
167 LightDM{id: lightDM} // Provide backend access
168+
150 VolumeControl {
169 VolumeControl {
151 id: volumeControl
170 id: volumeControl
152 indicators: panel.indicators
171 indicators: panel.indicators
@@ -178,6 +197,12 @@ Item {
178
197
179 HomeKeyWatcher {
198 HomeKeyWatcher {
180 onActivated: { launcher.fadeOut(); shell.showHome(); }
199 onActivated: { launcher.fadeOut(); shell.showHome(); }
200+ onWindowTouched: { cursorPriv.hideCursor(); }
201+ onWindowReleased: {
202+ // store the last known touch position
203+ cursor.x = pos.x;
204+ cursor.y = pos.y;
205+ }
181 }
206 }
182
207
183 Item {
208 Item {
@@ -663,6 +688,7 @@ Item {
663 id: cursor
688 id: cursor
664 visible: shell.hasMouse
689 visible: shell.hasMouse
665 z: screenGrabber.z + 1
690 z: screenGrabber.z + 1
691+ opacity: shell.cursorVisible ? 1 : 0
666
692
667 onPushedLeftBoundary: {
693 onPushedLeftBoundary: {
668 if (buttons === Qt.NoButton) {
694 if (buttons === Qt.NoButton) {
@@ -676,6 +702,10 @@ Item {
676 applicationsDisplayLoader.item.pushRightEdge(amount);
702 applicationsDisplayLoader.item.pushRightEdge(amount);
677 }
703 }
678 }
704 }
705+
706+ onMouseMoved: {
707+ cursorPriv.revealCursor();
708+ }
679 }
709 }
680
710
681 Rectangle {
711 Rectangle {
qml/Stages/WindowResizeArea.qml+3−5
@@ -118,8 +118,8 @@ MouseArea {
118 property real currentWidth
118 property real currentWidth
119 property real currentHeight
119 property real currentHeight
120
120
121− property string cursorName: {
121+ readonly property string cursorName: {
122− if (root.containsMouse || root.pressed) {
122+ if (root.containsMouse || dragging) {
123 if (leftBorder && !topBorder && !bottomBorder) {
123 if (leftBorder && !topBorder && !bottomBorder) {
124 return "left_side";
124 return "left_side";
125 } else if (rightBorder && !topBorder && !bottomBorder) {
125 } else if (rightBorder && !topBorder && !bottomBorder) {
@@ -186,9 +186,7 @@ MouseArea {
186 } else {
186 } else {
187 resetBordersToMoveTimer.start();
187 resetBordersToMoveTimer.start();
188 d.dragging = false;
188 d.dragging = false;
189− if (containsMouse) {
190− d.updateBorders();
189+ d.updateBorders();
191− }
192 }
190 }
193 }
191 }
194
192