Merge lp:~lukas-kde/unity8/cursorHiding into lp:unity8

Proposed by Lukáš Tinkl
Status: Merged
Approved by: Michał Sawicz
Approved revision: 2092
Merged at revision: 2159
Proposed branch: lp:~lukas-kde/unity8/cursorHiding
Merge into: lp:unity8
Prerequisite: lp:~mzanetti/unity8/inputmethod2
Diff against target: 434 lines (+95/-55)
12 files modified
plugins/Cursor/MousePointer.cpp (+4/-0)
plugins/Cursor/MousePointer.h (+1/-0)
plugins/Utils/CMakeLists.txt (+1/-1)
plugins/Utils/WindowInputMonitor.cpp (+19/-12)
plugins/Utils/WindowInputMonitor.h (+37/-20)
plugins/Utils/plugin.cpp (+2/-2)
qml/Shell.qml (+11/-3)
tests/mocks/Cursor/Cursor.qml (+1/-0)
tests/mocks/Utils/WindowInputMonitor.qml (+3/-1)
tests/mocks/Utils/qmldir (+1/-1)
tests/plugins/Utils/CMakeLists.txt (+1/-1)
tests/plugins/Utils/WindowInputMonitorTest.cpp (+14/-14)
To merge this branch: bzr merge lp:~lukas-kde/unity8/cursorHiding
Reviewer Review Type Date Requested Status
Michał Sawicz Approve
PS Jenkins bot (community) continuous-integration Needs Fixing
Unity8 CI Bot continuous-integration Needs Fixing
Daniel d'Andrada Pending
Review via email: mp+284332@code.launchpad.net

This proposal supersedes a proposal from 2015-12-01.

Commit message

Hide/reveal the mouse pointer on touch/mouse events

Description of the change

Hide the mouse pointer when a touch event is detected, reveal it again when the mouse is moved again.

This matches unity7 behavior in this regard, the mouse pointer is moved to the last known touch position.

* Are there any related MPs required for this MP to build/function as expected? Please list.

Yes, lp:~mzanetti/unity8/inputmethod2

 * Did you perform an exploratory manual test run of your code change and any related functionality?

Yes

 * Did you make sure that your branch does not contain spurious tags?

Yes

 * If you changed the packaging (debian), did you subscribe the ubuntu-unity team to this MP?

Yes

 * If you changed the UI, has there been a design review?

N/A, matches unity7 behavior

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal

FAILED: Continuous integration, rev:2078
http://jenkins.qa.ubuntu.com/job/unity8-ci/6860/
Executed test runs:
    FAILURE: http://jenkins.qa.ubuntu.com/job/generic-deb-autopilot-vivid-touch/5538/console
    FAILURE: http://jenkins.qa.ubuntu.com/job/generic-deb-autopilot-xenial-touch/275/console
    UNSTABLE: http://jenkins.qa.ubuntu.com/job/unity-phablet-qmluitests-vivid/1571
    UNSTABLE: http://jenkins.qa.ubuntu.com/job/unity8-qmluitest-xenial-amd64/274
    SUCCESS: http://jenkins.qa.ubuntu.com/job/unity8-vivid-amd64-ci/1466
    SUCCESS: http://jenkins.qa.ubuntu.com/job/unity8-vivid-i386-ci/1466
    SUCCESS: http://jenkins.qa.ubuntu.com/job/unity8-xenial-amd64-ci/273
    SUCCESS: http://jenkins.qa.ubuntu.com/job/unity8-xenial-i386-ci/272
    FAILURE: http://jenkins.qa.ubuntu.com/job/generic-deb-autopilot-runner-vivid-touch/4335/console
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-vivid-armhf/5552
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-vivid-armhf/5552/artifact/work/output/*zip*/output.zip
    SUCCESS: http://s-jenkins.ubuntu-ci:8080/job/touch-flash-device/25684
    FAILURE: http://jenkins.qa.ubuntu.com/job/generic-deb-autopilot-runner-xenial-touch/95/console
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-xenial-armhf/274
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-xenial-armhf/274/artifact/work/output/*zip*/output.zip
    SUCCESS: http://s-jenkins.ubuntu-ci:8080/job/touch-flash-device/25683

Click here to trigger a rebuild:
http://s-jenkins.ubuntu-ci:8080/job/unity8-ci/6860/rebuild

review: Needs Fixing (continuous-integration)
Revision history for this message
Daniel d'Andrada (dandrader) wrote : Posted in a previous version of this proposal

I wouldn't move the cursor because of touch interaction.

That's an habit of X11, because of its "low-level" mouse emulation out of touch events.

Revision history for this message
Daniel d'Andrada (dandrader) wrote : Posted in a previous version of this proposal

If you plan to use HomeKeyWatcher for that stuff it should be renamed to something more generic, like WindowInputMonitor or something.

Revision history for this message
Lukáš Tinkl (lukas-kde) wrote : Posted in a previous version of this proposal

