From kde-commits Tue Apr 24 14:24:22 2018 From: Aleix Pol Date: Tue, 24 Apr 2018 14:24:22 +0000 To: kde-commits Subject: [kwin] /: Don't try to filter null key combinations Message-Id: X-MARC-Message: https://marc.info/?l=kde-commits&m=152457987208999 Git commit 4403e86acc8c4598ef1fbbf27ce2274b9b3ef5c5 by Aleix Pol. Committed on 24/04/2018 at 14:23. Pushed by apol into branch 'master'. Don't try to filter null key combinations Summary: When using composite key combinations, kwin would do random weird actions when the first key was pressed (e.g. ` key). This makes sure we are not trying to match. BUG: 390110 Reviewers: #kwin, graesslin Reviewed By: #kwin, graesslin Subscribers: graesslin, kwin, #kwin Tags: #kwin Differential Revision: https://phabricator.kde.org/D12416 M +20 -0 autotests/integration/globalshortcuts_test.cpp M +3 -0 globalshortcuts.cpp https://commits.kde.org/kwin/4403e86acc8c4598ef1fbbf27ce2274b9b3ef5c5 diff --git a/autotests/integration/globalshortcuts_test.cpp b/autotests/int= egration/globalshortcuts_test.cpp index 6a4024f00..c17721bd1 100644 --- a/autotests/integration/globalshortcuts_test.cpp +++ b/autotests/integration/globalshortcuts_test.cpp @@ -55,6 +55,7 @@ private Q_SLOTS: void testRepeatedTrigger(); void testUserActionsMenu(); void testMetaShiftW(); + void testComponseKey(); void testX11ClientShortcut(); void testWaylandClientShortcut(); void testSetupWindowShortcut(); @@ -203,6 +204,25 @@ void GlobalShortcutsTest::testMetaShiftW() kwinApp()->platform()->keyboardKeyReleased(KEY_LEFTMETA, timestamp++); } = +void GlobalShortcutsTest::testComponseKey() +{ + // BUG 390110 + QScopedPointer action(new QAction(nullptr)); + action->setProperty("componentName", QStringLiteral(KWIN_NAME)); + action->setObjectName(QStringLiteral("globalshortcuts-accent")); + QSignalSpy triggeredSpy(action.data(), &QAction::triggered); + QVERIFY(triggeredSpy.isValid()); + KGlobalAccel::self()->setShortcut(action.data(), QList{Q= t::UNICODE_ACCEL}, KGlobalAccel::NoAutoloading); + input()->registerShortcut(Qt::UNICODE_ACCEL, action.data()); + + // press & release ` + quint32 timestamp =3D 0; + kwinApp()->platform()->keyboardKeyPressed(KEY_RESERVED, timestamp++); + kwinApp()->platform()->keyboardKeyReleased(KEY_RESERVED, timestamp++); + + QTRY_COMPARE(triggeredSpy.count(), 0); +} + struct XcbConnectionDeleter { static inline void cleanup(xcb_connection_t *pointer) diff --git a/globalshortcuts.cpp b/globalshortcuts.cpp index 89fc63235..970c79fbf 100644 --- a/globalshortcuts.cpp +++ b/globalshortcuts.cpp @@ -245,6 +245,9 @@ bool processShortcut(Qt::KeyboardModifiers mods, T key,= U &shortcuts) bool GlobalShortcutsManager::processKey(Qt::KeyboardModifiers mods, int ke= yQt) { if (m_kglobalAccelInterface) { + if (!keyQt && !mods) { + return false; + } auto check =3D [this] (Qt::KeyboardModifiers mods, int keyQt) { bool retVal =3D false; QMetaObject::invokeMethod(m_kglobalAccelInterface,