on xenial help sign in
Make sure the home key is released before activation
commit6f711f149709e57aa6ea0a5bec71710bd64f9aca authorMichał Sawicz <michal.sawicz@canonical.com> dateThu 23 Apr 2015, 14:49 (11 years ago) parent5bd30bb
3 files changed+14−1
plugins/Utils/HomeKeyWatcher.cpp+12−1 plugins/Utils/HomeKeyWatcher.h+1 tests/plugins/Utils/homekeywatchertest.cpp+1
plugins/Utils/HomeKeyWatcher.cpp+12−1
@@ -30,6 +30,7 @@ HomeKeyWatcher::HomeKeyWatcher(UnityUtil::AbstractTimer *timer,
3030 QQuickItem *parent)
3131 : QQuickItem(parent)
3232 , m_windowBeingTouched(false)
33+ , m_homeKeyPressed(false)
3334 , m_windowLastTouchedTimer(elapsedTimer)
3435 , m_activationTimer(timer)
3536{
@@ -66,12 +67,21 @@ void HomeKeyWatcher::update(QEvent *event)
6667 if (event->type() == QEvent::KeyPress) {
6768 QKeyEvent *keyEvent = static_cast<QKeyEvent*>(event);
6869
70+ m_homeKeyPressed = true;
71+
6972 if (keyEvent->key() == Qt::Key_Super_L && !keyEvent->isAutoRepeat()
7073 && !m_windowBeingTouched
7174 && m_windowLastTouchedTimer->elapsed() >= msecsWithoutTouches) {
7275 m_activationTimer->start();
7376 }
7477
78+ } else if (event->type() == QEvent::KeyRelease) {
79+ QKeyEvent *keyEvent = static_cast<QKeyEvent*>(event);
80+
81+ if (keyEvent->key() == Qt::Key_Super_L) {
82+ m_homeKeyPressed = false;
83+ }
84+
7585 } else if (event->type() == QEvent::TouchBegin) {
7686
7787 m_activationTimer->stop();
@@ -99,7 +109,8 @@ void HomeKeyWatcher::setupFilterOnWindow(QQuickWindow *window)
99109
100110void HomeKeyWatcher::emitActivatedIfNoTouchesAround()
101111{
102− if (!m_windowBeingTouched && (m_windowLastTouchedTimer->elapsed() > msecsWithoutTouches)) {
112+ if (!m_homeKeyPressed && !m_windowBeingTouched &&
113+ (m_windowLastTouchedTimer->elapsed() > msecsWithoutTouches)) {
103114 Q_EMIT activated();
104115 }
105116}
plugins/Utils/HomeKeyWatcher.h+1
@@ -66,6 +66,7 @@ private Q_SLOTS:
6666private:
6767 QPointer<QQuickWindow> m_filteredWindow;
6868 bool m_windowBeingTouched;
69+ bool m_homeKeyPressed;
6970 UnityUtil::AbstractElapsedTimer *m_windowLastTouchedTimer;
7071 UnityUtil::AbstractTimer *m_activationTimer;
7172};
tests/plugins/Utils/homekeywatchertest.cpp+1
@@ -118,6 +118,7 @@ void HomeKeyWatcherTest::touchTapTouch_data()
118118 QTest::newRow("touch followed by tap") << 10 << 50 << 2000 << 0;
119119 QTest::newRow("touch followed by long tap") << 10 << 500 << 2000 << 0;
120120 QTest::newRow("isolated tap") << 1000 << 50 << 1000 << 1;
121+ QTest::newRow("isolated long press") << 1000 << 200 << 1000 << 0;
121122}
122123
123124void HomeKeyWatcherTest::touchTapTouch()