> I wouldn't move the cursor because of touch interaction.
>
> That's an habit of X11, because of its "low-level" mouse emulation out of
> touch events.

Discussed this with mzanetti and I also compared it with other systems (unity7, Windows 10), it really feels natural this way. Of course, subjective feeling, we can ask design for opinion on this

Revision history for this message
Lukáš Tinkl (lukas-kde) wrote : Posted in a previous version of this proposal

> If you plan to use HomeKeyWatcher for that stuff it should be renamed to
> something more generic, like WindowInputMonitor or something.

Yup, will do

Revision history for this message
Lukáš Tinkl (lukas-kde) wrote : Posted in a previous version of this proposal

> If you plan to use HomeKeyWatcher for that stuff it should be renamed to
> something more generic, like WindowInputMonitor or something.

Done

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal

FAILED: Continuous integration, rev:2079
http://jenkins.qa.ubuntu.com/job/unity8-ci/6869/
Executed test runs:
    UNSTABLE: http://jenkins.qa.ubuntu.com/job/generic-deb-autopilot-vivid-touch/5554
    FAILURE: http://jenkins.qa.ubuntu.com/job/generic-deb-autopilot-xenial-touch/284/console
    UNSTABLE: http://jenkins.qa.ubuntu.com/job/unity-phablet-qmluitests-vivid/1580
    UNSTABLE: http://jenkins.qa.ubuntu.com/job/unity8-qmluitest-xenial-amd64/283
    SUCCESS: http://jenkins.qa.ubuntu.com/job/unity8-vivid-amd64-ci/1475
    SUCCESS: http://jenkins.qa.ubuntu.com/job/unity8-vivid-i386-ci/1475
    SUCCESS: http://jenkins.qa.ubuntu.com/job/unity8-xenial-amd64-ci/282
    SUCCESS: http://jenkins.qa.ubuntu.com/job/unity8-xenial-i386-ci/281
    UNSTABLE: http://jenkins.qa.ubuntu.com/job/generic-deb-autopilot-runner-vivid-touch/4350
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-vivid-armhf/5568
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-vivid-armhf/5568/artifact/work/output/*zip*/output.zip
    SUCCESS: http://s-jenkins.ubuntu-ci:8080/job/touch-flash-device/25728
    FAILURE: http://jenkins.qa.ubuntu.com/job/generic-deb-autopilot-runner-xenial-touch/102/console
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-xenial-armhf/283
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-xenial-armhf/283/artifact/work/output/*zip*/output.zip
    SUCCESS: http://s-jenkins.ubuntu-ci:8080/job/touch-flash-device/25727

Click here to trigger a rebuild:
http://s-jenkins.ubuntu-ci:8080/job/unity8-ci/6869/rebuild

review: Needs Fixing (continuous-integration)
Revision history for this message
Daniel d'Andrada (dandrader) wrote : Posted in a previous version of this proposal

You also have to update/rephrase WindowInputMonitor's documentation and rename its activated() signal to something more specific since the class is not just about the home key anymore.

I would suggest some changes to those new signal names to get them closer to existing naming and concepts:

s/windowTouched/touchBegun
s/windowReleased/touchEnded

Also the class has "Window" in its name already, so no need to repeat that in the signal name.

------------

In WindowInputMonitor.cpp:

"""
if (touchEv && !touchEv->touchPoints().isEmpty()) {
"""

A touch event is malformed if it doesn't contain any touch point. So that should be an assertion if you care about checking it at all.

Furthermore, it would be inconsistent to emit a touchBegun() but not its touchEnded() counterpart.

review: Needs Fixing
Revision history for this message
Daniel d'Andrada (dandrader) wrote : Posted in a previous version of this proposal

In Shell.qml

"""
// store the last known touch position
"""

Not a very accurate comment. You're not "storing" the touch position, you're moving the Cursor to it.

Revision history for this message
Daniel d'Andrada (dandrader) wrote : Posted in a previous version of this proposal

In Shell.qml

"""
        function revealCursor() {
            if (touchDetected) {
                touchDetected = false;
                Mir.cursorName = "";
                shell.cursorVisible = true;
            }
        }
"""

There should be no need to touch Mir.cursorName.

review: Needs Fixing
Revision history for this message
Daniel d'Andrada (dandrader) wrote : Posted in a previous version of this proposal

Can't you move the stuff in cursorPriv to Cursor.qml?

Revision history for this message
Lukáš Tinkl (lukas-kde) wrote : Posted in a previous version of this proposal

Comments/issues addressed

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal

