on xenial help sign in
Cancel the home key activation if something else is pressed along with Meta
13173a8Michael Zanetti
plugins/Utils/WindowInputMonitor.cpp+3
@@ -73,6 +73,9 @@ void WindowInputMonitor::update(QEvent *event)
73 && m_windowLastTouchedTimer->elapsed() >= msecsWithoutTouches) {
73 && m_windowLastTouchedTimer->elapsed() >= msecsWithoutTouches) {
74 m_pressedHomeKey = keyEvent->key();
74 m_pressedHomeKey = keyEvent->key();
75 m_activationTimer->start();
75 m_activationTimer->start();
76+ } else if (m_pressedHomeKey != 0 && !m_homeKeys.contains(keyEvent->key())) {
77+ // something else came in... cancel activation
78+ m_activationTimer->stop();
76 }
79 }
77
80
78 } else if (event->type() == QEvent::KeyRelease) {
81 } else if (event->type() == QEvent::KeyRelease) {
tests/plugins/Utils/WindowInputMonitorTest.cpp+30
@@ -89,6 +89,8 @@ private Q_SLOTS:
89 void tapWhileTouching();
89 void tapWhileTouching();
90 void multipleHomeKeys();
90 void multipleHomeKeys();
91
91
92+ void keyComboInvolvingHome();
93+
92 void repeatedSuperPress();
94 void repeatedSuperPress();
93
95
94private:
96private:
@@ -197,6 +199,34 @@ void WindowInputMonitorTest::touchTapTouch()
197 QCOMPARE(activatedSpy.count(), expectedActivatedCount);
199 QCOMPARE(activatedSpy.count(), expectedActivatedCount);
198}
200}
199
201
202+void WindowInputMonitorTest::keyComboInvolvingHome()
203+{
204+ WindowInputMonitor homeKeyWatcher(m_fakeTimerFactory->create(this), new FakeElapsedTimer);
205+ QSignalSpy activatedSpy(&homeKeyWatcher, &WindowInputMonitor::homeKeyActivated);
206+ QVERIFY(activatedSpy.isValid());
207+
208+ passTime(1000);
209+ {
210+ QKeyEvent keyEvent(QEvent::KeyPress, Qt::Key_Super_L, Qt::NoModifier);
211+ homeKeyWatcher.update(&keyEvent);
212+ }
213+ {
214+ QKeyEvent keyEvent(QEvent::KeyPress, Qt::Key_A, Qt::NoModifier);
215+ homeKeyWatcher.update(&keyEvent);
216+ }
217+ {
218+ QKeyEvent keyEvent(QEvent::KeyRelease, Qt::Key_A, Qt::NoModifier);
219+ homeKeyWatcher.update(&keyEvent);
220+ }
221+ {
222+ QKeyEvent keyEvent(QEvent::KeyRelease, Qt::Key_Super_L, Qt::NoModifier);
223+ homeKeyWatcher.update(&keyEvent);
224+ }
225+ passTime(1000);
226+
227+ QCOMPARE(activatedSpy.count(), 0);
228+}
229+
200void WindowInputMonitorTest::tapWhileTouching()
230void WindowInputMonitorTest::tapWhileTouching()
201{
231{
202 WindowInputMonitor homeKeyWatcher(m_fakeTimerFactory->create(this), new FakeElapsedTimer);
232 WindowInputMonitor homeKeyWatcher(m_fakeTimerFactory->create(this), new FakeElapsedTimer);