on xenial help sign in
Make sure the home key is released before activation
6f711f1Michał Sawicz
plugins/Utils/HomeKeyWatcher.cpp+12−1
@@ -30,6 +30,7 @@ HomeKeyWatcher::HomeKeyWatcher(UnityUtil::AbstractTimer *timer,
30 QQuickItem *parent)
30 QQuickItem *parent)
31 : QQuickItem(parent)
31 : QQuickItem(parent)
32 , m_windowBeingTouched(false)
32 , m_windowBeingTouched(false)
33+ , m_homeKeyPressed(false)
33 , m_windowLastTouchedTimer(elapsedTimer)
34 , m_windowLastTouchedTimer(elapsedTimer)
34 , m_activationTimer(timer)
35 , m_activationTimer(timer)
35{
36{
@@ -66,12 +67,21 @@ void HomeKeyWatcher::update(QEvent *event)
66 if (event->type() == QEvent::KeyPress) {
67 if (event->type() == QEvent::KeyPress) {
67 QKeyEvent *keyEvent = static_cast<QKeyEvent*>(event);
68 QKeyEvent *keyEvent = static_cast<QKeyEvent*>(event);
68
69
70+ m_homeKeyPressed = true;
71+
69 if (keyEvent->key() == Qt::Key_Super_L && !keyEvent->isAutoRepeat()
72 if (keyEvent->key() == Qt::Key_Super_L && !keyEvent->isAutoRepeat()
70 && !m_windowBeingTouched
73 && !m_windowBeingTouched
71 && m_windowLastTouchedTimer->elapsed() >= msecsWithoutTouches) {
74 && m_windowLastTouchedTimer->elapsed() >= msecsWithoutTouches) {
72 m_activationTimer->start();
75 m_activationTimer->start();
73 }
76 }
74
77
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+
75 } else if (event->type() == QEvent::TouchBegin) {
85 } else if (event->type() == QEvent::TouchBegin) {
76
86
77 m_activationTimer->stop();
87 m_activationTimer->stop();
@@ -99,7 +109,8 @@ void HomeKeyWatcher::setupFilterOnWindow(QQuickWindow *window)
99
109
100void HomeKeyWatcher::emitActivatedIfNoTouchesAround()
110void HomeKeyWatcher::emitActivatedIfNoTouchesAround()
101{
111{
112+ if (!m_homeKeyPressed && !m_windowBeingTouched &&
102− if (!m_windowBeingTouched && (m_windowLastTouchedTimer->elapsed() > msecsWithoutTouches)) {
113+ (m_windowLastTouchedTimer->elapsed() > msecsWithoutTouches)) {
103 Q_EMIT activated();
114 Q_EMIT activated();
104 }
115 }
105}
116}
plugins/Utils/HomeKeyWatcher.h+1
@@ -66,6 +66,7 @@ private Q_SLOTS:
66private:
66private:
67 QPointer<QQuickWindow> m_filteredWindow;
67 QPointer<QQuickWindow> m_filteredWindow;
68 bool m_windowBeingTouched;
68 bool m_windowBeingTouched;
69+ bool m_homeKeyPressed;
69 UnityUtil::AbstractElapsedTimer *m_windowLastTouchedTimer;
70 UnityUtil::AbstractElapsedTimer *m_windowLastTouchedTimer;
70 UnityUtil::AbstractTimer *m_activationTimer;
71 UnityUtil::AbstractTimer *m_activationTimer;
71};
72};
tests/plugins/Utils/homekeywatchertest.cpp+1
@@ -118,6 +118,7 @@ void HomeKeyWatcherTest::touchTapTouch_data()
118 QTest::newRow("touch followed by tap") << 10 << 50 << 2000 << 0;
118 QTest::newRow("touch followed by tap") << 10 << 50 << 2000 << 0;
119 QTest::newRow("touch followed by long tap") << 10 << 500 << 2000 << 0;
119 QTest::newRow("touch followed by long tap") << 10 << 500 << 2000 << 0;
120 QTest::newRow("isolated tap") << 1000 << 50 << 1000 << 1;
120 QTest::newRow("isolated tap") << 1000 << 50 << 1000 << 1;
121+ QTest::newRow("isolated long press") << 1000 << 200 << 1000 << 0;
121}
122}
122
123
123void HomeKeyWatcherTest::touchTapTouch()
124void HomeKeyWatcherTest::touchTapTouch()