FAILED: Continuous integration, rev:2081
http://jenkins.qa.ubuntu.com/job/unity8-ci/6871/
Executed test runs:
    FAILURE: http://jenkins.qa.ubuntu.com/job/generic-deb-autopilot-vivid-touch/5564/console
    FAILURE: http://jenkins.qa.ubuntu.com/job/generic-deb-autopilot-xenial-touch/286/console
    UNSTABLE: http://jenkins.qa.ubuntu.com/job/unity-phablet-qmluitests-vivid/1582
    UNSTABLE: http://jenkins.qa.ubuntu.com/job/unity8-qmluitest-xenial-amd64/285
    SUCCESS: http://jenkins.qa.ubuntu.com/job/unity8-vivid-amd64-ci/1477
    SUCCESS: http://jenkins.qa.ubuntu.com/job/unity8-vivid-i386-ci/1477
    SUCCESS: http://jenkins.qa.ubuntu.com/job/unity8-xenial-amd64-ci/284
    SUCCESS: http://jenkins.qa.ubuntu.com/job/unity8-xenial-i386-ci/283
    FAILURE: http://jenkins.qa.ubuntu.com/job/generic-deb-autopilot-runner-vivid-touch/4357/console
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-vivid-armhf/5578
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-vivid-armhf/5578/artifact/work/output/*zip*/output.zip
    SUCCESS: http://s-jenkins.ubuntu-ci:8080/job/touch-flash-device/25745
    FAILURE: http://jenkins.qa.ubuntu.com/job/generic-deb-autopilot-runner-xenial-touch/103/console
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-xenial-armhf/285
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-xenial-armhf/285/artifact/work/output/*zip*/output.zip
    SUCCESS: http://s-jenkins.ubuntu-ci:8080/job/touch-flash-device/25744

Click here to trigger a rebuild:
http://s-jenkins.ubuntu-ci:8080/job/unity8-ci/6871/rebuild

review: Needs Fixing (continuous-integration)
Revision history for this message
Daniel d'Andrada (dandrader) wrote : Posted in a previous version of this proposal

I think there's quite a bit of redundant code there. I removed it and it works fine:
http://bazaar.launchpad.net/~dandrader/unity8/cursorHiding/revision/2080

In Shell.qml:

"""
        onTouchEnded: {
            // move the (hidden) cursor to the last known touch position
            cursor.x = pos.x;
            cursor.y = pos.y;
        }
"""

You can't simply assign as the touch position is in a different coordinate system. Cursor is in Shell coordinates whereas touch position is in root, OrientedShell, coordinates. You have to map it.

You can see it's broken is you try it on a Nexus 7 for instance.

review: Needs Fixing
Revision history for this message
Lukáš Tinkl (lukas-kde) wrote : Posted in a previous version of this proposal

Comments addressed, also fixed the tests after the class renaming and new signal additions

Revision history for this message
Daniel d'Andrada (dandrader) wrote : Posted in a previous version of this proposal

In Shell.qml:

"""
var mappedCoords = mapFromItem(shell.parent, pos.x, pos.y);
"""

When mapping from the root coordinate system you just pass null, like this:

var mappedCoords = mapFromItem(null, pos.x, pos.y);

review: Needs Fixing
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal

FAILED: Continuous integration, rev:2082
http://jenkins.qa.ubuntu.com/job/unity8-ci/6877/
Executed test runs:
    UNSTABLE: http://jenkins.qa.ubuntu.com/job/generic-deb-autopilot-vivid-touch/5579
    FAILURE: http://jenkins.qa.ubuntu.com/job/generic-deb-autopilot-xenial-touch/292/console
    UNSTABLE: http://jenkins.qa.ubuntu.com/job/unity-phablet-qmluitests-vivid/1588
    UNSTABLE: http://jenkins.qa.ubuntu.com/job/unity8-qmluitest-xenial-amd64/291
    SUCCESS: http://jenkins.qa.ubuntu.com/job/unity8-vivid-amd64-ci/1483
    SUCCESS: http://jenkins.qa.ubuntu.com/job/unity8-vivid-i386-ci/1483
    SUCCESS: http://jenkins.qa.ubuntu.com/job/unity8-xenial-amd64-ci/290
    SUCCESS: http://jenkins.qa.ubuntu.com/job/unity8-xenial-i386-ci/289
    UNSTABLE: http://jenkins.qa.ubuntu.com/job/generic-deb-autopilot-runner-vivid-touch/4370
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-vivid-armhf/5593
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-vivid-armhf/5593/artifact/work/output/*zip*/output.zip
    SUCCESS: http://s-jenkins.ubuntu-ci:8080/job/touch-flash-device/25783
    FAILURE: http://jenkins.qa.ubuntu.com/job/generic-deb-autopilot-runner-xenial-touch/109/console
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-xenial-armhf/291
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-xenial-armhf/291/artifact/work/output/*zip*/output.zip
    SUCCESS: http://s-jenkins.ubuntu-ci:8080/job/touch-flash-device/25784

Click here to trigger a rebuild:
http://s-jenkins.ubuntu-ci:8080/job/unity8-ci/6877/rebuild

review: Needs Fixing (continuous-integration)
Revision history for this message
Daniel d'Andrada (dandrader) wrote : Posted in a previous version of this proposal

