on xenial help sign in
rename signals, add some docu
commitfc18645ef33b518598c2379514bd38da4dfdf8fe authorLukáš Tinkl <lukas.tinkl@canonical.com> dateWed 2 Dec 2015, 23:27 (11 years ago) parent17b5515
4 files changed+16−13
plugins/Utils/WindowInputMonitor.cpp+3−3 plugins/Utils/WindowInputMonitor.h+6−3 qml/Shell.qml+5−5 tests/plugins/Utils/WindowInputMonitorTest.cpp+2−2
plugins/Utils/WindowInputMonitor.cpp+3−3
@@ -86,7 +86,7 @@ void WindowInputMonitor::update(QEvent *event)
8686
8787 m_activationTimer->stop();
8888 m_windowBeingTouched = true;
89− Q_EMIT windowTouched();
89+ Q_EMIT touchBegun();
9090
9191 } else if (event->type() == QEvent::TouchEnd) {
9292
@@ -96,7 +96,7 @@ void WindowInputMonitor::update(QEvent *event)
9696 QTouchEvent * touchEv = static_cast<QTouchEvent *>(event);
9797 if (touchEv && !touchEv->touchPoints().isEmpty()) {
9898 const QPointF pos = touchEv->touchPoints().last().screenPos();
99− Q_EMIT windowReleased(pos);
99+ Q_EMIT touchEnded(pos);
100100 }
101101 }
102102}
@@ -118,6 +118,6 @@ void WindowInputMonitor::emitActivatedIfNoTouchesAround()
118118{
119119 if (!m_homeKeyPressed && !m_windowBeingTouched &&
120120 (m_windowLastTouchedTimer->elapsed() > msecsWithoutTouches)) {
121− Q_EMIT activated();
121+ Q_EMIT homeKeyActivated();
122122 }
123123}
plugins/Utils/WindowInputMonitor.h+6−3
@@ -34,6 +34,9 @@
3434 Rationale being that it's easy to accidentally hit the home key while performing
3535 a swipe from a screen edge, for instance. That's particularly the case when the
3636 home key is a capacitive key.
37+
38+ Additionally, this class monitors for generic touch events on the screen, to
39+ help with hiding/revealing the mouse pointer.
3740 */
3841class WindowInputMonitor : public QQuickItem
3942{
@@ -57,10 +60,10 @@ public:
5760
5861Q_SIGNALS:
5962 // Emitted when the home key has been intentionally tapped
60− void activated();
63+ void homeKeyActivated();
6164
62− void windowTouched();
63− void windowReleased(const QPointF &pos);
65+ void touchBegun();
66+ void touchEnded(const QPointF &pos);
6467
6568private Q_SLOTS:
6669 void setupFilterOnWindow(QQuickWindow *window);
qml/Shell.qml+5−5
@@ -144,7 +144,7 @@ Item {
144144 function revealCursor() {
145145 if (touchDetected) {
146146 touchDetected = false;
147− Mir.cursorName = "";
147+ //Mir.cursorName = "";
148148 shell.cursorVisible = true;
149149 }
150150 }
@@ -196,10 +196,10 @@ Item {
196196 }
197197
198198 WindowInputMonitor {
199− onActivated: { launcher.fadeOut(); shell.showHome(); }
200− onWindowTouched: { cursorPriv.hideCursor(); }
201− onWindowReleased: {
202− // store the last known touch position
199+ onHomeKeyActivated: { launcher.fadeOut(); shell.showHome(); }
200+ onTouchBegun: { cursorPriv.hideCursor(); }
201+ onTouchEnded: {
202+ // move the (hidden) cursor to the last known touch position
203203 cursor.x = pos.x;
204204 cursor.y = pos.y;
205205 }
tests/plugins/Utils/WindowInputMonitorTest.cpp+2−2
@@ -128,7 +128,7 @@ void WindowInputMonitorTest::touchTapTouch()
128128 QFETCH(int, silenceAfterTap);
129129 QFETCH(int, expectedActivatedCount);
130130 WindowInputMonitor homeKeyWatcher(m_fakeTimerFactory->create(), new FakeElapsedTimer);
131− QSignalSpy activatedSpy(&homeKeyWatcher, &WindowInputMonitor::activated);
131+ QSignalSpy activatedSpy(&homeKeyWatcher, &WindowInputMonitor::homeKeyActivated);
132132 QVERIFY(activatedSpy.isValid());
133133
134134 {
@@ -189,7 +189,7 @@ void WindowInputMonitorTest::touchTapTouch()
189189void WindowInputMonitorTest::tapWhileTouching()
190190{
191191 WindowInputMonitor homeKeyWatcher(m_fakeTimerFactory->create(), new FakeElapsedTimer);
192− QSignalSpy activatedSpy(&homeKeyWatcher, &WindowInputMonitor::activated);
192+ QSignalSpy activatedSpy(&homeKeyWatcher, &WindowInputMonitor::homeKeyActivated);
193193 QVERIFY(activatedSpy.isValid());
194194
195195 {