on xenial help sign in
rename HomeKeyWatcher.cpp => WindowInputMonitor.cpp
17b5515Lukáš Tinkl
plugins/Utils/CMakeLists.txt+1−1
@@ -13,7 +13,7 @@ set(QMLPLUGIN_SRC
13 ${APPLICATION_API_INCLUDEDIR}/unity/shell/application/ApplicationManagerInterface.h
13 ${APPLICATION_API_INCLUDEDIR}/unity/shell/application/ApplicationManagerInterface.h
14 applicationsfiltermodel.cpp
14 applicationsfiltermodel.cpp
15 constants.cpp
15 constants.cpp
16− HomeKeyWatcher.cpp
16+ WindowInputMonitor.cpp
17 inputwatcher.cpp
17 inputwatcher.cpp
18 qlimitproxymodelqml.cpp
18 qlimitproxymodelqml.cpp
19 unitysortfilterproxymodelqml.cpp
19 unitysortfilterproxymodelqml.cpp
plugins/Utils/HomeKeyWatcher.cpp → plugins/Utils/WindowInputMonitor.cpprenamed+11−11
@@ -14,18 +14,18 @@
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
15 */
16
16
17−#include "HomeKeyWatcher.h"
17+#include "WindowInputMonitor.h"
18
18
19#include <QQuickWindow>
19#include <QQuickWindow>
20
20
21using namespace UnityUtil;
21using namespace UnityUtil;
22
22
23−HomeKeyWatcher::HomeKeyWatcher(QQuickItem *parent)
23+WindowInputMonitor::WindowInputMonitor(QQuickItem *parent)
24− : HomeKeyWatcher(new Timer, new ElapsedTimer, parent)
24+ : WindowInputMonitor(new Timer, new ElapsedTimer, parent)
25{
25{
26}
26}
27
27
28−HomeKeyWatcher::HomeKeyWatcher(UnityUtil::AbstractTimer *timer,
28+WindowInputMonitor::WindowInputMonitor(UnityUtil::AbstractTimer *timer,
29 UnityUtil::AbstractElapsedTimer *elapsedTimer,
29 UnityUtil::AbstractElapsedTimer *elapsedTimer,
30 QQuickItem *parent)
30 QQuickItem *parent)
31 : QQuickItem(parent)
31 : QQuickItem(parent)
@@ -37,20 +37,20 @@ HomeKeyWatcher::HomeKeyWatcher(UnityUtil::AbstractTimer *timer,
37 m_windowLastTouchedTimer->start();
37 m_windowLastTouchedTimer->start();
38
38
39 connect(this, &QQuickItem::windowChanged,
39 connect(this, &QQuickItem::windowChanged,
40− this, &HomeKeyWatcher::setupFilterOnWindow);
40+ this, &WindowInputMonitor::setupFilterOnWindow);
41
41
42 connect(m_activationTimer, &UnityUtil::AbstractTimer::timeout,
42 connect(m_activationTimer, &UnityUtil::AbstractTimer::timeout,
43− this, &HomeKeyWatcher::emitActivatedIfNoTouchesAround);
43+ this, &WindowInputMonitor::emitActivatedIfNoTouchesAround);
44 m_activationTimer->setInterval(msecsWithoutTouches);
44 m_activationTimer->setInterval(msecsWithoutTouches);
45}
45}
46
46
47−HomeKeyWatcher::~HomeKeyWatcher()
47+WindowInputMonitor::~WindowInputMonitor()
48{
48{
49 delete m_windowLastTouchedTimer;
49 delete m_windowLastTouchedTimer;
50 delete m_activationTimer;
50 delete m_activationTimer;
51}
51}
52
52
53−bool HomeKeyWatcher::eventFilter(QObject *watched, QEvent *event)
53+bool WindowInputMonitor::eventFilter(QObject *watched, QEvent *event)
54{
54{
55 Q_ASSERT(!m_filteredWindow.isNull());
55 Q_ASSERT(!m_filteredWindow.isNull());
56 Q_ASSERT(watched == static_cast<QObject*>(m_filteredWindow.data()));
56 Q_ASSERT(watched == static_cast<QObject*>(m_filteredWindow.data()));
@@ -62,7 +62,7 @@ bool HomeKeyWatcher::eventFilter(QObject *watched, QEvent *event)
62 return false;
62 return false;
63}
63}
64
64
65−void HomeKeyWatcher::update(QEvent *event)
65+void WindowInputMonitor::update(QEvent *event)
66{
66{
67 if (event->type() == QEvent::KeyPress) {
67 if (event->type() == QEvent::KeyPress) {
68 QKeyEvent *keyEvent = static_cast<QKeyEvent*>(event);
68 QKeyEvent *keyEvent = static_cast<QKeyEvent*>(event);
@@ -101,7 +101,7 @@ void HomeKeyWatcher::update(QEvent *event)
101 }
101 }
102}
102}
103
103
104−void HomeKeyWatcher::setupFilterOnWindow(QQuickWindow *window)
104+void WindowInputMonitor::setupFilterOnWindow(QQuickWindow *window)
105{
105{
106 if (!m_filteredWindow.isNull()) {
106 if (!m_filteredWindow.isNull()) {
107 m_filteredWindow->removeEventFilter(this);
107 m_filteredWindow->removeEventFilter(this);
@@ -114,7 +114,7 @@ void HomeKeyWatcher::setupFilterOnWindow(QQuickWindow *window)
114 }
114 }
115}
115}
116
116
117−void HomeKeyWatcher::emitActivatedIfNoTouchesAround()
117+void WindowInputMonitor::emitActivatedIfNoTouchesAround()
118{
118{
119 if (!m_homeKeyPressed && !m_windowBeingTouched &&
119 if (!m_homeKeyPressed && !m_windowBeingTouched &&
120 (m_windowLastTouchedTimer->elapsed() > msecsWithoutTouches)) {
120 (m_windowLastTouchedTimer->elapsed() > msecsWithoutTouches)) {
plugins/Utils/HomeKeyWatcher.h → plugins/Utils/WindowInputMonitor.hrenamed+7−7
@@ -14,8 +14,8 @@
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
15 */
16
16
17−#ifndef UNITY_HOMEKEYWATCHER_H
17+#ifndef UNITY_WINDOWINPUTMONITOR_H
18−#define UNITY_HOMEKEYWATCHER_H
18+#define UNITY_WINDOWINPUTMONITOR_H
19
19
20#include <QQuickItem>
20#include <QQuickItem>
21#include <QPointer>
21#include <QPointer>
@@ -35,19 +35,19 @@
35 a swipe from a screen edge, for instance. That's particularly the case when the
35 a swipe from a screen edge, for instance. That's particularly the case when the
36 home key is a capacitive key.
36 home key is a capacitive key.
37 */
37 */
38−class HomeKeyWatcher : public QQuickItem
38+class WindowInputMonitor : public QQuickItem
39{
39{
40 Q_OBJECT
40 Q_OBJECT
41public:
41public:
42
42
43− HomeKeyWatcher(QQuickItem *parent = 0);
43+ WindowInputMonitor(QQuickItem *parent = 0);
44
44
45 // for testing
45 // for testing
46− HomeKeyWatcher(UnityUtil::AbstractTimer *timer,
46+ WindowInputMonitor(UnityUtil::AbstractTimer *timer,
47 UnityUtil::AbstractElapsedTimer *elapsedTimer,
47 UnityUtil::AbstractElapsedTimer *elapsedTimer,
48 QQuickItem *parent = 0);
48 QQuickItem *parent = 0);
49
49
50− virtual ~HomeKeyWatcher();
50+ virtual ~WindowInputMonitor();
51
51
52 bool eventFilter(QObject *watched, QEvent *event) override;
52 bool eventFilter(QObject *watched, QEvent *event) override;
53
53
@@ -74,4 +74,4 @@ private:
74 UnityUtil::AbstractTimer *m_activationTimer;
74 UnityUtil::AbstractTimer *m_activationTimer;
75};
75};
76
76
77−#endif // UNITY_HOMEKEYWATCHER_H
77+#endif // UNITY_WINDOWINPUTMONITOR_H
plugins/Utils/plugin.cpp+2−2
@@ -25,7 +25,7 @@
25// local
25// local
26#include "activefocuslogger.h"
26#include "activefocuslogger.h"
27#include "easingcurve.h"
27#include "easingcurve.h"
28−#include "HomeKeyWatcher.h"
28+#include "WindowInputMonitor.h"
29#include "inputwatcher.h"
29#include "inputwatcher.h"
30#include "qlimitproxymodelqml.h"
30#include "qlimitproxymodelqml.h"
31#include "unitysortfilterproxymodelqml.h"
31#include "unitysortfilterproxymodelqml.h"
@@ -54,7 +54,7 @@ static QObject *createConstants(QQmlEngine *engine, QJSEngine *scriptEngine)
54void UtilsPlugin::registerTypes(const char *uri)
54void UtilsPlugin::registerTypes(const char *uri)
55{
55{
56 Q_ASSERT(uri == QLatin1String("Utils"));
56 Q_ASSERT(uri == QLatin1String("Utils"));
57− qmlRegisterType<HomeKeyWatcher>(uri, 0, 1, "HomeKeyWatcher");
57+ qmlRegisterType<WindowInputMonitor>(uri, 0, 1, "WindowInputMonitor");
58 qmlRegisterType<QAbstractItemModel>();
58 qmlRegisterType<QAbstractItemModel>();
59 qmlRegisterType<QLimitProxyModelQML>(uri, 0, 1, "LimitProxyModel");
59 qmlRegisterType<QLimitProxyModelQML>(uri, 0, 1, "LimitProxyModel");
60 qmlRegisterType<UnitySortFilterProxyModelQML>(uri, 0, 1, "UnitySortFilterProxyModel");
60 qmlRegisterType<UnitySortFilterProxyModelQML>(uri, 0, 1, "UnitySortFilterProxyModel");
qml/Shell.qml+1−1
@@ -195,7 +195,7 @@ Item {
195 Keys.onReleased: physicalKeysMapper.onKeyReleased(event, currentEventTimestamp);
195 Keys.onReleased: physicalKeysMapper.onKeyReleased(event, currentEventTimestamp);
196 }
196 }
197
197
198− HomeKeyWatcher {
198+ WindowInputMonitor {
199 onActivated: { launcher.fadeOut(); shell.showHome(); }
199 onActivated: { launcher.fadeOut(); shell.showHome(); }
200 onWindowTouched: { cursorPriv.hideCursor(); }
200 onWindowTouched: { cursorPriv.hideCursor(); }
201 onWindowReleased: {
201 onWindowReleased: {
tests/plugins/Utils/CMakeLists.txt+1−1
@@ -7,7 +7,7 @@ include_directories(
7foreach(util_test
7foreach(util_test
8 QLimitProxyModel
8 QLimitProxyModel
9 UnitySortFilterProxyModel
9 UnitySortFilterProxyModel
10− HomeKeyWatcher
10+ WindowInputMonitor
11)
11)
12 add_executable(${util_test}TestExec ${util_test}Test.cpp ModelTest.cpp)
12 add_executable(${util_test}TestExec ${util_test}Test.cpp ModelTest.cpp)
13 qt5_use_modules(${util_test}TestExec Test Core Qml)
13 qt5_use_modules(${util_test}TestExec Test Core Qml)
tests/plugins/Utils/HomeKeyWatcherTest.cpp → tests/plugins/Utils/WindowInputMonitorTest.cpprenamed+14−14
@@ -14,7 +14,7 @@
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
15 */
16
16
17−#include "HomeKeyWatcher.h"
17+#include "WindowInputMonitor.h"
18
18
19#include <QTest>
19#include <QTest>
20#include <QSignalSpy>
20#include <QSignalSpy>
@@ -71,7 +71,7 @@ public:
71
71
72using namespace UnityUtil;
72using namespace UnityUtil;
73
73
74−class HomeKeyWatcherTest : public QObject {
74+class WindowInputMonitorTest : public QObject {
75 Q_OBJECT
75 Q_OBJECT
76private Q_SLOTS:
76private Q_SLOTS:
77 void init(); // called right before each and every test function is executed
77 void init(); // called right before each and every test function is executed
@@ -88,25 +88,25 @@ private:
88 FakeTimerFactory *m_fakeTimerFactory;
88 FakeTimerFactory *m_fakeTimerFactory;
89};
89};
90
90
91−void HomeKeyWatcherTest::init()
91+void WindowInputMonitorTest::init()
92{
92{
93 m_fakeTimerFactory = new FakeTimerFactory;
93 m_fakeTimerFactory = new FakeTimerFactory;
94}
94}
95
95
96−void HomeKeyWatcherTest::cleanup()
96+void WindowInputMonitorTest::cleanup()
97{
97{
98 delete m_fakeTimerFactory;
98 delete m_fakeTimerFactory;
99 m_fakeTimerFactory = nullptr;
99 m_fakeTimerFactory = nullptr;
100}
100}
101
101
102
102
103−void HomeKeyWatcherTest::passTime(qint64 timeSpanMs)
103+void WindowInputMonitorTest::passTime(qint64 timeSpanMs)
104{
104{
105 qint64 finalTime = FakeElapsedTimer::msecsSinceEpoch + timeSpanMs;
105 qint64 finalTime = FakeElapsedTimer::msecsSinceEpoch + timeSpanMs;
106 m_fakeTimerFactory->updateTime(finalTime);
106 m_fakeTimerFactory->updateTime(finalTime);
107}
107}
108
108
109−void HomeKeyWatcherTest::touchTapTouch_data()
109+void WindowInputMonitorTest::touchTapTouch_data()
110{
110{
111 QTest::addColumn<int>("silenceBeforeTap");
111 QTest::addColumn<int>("silenceBeforeTap");
112 QTest::addColumn<int>("tapDuration");
112 QTest::addColumn<int>("tapDuration");
@@ -121,14 +121,14 @@ void HomeKeyWatcherTest::touchTapTouch_data()
121 QTest::newRow("isolated long press") << 1000 << 200 << 1000 << 0;
121 QTest::newRow("isolated long press") << 1000 << 200 << 1000 << 0;
122}
122}
123
123
124−void HomeKeyWatcherTest::touchTapTouch()
124+void WindowInputMonitorTest::touchTapTouch()
125{
125{
126 QFETCH(int, silenceBeforeTap);
126 QFETCH(int, silenceBeforeTap);
127 QFETCH(int, tapDuration);
127 QFETCH(int, tapDuration);
128 QFETCH(int, silenceAfterTap);
128 QFETCH(int, silenceAfterTap);
129 QFETCH(int, expectedActivatedCount);
129 QFETCH(int, expectedActivatedCount);
130− HomeKeyWatcher homeKeyWatcher(m_fakeTimerFactory->create(), new FakeElapsedTimer);
130+ WindowInputMonitor homeKeyWatcher(m_fakeTimerFactory->create(), new FakeElapsedTimer);
131− QSignalSpy activatedSpy(&homeKeyWatcher, &HomeKeyWatcher::activated);
131+ QSignalSpy activatedSpy(&homeKeyWatcher, &WindowInputMonitor::activated);
132 QVERIFY(activatedSpy.isValid());
132 QVERIFY(activatedSpy.isValid());
133
133
134 {
134 {
@@ -186,10 +186,10 @@ void HomeKeyWatcherTest::touchTapTouch()
186 QCOMPARE(activatedSpy.count(), expectedActivatedCount);
186 QCOMPARE(activatedSpy.count(), expectedActivatedCount);
187}
187}
188
188
189−void HomeKeyWatcherTest::tapWhileTouching()
189+void WindowInputMonitorTest::tapWhileTouching()
190{
190{
191− HomeKeyWatcher homeKeyWatcher(m_fakeTimerFactory->create(), new FakeElapsedTimer);
191+ WindowInputMonitor homeKeyWatcher(m_fakeTimerFactory->create(), new FakeElapsedTimer);
192− QSignalSpy activatedSpy(&homeKeyWatcher, &HomeKeyWatcher::activated);
192+ QSignalSpy activatedSpy(&homeKeyWatcher, &WindowInputMonitor::activated);
193 QVERIFY(activatedSpy.isValid());
193 QVERIFY(activatedSpy.isValid());
194
194
195 {
195 {
@@ -318,6 +318,6 @@ AbstractTimer *FakeTimerFactory::create(QObject *parent)
318 return fakeTimer;
318 return fakeTimer;
319}
319}
320
320
321−QTEST_GUILESS_MAIN(HomeKeyWatcherTest)
321+QTEST_GUILESS_MAIN(WindowInputMonitorTest)
322
322
323−#include "HomeKeyWatcherTest.moc"
323+#include "WindowInputMonitorTest.moc"