Works fine and code looks ok. Let's wait for jenkins before top-approving.

review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal

FAILED: Continuous integration, rev:2088
http://jenkins.qa.ubuntu.com/job/unity8-ci/6879/
Executed test runs:
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-deb-autopilot-vivid-touch/5585
    FAILURE: http://jenkins.qa.ubuntu.com/job/generic-deb-autopilot-xenial-touch/294/console
    SUCCESS: http://jenkins.qa.ubuntu.com/job/unity-phablet-qmluitests-vivid/1590
    UNSTABLE: http://jenkins.qa.ubuntu.com/job/unity8-qmluitest-xenial-amd64/293
    SUCCESS: http://jenkins.qa.ubuntu.com/job/unity8-vivid-amd64-ci/1485
    SUCCESS: http://jenkins.qa.ubuntu.com/job/unity8-vivid-i386-ci/1485
    SUCCESS: http://jenkins.qa.ubuntu.com/job/unity8-xenial-amd64-ci/292
    SUCCESS: http://jenkins.qa.ubuntu.com/job/unity8-xenial-i386-ci/291
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-deb-autopilot-runner-vivid-touch/4373
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-vivid-armhf/5599
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-vivid-armhf/5599/artifact/work/output/*zip*/output.zip
    SUCCESS: http://s-jenkins.ubuntu-ci:8080/job/touch-flash-device/25789
    FAILURE: http://jenkins.qa.ubuntu.com/job/generic-deb-autopilot-runner-xenial-touch/110/console
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-xenial-armhf/293
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-xenial-armhf/293/artifact/work/output/*zip*/output.zip
    SUCCESS: http://s-jenkins.ubuntu-ci:8080/job/touch-flash-device/25790

Click here to trigger a rebuild:
http://s-jenkins.ubuntu-ci:8080/job/unity8-ci/6879/rebuild

review: Needs Fixing (continuous-integration)
Revision history for this message
Daniel d'Andrada (dandrader) wrote : Posted in a previous version of this proposal

* Did you perform an exploratory manual test run of the code change and any related functionality?
Yes

* Did CI run pass? If not, please explain why.
Yes (apart from the usual xenial AP failure)

* Did you make sure that the branch does not contain spurious tags?
Yes

review: Approve
Revision history for this message
Unity8 CI Bot (unity8-ci-bot) wrote :

FAILED: Continuous integration, rev:2092
https://unity8-jenkins.ubuntu.com/job/lp-unity8-1-ci/223/
Executed test runs:

Click here to trigger a rebuild:
https://unity8-jenkins.ubuntu.com/job/lp-unity8-1-ci/223/rebuild

review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :

FAILED: Continuous integration, rev:2092
http://jenkins.qa.ubuntu.com/job/unity8-ci/7173/
Executed test runs:
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-deb-autopilot-vivid-touch/6251
    FAILURE: http://jenkins.qa.ubuntu.com/job/generic-deb-autopilot-xenial-touch/588/console
    SUCCESS: http://jenkins.qa.ubuntu.com/job/unity-phablet-qmluitests-vivid/1878
    SUCCESS: http://jenkins.qa.ubuntu.com/job/unity8-qmluitest-xenial-amd64/581
    SUCCESS: http://jenkins.qa.ubuntu.com/job/unity8-vivid-amd64-ci/1773
    SUCCESS: http://jenkins.qa.ubuntu.com/job/unity8-vivid-i386-ci/1773
    SUCCESS: http://jenkins.qa.ubuntu.com/job/unity8-xenial-amd64-ci/580
    SUCCESS: http://jenkins.qa.ubuntu.com/job/unity8-xenial-i386-ci/579
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-deb-autopilot-runner-vivid-touch/4814
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-vivid-armhf/6262
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-vivid-armhf/6262/artifact/work/output/*zip*/output.zip
    SUCCESS: http://s-jenkins.ubuntu-ci:8080/job/touch-flash-device/27141
    FAILURE: http://jenkins.qa.ubuntu.com/job/generic-deb-autopilot-runner-xenial-touch/306/console
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-xenial-armhf/586
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-xenial-armhf/586/artifact/work/output/*zip*/output.zip
    SUCCESS: http://s-jenkins.ubuntu-ci:8080/job/touch-flash-device/27138

Click here to trigger a rebuild:
http://s-jenkins.ubuntu-ci:8080/job/unity8-ci/7173/rebuild

review: Needs Fixing (continuous-integration)
Revision history for this message
Michał Sawicz (saviq) wrote :

Approving after resubmission.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'plugins/Cursor/MousePointer.cpp'
2--- plugins/Cursor/MousePointer.cpp 2015-11-30 17:38:20 +0000
3+++ plugins/Cursor/MousePointer.cpp 2016-01-28 18:26:46 +0000
4@@ -42,6 +42,10 @@
5 return;
6 }
7
8+ if (!movement.isNull()) {
9+ Q_EMIT mouseMoved();
10+ }
11+
12 qreal newX = x() + movement.x();
13 if (newX < 0) {
14 Q_EMIT pushedLeftBoundary(qAbs(newX), buttons);
15
16=== modified file 'plugins/Cursor/MousePointer.h'
17--- plugins/Cursor/MousePointer.h 2015-11-26 13:51:24 +0000
18+++ plugins/Cursor/MousePointer.h 2016-01-28 18:26:46 +0000
19@@ -48,6 +48,7 @@
20 Q_SIGNALS:
21 void pushedLeftBoundary(qreal amount, Qt::MouseButtons buttons);
22 void pushedRightBoundary(qreal amount, Qt::MouseButtons buttons);
23+ void mouseMoved();
24
25 protected:
26 void itemChange(ItemChange change, const ItemChangeData &value) override;
27
28=== modified file 'plugins/Utils/CMakeLists.txt'
29--- plugins/Utils/CMakeLists.txt 2015-10-28 10:32:47 +0000
30+++ plugins/Utils/CMakeLists.txt 2016-01-28 18:26:46 +0000
31@@ -13,7 +13,7 @@
32 ${APPLICATION_API_INCLUDEDIR}/unity/shell/application/ApplicationManagerInterface.h
33 applicationsfiltermodel.cpp
34 constants.cpp
35- HomeKeyWatcher.cpp
36+ WindowInputMonitor.cpp
37 inputwatcher.cpp
38 qlimitproxymodelqml.cpp
39 unitysortfilterproxymodelqml.cpp
40
41=== renamed file 'plugins/Utils/HomeKeyWatcher.cpp' => 'plugins/Utils/WindowInputMonitor.cpp'
42--- plugins/Utils/HomeKeyWatcher.cpp 2015-04-23 12:49:15 +0000
43+++ plugins/Utils/WindowInputMonitor.cpp 2016-01-28 18:26:46 +0000
44@@ -14,18 +14,18 @@
45 * along with this program. If not, see <http://www.gnu.org/licenses/>.
46 */
47
48-#include "HomeKeyWatcher.h"
49+#include "WindowInputMonitor.h"
50
51 #include <QQuickWindow>
52
53 using namespace UnityUtil;
54
55-HomeKeyWatcher::HomeKeyWatcher(QQuickItem *parent)
56- : HomeKeyWatcher(new Timer, new ElapsedTimer, parent)
57+WindowInputMonitor::WindowInputMonitor(QQuickItem *parent)
58+ : WindowInputMonitor(new Timer, new ElapsedTimer, parent)
59 {
60 }
61
62-HomeKeyWatcher::HomeKeyWatcher(UnityUtil::AbstractTimer *timer,
63+WindowInputMonitor::WindowInputMonitor(UnityUtil::AbstractTimer *timer,
64 UnityUtil::AbstractElapsedTimer *elapsedTimer,
65 QQuickItem *parent)
66 : QQuickItem(parent)
67@@ -37,20 +37,20 @@
68 m_windowLastTouchedTimer->start();
69
70 connect(this, &QQuickItem::windowChanged,
71- this, &HomeKeyWatcher::setupFilterOnWindow);
72+ this, &WindowInputMonitor::setupFilterOnWindow);
73
74 connect(m_activationTimer, &UnityUtil::AbstractTimer::timeout,
75- this, &HomeKeyWatcher::emitActivatedIfNoTouchesAround);
76+ this, &WindowInputMonitor::emitActivatedIfNoTouchesAround);
77 m_activationTimer->setInterval(msecsWithoutTouches);
78 }
79
80-HomeKeyWatcher::~HomeKeyWatcher()
81+WindowInputMonitor::~WindowInputMonitor()
82 {
83 delete m_windowLastTouchedTimer;
84 delete m_activationTimer;
85 }
86
87-bool HomeKeyWatcher::eventFilter(QObject *watched, QEvent *event)
88+bool WindowInputMonitor::eventFilter(QObject *watched, QEvent *event)
89 {
90 Q_ASSERT(!m_filteredWindow.isNull());
91 Q_ASSERT(watched == static_cast<QObject*>(m_filteredWindow.data()));
92@@ -62,7 +62,7 @@
93 return false;
94 }
95
96-void HomeKeyWatcher::update(QEvent *event)
97+void WindowInputMonitor::update(QEvent *event)
98 {
99 if (event->type() == QEvent::KeyPress) {
100 QKeyEvent *keyEvent = static_cast<QKeyEvent*>(event);
101@@ -86,15 +86,22 @@
102
103 m_activationTimer->stop();
104 m_windowBeingTouched = true;
105+ Q_EMIT touchBegun();
106
107 } else if (event->type() == QEvent::TouchEnd) {
108
109 m_windowBeingTouched = false;
110 m_windowLastTouchedTimer->start();
111+
112+ QTouchEvent * touchEv = static_cast<QTouchEvent *>(event);
113+ if (touchEv && !touchEv->touchPoints().isEmpty()) {
114+ const QPointF pos = touchEv->touchPoints().last().screenPos();
115+ Q_EMIT touchEnded(pos);
116+ }
117 }
118 }
119
120-void HomeKeyWatcher::setupFilterOnWindow(QQuickWindow *window)
121+void WindowInputMonitor::setupFilterOnWindow(QQuickWindow *window)
122 {
123 if (!m_filteredWindow.isNull()) {
124 m_filteredWindow->removeEventFilter(this);
125@@ -107,10 +114,10 @@
126 }
127 }
128
129-void HomeKeyWatcher::emitActivatedIfNoTouchesAround()
130+void WindowInputMonitor::emitActivatedIfNoTouchesAround()
131 {
132 if (!m_homeKeyPressed && !m_windowBeingTouched &&
133 (m_windowLastTouchedTimer->elapsed() > msecsWithoutTouches)) {
134- Q_EMIT activated();
135+ Q_EMIT homeKeyActivated();
136 }
137 }
138
139=== renamed file 'plugins/Utils/HomeKeyWatcher.h' => 'plugins/Utils/WindowInputMonitor.h'
140--- plugins/Utils/HomeKeyWatcher.h 2015-04-30 09:31:51 +0000
141+++ plugins/Utils/WindowInputMonitor.h 2016-01-28 18:26:46 +0000
142@@ -14,8 +14,8 @@
143 * along with this program. If not, see <http://www.gnu.org/licenses/>.
144 */
145
146-#ifndef UNITY_HOMEKEYWATCHER_H
147-#define UNITY_HOMEKEYWATCHER_H
148+#ifndef UNITY_WINDOWINPUTMONITOR_H
149+#define UNITY_WINDOWINPUTMONITOR_H
150
151 #include <QQuickItem>
152 #include <QPointer>
153@@ -23,31 +23,26 @@
154 #include "Timer.h"
155 #include "ElapsedTimer.h"
156
157-/*
158- Signals when the home key seems to be have been intentionally tapped.
159-
160- It only says the home key has been activated if it has been tapped in isolation,
161- that is, without being accompanied by touches on the screen. Home key taps that
162- happen along with (or immediately after, or immediately before) touches on the
163- screen are considered to have happened unintentionally and are thus ignored.
164-
165- Rationale being that it's easy to accidentally hit the home key while performing
166- a swipe from a screen edge, for instance. That's particularly the case when the
167- home key is a capacitive key.
168+/**
169+ * Monitors input events received by the window holding this item and the Home (Win aka Super_L)
170+ * key presses.
171+ *
172+ * Additionally, this class monitors for generic touch events on the screen, to
173+ * help with hiding/revealing the mouse pointer.
174 */
175-class HomeKeyWatcher : public QQuickItem
176+class WindowInputMonitor : public QQuickItem
177 {
178 Q_OBJECT
179 public:
180
181- HomeKeyWatcher(QQuickItem *parent = 0);
182+ WindowInputMonitor(QQuickItem *parent = 0);
183
184 // for testing
185- HomeKeyWatcher(UnityUtil::AbstractTimer *timer,
186+ WindowInputMonitor(UnityUtil::AbstractTimer *timer,
187 UnityUtil::AbstractElapsedTimer *elapsedTimer,
188 QQuickItem *parent = 0);
189
190- virtual ~HomeKeyWatcher();
191+ virtual ~WindowInputMonitor();
192
193 bool eventFilter(QObject *watched, QEvent *event) override;
194
195@@ -56,8 +51,30 @@
196 const qint64 msecsWithoutTouches = 150;
197
198 Q_SIGNALS:
199- // Emitted when the home key has been intentionally tapped
200- void activated();
201+ /**
202+ * Emitted when the home key has been intentionally tapped
203+ *
204+ * It only says the home key has been activated if it has been tapped in isolation,
205+ * that is, without being accompanied by touches on the screen. Home key taps that
206+ * happen along with (or immediately after, or immediately before) touches on the
207+ * screen are considered to have happened unintentionally and are thus ignored.
208+ *
209+ * Rationale being that it's easy to accidentally hit the home key while performing
210+ * a swipe from a screen edge, for instance. That's particularly the case when the
211+ * home key is a capacitive key.
212+ */
213+ void homeKeyActivated();
214+
215+ /**
216+ * Emitted when a touch begin event is detected
217+ */
218+ void touchBegun();
219+
220+ /**
221+ * Emitted when a touch end event is detected
222+ * @param pos the position in screen coordinates
223+ */
224+ void touchEnded(const QPointF &pos);
225
226 private Q_SLOTS:
227 void setupFilterOnWindow(QQuickWindow *window);
228@@ -71,4 +88,4 @@
229 UnityUtil::AbstractTimer *m_activationTimer;
230 };
231
232-#endif // UNITY_HOMEKEYWATCHER_H
233+#endif // UNITY_WINDOWINPUTMONITOR_H
234
235=== modified file 'plugins/Utils/plugin.cpp'
236--- plugins/Utils/plugin.cpp 2015-10-26 16:47:52 +0000
237+++ plugins/Utils/plugin.cpp 2016-01-28 18:26:46 +0000
238@@ -25,7 +25,7 @@
239 // local
240 #include "activefocuslogger.h"
241 #include "easingcurve.h"
242-#include "HomeKeyWatcher.h"
243+#include "WindowInputMonitor.h"
244 #include "inputwatcher.h"
245 #include "qlimitproxymodelqml.h"
246 #include "unitysortfilterproxymodelqml.h"
247@@ -54,7 +54,7 @@
248 void UtilsPlugin::registerTypes(const char *uri)
249 {
250 Q_ASSERT(uri == QLatin1String("Utils"));
251- qmlRegisterType<HomeKeyWatcher>(uri, 0, 1, "HomeKeyWatcher");
252+ qmlRegisterType<WindowInputMonitor>(uri, 0, 1, "WindowInputMonitor");
253 qmlRegisterType<QAbstractItemModel>();
254 qmlRegisterType<QLimitProxyModelQML>(uri, 0, 1, "LimitProxyModel");
255 qmlRegisterType<UnitySortFilterProxyModelQML>(uri, 0, 1, "UnitySortFilterProxyModel");
256
257=== modified file 'qml/Shell.qml'
258--- qml/Shell.qml 2016-01-28 18:26:46 +0000
259+++ qml/Shell.qml 2016-01-28 18:26:46 +0000
260@@ -56,7 +56,6 @@
261 property bool beingResized
262 property string usageScenario: "phone" // supported values: "phone", "tablet" or "desktop"
263 property string mode: "full-greeter"
264- property bool cursorVisible: false
265 property alias oskEnabled: inputMethod.enabled
266 function updateFocusedAppOrientation() {
267 applicationsDisplayLoader.item.updateFocusedAppOrientation();
268@@ -177,8 +176,15 @@
269 Keys.onReleased: physicalKeysMapper.onKeyReleased(event, currentEventTimestamp);
270 }
271
272- HomeKeyWatcher {
273- onActivated: { launcher.fadeOut(); shell.showHome(); }
274+ WindowInputMonitor {
275+ onHomeKeyActivated: { launcher.fadeOut(); shell.showHome(); }
276+ onTouchBegun: { cursor.opacity = 0; }
277+ onTouchEnded: {
278+ // move the (hidden) cursor to the last known touch position
279+ var mappedCoords = mapFromItem(null, pos.x, pos.y);
280+ cursor.x = mappedCoords.x;
281+ cursor.y = mappedCoords.y;
282+ }
283 }
284
285 Item {
286@@ -677,6 +683,8 @@
287 applicationsDisplayLoader.item.pushRightEdge(amount);
288 }
289 }
290+
291+ onMouseMoved: { cursor.opacity = 1; }
292 }
293
294 Rectangle {
295
296=== modified file 'tests/mocks/Cursor/Cursor.qml'
297--- tests/mocks/Cursor/Cursor.qml 2015-11-24 17:44:18 +0000
298+++ tests/mocks/Cursor/Cursor.qml 2016-01-28 18:26:46 +0000
299@@ -19,4 +19,5 @@
300 Item {
301 signal pushedLeftBoundary(real amount, int buttons)
302 signal pushedRightBoundary(real amount, int buttons)
303+ signal mouseMoved()
304 }
305
306=== renamed file 'tests/mocks/Utils/HomeKeyWatcher.qml' => 'tests/mocks/Utils/WindowInputMonitor.qml'
307--- tests/mocks/Utils/HomeKeyWatcher.qml 2015-07-15 15:07:19 +0000
308+++ tests/mocks/Utils/WindowInputMonitor.qml 2016-01-28 18:26:46 +0000
309@@ -17,5 +17,7 @@
310 import QtQuick 2.4
311
312 QtObject {
313- signal activated()
314+ signal homeKeyActivated()
315+ signal touchBegun()
316+ signal touchEnded(point pos)
317 }
318
319=== modified file 'tests/mocks/Utils/qmldir'
320--- tests/mocks/Utils/qmldir 2015-11-24 17:44:18 +0000
321+++ tests/mocks/Utils/qmldir 2016-01-28 18:26:46 +0000
322@@ -2,5 +2,5 @@
323 plugin FakeUtils-qml
324 typeinfo Utils.qmltypes
325 Style 0.1 Style.js
326-HomeKeyWatcher 0.1 HomeKeyWatcher.qml
327+WindowInputMonitor 0.1 WindowInputMonitor.qml
328 singleton EdgeBarrierSettings 0.1 EdgeBarrierSettings.qml
329
330=== modified file 'tests/plugins/Utils/CMakeLists.txt'
331--- tests/plugins/Utils/CMakeLists.txt 2015-07-15 11:37:23 +0000
332+++ tests/plugins/Utils/CMakeLists.txt 2016-01-28 18:26:46 +0000
333@@ -7,7 +7,7 @@
334 foreach(util_test
335 QLimitProxyModel
336 UnitySortFilterProxyModel
337- HomeKeyWatcher
338+ WindowInputMonitor
339 )
340 add_executable(${util_test}TestExec ${util_test}Test.cpp ModelTest.cpp)
341 qt5_use_modules(${util_test}TestExec Test Core Qml)
342
343=== renamed file 'tests/plugins/Utils/HomeKeyWatcherTest.cpp' => 'tests/plugins/Utils/WindowInputMonitorTest.cpp'
344--- tests/plugins/Utils/HomeKeyWatcherTest.cpp 2015-08-19 14:24:07 +0000
345+++ tests/plugins/Utils/WindowInputMonitorTest.cpp 2016-01-28 18:26:46 +0000
346@@ -14,7 +14,7 @@
347 * along with this program. If not, see <http://www.gnu.org/licenses/>.
348 */
349
350-#include "HomeKeyWatcher.h"
351+#include "WindowInputMonitor.h"
352
353 #include <QTest>
354 #include <QSignalSpy>
355@@ -71,7 +71,7 @@
356
357 using namespace UnityUtil;
358
359-class HomeKeyWatcherTest : public QObject {
360+class WindowInputMonitorTest : public QObject {
361 Q_OBJECT
362 private Q_SLOTS:
363 void init(); // called right before each and every test function is executed
364@@ -88,25 +88,25 @@
365 FakeTimerFactory *m_fakeTimerFactory;
366 };
367
368-void HomeKeyWatcherTest::init()
369+void WindowInputMonitorTest::init()
370 {
371 m_fakeTimerFactory = new FakeTimerFactory;
372 }
373
374-void HomeKeyWatcherTest::cleanup()
375+void WindowInputMonitorTest::cleanup()
376 {
377 delete m_fakeTimerFactory;
378 m_fakeTimerFactory = nullptr;
379 }
380
381
382-void HomeKeyWatcherTest::passTime(qint64 timeSpanMs)
383+void WindowInputMonitorTest::passTime(qint64 timeSpanMs)
384 {
385 qint64 finalTime = FakeElapsedTimer::msecsSinceEpoch + timeSpanMs;
386 m_fakeTimerFactory->updateTime(finalTime);
387 }
388
389-void HomeKeyWatcherTest::touchTapTouch_data()
390+void WindowInputMonitorTest::touchTapTouch_data()
391 {
392 QTest::addColumn<int>("silenceBeforeTap");
393 QTest::addColumn<int>("tapDuration");
394@@ -121,14 +121,14 @@
395 QTest::newRow("isolated long press") << 1000 << 200 << 1000 << 0;
396 }
397
398-void HomeKeyWatcherTest::touchTapTouch()
399+void WindowInputMonitorTest::touchTapTouch()
400 {
401 QFETCH(int, silenceBeforeTap);
402 QFETCH(int, tapDuration);
403 QFETCH(int, silenceAfterTap);
404 QFETCH(int, expectedActivatedCount);
405- HomeKeyWatcher homeKeyWatcher(m_fakeTimerFactory->create(), new FakeElapsedTimer);
406- QSignalSpy activatedSpy(&homeKeyWatcher, &HomeKeyWatcher::activated);
407+ WindowInputMonitor homeKeyWatcher(m_fakeTimerFactory->create(), new FakeElapsedTimer);
408+ QSignalSpy activatedSpy(&homeKeyWatcher, &WindowInputMonitor::homeKeyActivated);
409 QVERIFY(activatedSpy.isValid());
410
411 {
412@@ -186,10 +186,10 @@
413 QCOMPARE(activatedSpy.count(), expectedActivatedCount);
414 }
415
416-void HomeKeyWatcherTest::tapWhileTouching()
417+void WindowInputMonitorTest::tapWhileTouching()
418 {
419- HomeKeyWatcher homeKeyWatcher(m_fakeTimerFactory->create(), new FakeElapsedTimer);
420- QSignalSpy activatedSpy(&homeKeyWatcher, &HomeKeyWatcher::activated);
421+ WindowInputMonitor homeKeyWatcher(m_fakeTimerFactory->create(), new FakeElapsedTimer);
422+ QSignalSpy activatedSpy(&homeKeyWatcher, &WindowInputMonitor::homeKeyActivated);
423 QVERIFY(activatedSpy.isValid());
424
425 {
426@@ -318,6 +318,6 @@
427 return fakeTimer;
428 }
429
430-QTEST_GUILESS_MAIN(HomeKeyWatcherTest)
431+QTEST_GUILESS_MAIN(WindowInputMonitorTest)
432
433-#include "HomeKeyWatcherTest.moc"
434+#include "WindowInputMonitorTest.moc"

Subscribers

People subscribed via source and target branches