remove modifier only shortcuts
This is now implemented in kglobalacceld BUG: 371560
This commit is contained in:
parent
693603d87a
commit
c05a26f5c4
9 changed files with 0 additions and 517 deletions
|
@ -108,7 +108,6 @@ integrationTest(NAME testXdgShellWindow SRCS xdgshellwindow_test.cpp LIBS KDecor
|
|||
integrationTest(NAME testSceneOpenGL SRCS scene_opengl_test.cpp )
|
||||
integrationTest(NAME testSceneOpenGLES SRCS scene_opengl_es_test.cpp )
|
||||
integrationTest(NAME testScreenChanges SRCS screen_changes_test.cpp)
|
||||
integrationTest(NAME testModiferOnlyShortcut SRCS modifier_only_shortcut_test.cpp LIBS XKB::XKB)
|
||||
if (KWIN_BUILD_TABBOX)
|
||||
integrationTest(NAME testTabBox SRCS tabbox_test.cpp)
|
||||
endif()
|
||||
|
|
|
@ -1,376 +0,0 @@
|
|||
/*
|
||||
KWin - the KDE window manager
|
||||
This file is part of the KDE project.
|
||||
|
||||
SPDX-FileCopyrightText: 2016 Martin Gräßlin <mgraesslin@kde.org>
|
||||
|
||||
SPDX-License-Identifier: GPL-2.0-or-later
|
||||
*/
|
||||
#include <config-kwin.h>
|
||||
|
||||
#include "kwin_wayland_test.h"
|
||||
|
||||
#include "input.h"
|
||||
#include "keyboard_input.h"
|
||||
#include "pointer_input.h"
|
||||
#include "wayland_server.h"
|
||||
#include "workspace.h"
|
||||
#include "xkb.h"
|
||||
|
||||
#include <KConfigGroup>
|
||||
|
||||
#include <QDBusConnection>
|
||||
|
||||
#include <linux/input.h>
|
||||
|
||||
using namespace KWin;
|
||||
|
||||
static const QString s_socketName = QStringLiteral("wayland_test_kwin_modifier_only_shortcut-0");
|
||||
static const QString s_serviceName = QStringLiteral("org.kde.KWin.Test.ModifierOnlyShortcut");
|
||||
static const QString s_path = QStringLiteral("/Test");
|
||||
|
||||
class ModifierOnlyShortcutTest : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
private Q_SLOTS:
|
||||
void initTestCase();
|
||||
void init();
|
||||
void cleanup();
|
||||
|
||||
void testTrigger_data();
|
||||
void testTrigger();
|
||||
void testCapsLock();
|
||||
void testGlobalShortcutsDisabled_data();
|
||||
void testGlobalShortcutsDisabled();
|
||||
};
|
||||
|
||||
class Target : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_CLASSINFO("D-Bus Interface", "org.kde.KWin.Test.ModifierOnlyShortcut")
|
||||
|
||||
public:
|
||||
Target();
|
||||
~Target() override;
|
||||
|
||||
public Q_SLOTS:
|
||||
Q_SCRIPTABLE void shortcut();
|
||||
|
||||
Q_SIGNALS:
|
||||
void shortcutTriggered();
|
||||
};
|
||||
|
||||
Target::Target()
|
||||
: QObject()
|
||||
{
|
||||
QDBusConnection::sessionBus().registerService(s_serviceName);
|
||||
QDBusConnection::sessionBus().registerObject(s_path, s_serviceName, this, QDBusConnection::ExportScriptableSlots);
|
||||
}
|
||||
|
||||
Target::~Target()
|
||||
{
|
||||
QDBusConnection::sessionBus().unregisterObject(s_path);
|
||||
QDBusConnection::sessionBus().unregisterService(s_serviceName);
|
||||
}
|
||||
|
||||
void Target::shortcut()
|
||||
{
|
||||
Q_EMIT shortcutTriggered();
|
||||
}
|
||||
|
||||
void ModifierOnlyShortcutTest::initTestCase()
|
||||
{
|
||||
QSignalSpy applicationStartedSpy(kwinApp(), &Application::started);
|
||||
QVERIFY(waylandServer()->init(s_socketName));
|
||||
Test::setOutputConfig({
|
||||
QRect(0, 0, 1280, 1024),
|
||||
QRect(1280, 0, 1280, 1024),
|
||||
});
|
||||
|
||||
kwinApp()->setConfig(KSharedConfig::openConfig(QString(), KConfig::SimpleConfig));
|
||||
qputenv("KWIN_XKB_DEFAULT_KEYMAP", "1");
|
||||
qputenv("XKB_DEFAULT_RULES", "evdev");
|
||||
|
||||
kwinApp()->start();
|
||||
QVERIFY(applicationStartedSpy.wait());
|
||||
}
|
||||
|
||||
void ModifierOnlyShortcutTest::init()
|
||||
{
|
||||
workspace()->setActiveOutput(QPoint(640, 512));
|
||||
KWin::input()->pointer()->warp(QPoint(640, 512));
|
||||
}
|
||||
|
||||
void ModifierOnlyShortcutTest::cleanup()
|
||||
{
|
||||
}
|
||||
|
||||
void ModifierOnlyShortcutTest::testTrigger_data()
|
||||
{
|
||||
QTest::addColumn<QStringList>("metaConfig");
|
||||
QTest::addColumn<QStringList>("altConfig");
|
||||
QTest::addColumn<QStringList>("controlConfig");
|
||||
QTest::addColumn<QStringList>("shiftConfig");
|
||||
QTest::addColumn<int>("modifier");
|
||||
QTest::addColumn<QList<int>>("nonTriggeringMods");
|
||||
|
||||
const QStringList trigger = QStringList{s_serviceName, s_path, s_serviceName, QStringLiteral("shortcut")};
|
||||
const QStringList e = QStringList();
|
||||
|
||||
QTest::newRow("leftMeta") << trigger << e << e << e << KEY_LEFTMETA << QList<int>{KEY_LEFTALT, KEY_RIGHTALT, KEY_LEFTCTRL, KEY_RIGHTCTRL, KEY_LEFTSHIFT, KEY_RIGHTSHIFT};
|
||||
QTest::newRow("rightMeta") << trigger << e << e << e << KEY_RIGHTMETA << QList<int>{KEY_LEFTALT, KEY_RIGHTALT, KEY_LEFTCTRL, KEY_RIGHTCTRL, KEY_LEFTSHIFT, KEY_RIGHTSHIFT};
|
||||
QTest::newRow("leftAlt") << e << trigger << e << e << KEY_LEFTALT << QList<int>{KEY_LEFTMETA, KEY_RIGHTMETA, KEY_LEFTCTRL, KEY_RIGHTCTRL, KEY_LEFTSHIFT, KEY_RIGHTSHIFT};
|
||||
QTest::newRow("rightAlt") << e << trigger << e << e << KEY_RIGHTALT << QList<int>{KEY_LEFTMETA, KEY_RIGHTMETA, KEY_LEFTCTRL, KEY_RIGHTCTRL, KEY_LEFTSHIFT, KEY_RIGHTSHIFT};
|
||||
QTest::newRow("leftControl") << e << e << trigger << e << KEY_LEFTCTRL << QList<int>{KEY_LEFTALT, KEY_RIGHTALT, KEY_LEFTMETA, KEY_RIGHTMETA, KEY_LEFTSHIFT, KEY_RIGHTSHIFT};
|
||||
QTest::newRow("rightControl") << e << e << trigger << e << KEY_RIGHTCTRL << QList<int>{KEY_LEFTALT, KEY_RIGHTALT, KEY_LEFTMETA, KEY_RIGHTMETA, KEY_LEFTSHIFT, KEY_RIGHTSHIFT};
|
||||
QTest::newRow("leftShift") << e << e << e << trigger << KEY_LEFTSHIFT << QList<int>{KEY_LEFTALT, KEY_RIGHTALT, KEY_LEFTCTRL, KEY_RIGHTCTRL, KEY_LEFTMETA, KEY_RIGHTMETA};
|
||||
QTest::newRow("rightShift") << e << e << e << trigger << KEY_RIGHTSHIFT << QList<int>{KEY_LEFTALT, KEY_RIGHTALT, KEY_LEFTCTRL, KEY_RIGHTCTRL, KEY_LEFTMETA, KEY_RIGHTMETA};
|
||||
}
|
||||
|
||||
void ModifierOnlyShortcutTest::testTrigger()
|
||||
{
|
||||
// this test verifies that modifier only shortcut triggers correctly
|
||||
Target target;
|
||||
QSignalSpy triggeredSpy(&target, &Target::shortcutTriggered);
|
||||
|
||||
KConfigGroup group = kwinApp()->config()->group(QStringLiteral("ModifierOnlyShortcuts"));
|
||||
QFETCH(QStringList, metaConfig);
|
||||
QFETCH(QStringList, altConfig);
|
||||
QFETCH(QStringList, shiftConfig);
|
||||
QFETCH(QStringList, controlConfig);
|
||||
group.writeEntry("Meta", metaConfig);
|
||||
group.writeEntry("Alt", altConfig);
|
||||
group.writeEntry("Shift", shiftConfig);
|
||||
group.writeEntry("Control", controlConfig);
|
||||
group.sync();
|
||||
workspace()->slotReconfigure();
|
||||
|
||||
// configured shortcut should trigger
|
||||
quint32 timestamp = 1;
|
||||
QFETCH(int, modifier);
|
||||
Test::keyboardKeyPressed(modifier, timestamp++);
|
||||
Test::keyboardKeyReleased(modifier, timestamp++);
|
||||
QCOMPARE(triggeredSpy.count(), 1);
|
||||
|
||||
// the other shortcuts should not trigger
|
||||
QFETCH(QList<int>, nonTriggeringMods);
|
||||
for (auto it = nonTriggeringMods.constBegin(), end = nonTriggeringMods.constEnd(); it != end; it++) {
|
||||
Test::keyboardKeyPressed(*it, timestamp++);
|
||||
Test::keyboardKeyReleased(*it, timestamp++);
|
||||
QCOMPARE(triggeredSpy.count(), 1);
|
||||
}
|
||||
|
||||
// try configured again
|
||||
Test::keyboardKeyPressed(modifier, timestamp++);
|
||||
Test::keyboardKeyReleased(modifier, timestamp++);
|
||||
QCOMPARE(triggeredSpy.count(), 2);
|
||||
|
||||
// click another key while modifier is held
|
||||
Test::keyboardKeyPressed(modifier, timestamp++);
|
||||
Test::keyboardKeyPressed(KEY_A, timestamp++);
|
||||
Test::keyboardKeyReleased(KEY_A, timestamp++);
|
||||
Test::keyboardKeyReleased(modifier, timestamp++);
|
||||
QCOMPARE(triggeredSpy.count(), 2);
|
||||
|
||||
// release other key after modifier release
|
||||
Test::keyboardKeyPressed(modifier, timestamp++);
|
||||
Test::keyboardKeyPressed(KEY_A, timestamp++);
|
||||
Test::keyboardKeyReleased(modifier, timestamp++);
|
||||
Test::keyboardKeyReleased(KEY_A, timestamp++);
|
||||
QCOMPARE(triggeredSpy.count(), 2);
|
||||
|
||||
// press key before pressing modifier
|
||||
Test::keyboardKeyPressed(KEY_A, timestamp++);
|
||||
Test::keyboardKeyPressed(modifier, timestamp++);
|
||||
Test::keyboardKeyReleased(modifier, timestamp++);
|
||||
Test::keyboardKeyReleased(KEY_A, timestamp++);
|
||||
QCOMPARE(triggeredSpy.count(), 2);
|
||||
|
||||
// mouse button pressed before clicking modifier
|
||||
Test::pointerButtonPressed(BTN_LEFT, timestamp++);
|
||||
QCOMPARE(input()->qtButtonStates(), Qt::LeftButton);
|
||||
Test::keyboardKeyPressed(modifier, timestamp++);
|
||||
Test::keyboardKeyReleased(modifier, timestamp++);
|
||||
Test::pointerButtonReleased(BTN_LEFT, timestamp++);
|
||||
QCOMPARE(input()->qtButtonStates(), Qt::NoButton);
|
||||
QCOMPARE(triggeredSpy.count(), 2);
|
||||
|
||||
// mouse button press before mod press, release before mod release
|
||||
Test::pointerButtonPressed(BTN_LEFT, timestamp++);
|
||||
QCOMPARE(input()->qtButtonStates(), Qt::LeftButton);
|
||||
Test::keyboardKeyPressed(modifier, timestamp++);
|
||||
Test::pointerButtonReleased(BTN_LEFT, timestamp++);
|
||||
Test::keyboardKeyReleased(modifier, timestamp++);
|
||||
QCOMPARE(input()->qtButtonStates(), Qt::NoButton);
|
||||
QCOMPARE(triggeredSpy.count(), 2);
|
||||
|
||||
// mouse button click while mod is pressed
|
||||
Test::keyboardKeyPressed(modifier, timestamp++);
|
||||
Test::pointerButtonPressed(BTN_LEFT, timestamp++);
|
||||
QCOMPARE(input()->qtButtonStates(), Qt::LeftButton);
|
||||
Test::pointerButtonReleased(BTN_LEFT, timestamp++);
|
||||
Test::keyboardKeyReleased(modifier, timestamp++);
|
||||
QCOMPARE(input()->qtButtonStates(), Qt::NoButton);
|
||||
QCOMPARE(triggeredSpy.count(), 2);
|
||||
|
||||
// scroll while mod is pressed
|
||||
Test::keyboardKeyPressed(modifier, timestamp++);
|
||||
Test::pointerAxisVertical(5.0, timestamp++);
|
||||
Test::keyboardKeyReleased(modifier, timestamp++);
|
||||
QCOMPARE(triggeredSpy.count(), 2);
|
||||
|
||||
// same for horizontal
|
||||
Test::keyboardKeyPressed(modifier, timestamp++);
|
||||
Test::pointerAxisHorizontal(5.0, timestamp++);
|
||||
Test::keyboardKeyReleased(modifier, timestamp++);
|
||||
QCOMPARE(triggeredSpy.count(), 2);
|
||||
|
||||
#if KWIN_BUILD_SCREENLOCKER
|
||||
// now try to lock the screen while modifier key is pressed
|
||||
Test::keyboardKeyPressed(modifier, timestamp++);
|
||||
QVERIFY(Test::lockScreen());
|
||||
Test::keyboardKeyReleased(modifier, timestamp++);
|
||||
QCOMPARE(triggeredSpy.count(), 2);
|
||||
|
||||
// now trigger while screen is locked, should also not work
|
||||
Test::keyboardKeyPressed(modifier, timestamp++);
|
||||
Test::keyboardKeyReleased(modifier, timestamp++);
|
||||
QCOMPARE(triggeredSpy.count(), 2);
|
||||
|
||||
QVERIFY(Test::unlockScreen());
|
||||
#endif
|
||||
}
|
||||
|
||||
void ModifierOnlyShortcutTest::testCapsLock()
|
||||
{
|
||||
// this test verifies that Capslock does not trigger the shift shortcut
|
||||
// but other shortcuts still trigger even when Capslock is on
|
||||
Target target;
|
||||
QSignalSpy triggeredSpy(&target, &Target::shortcutTriggered);
|
||||
|
||||
KConfigGroup group = kwinApp()->config()->group(QStringLiteral("ModifierOnlyShortcuts"));
|
||||
group.writeEntry("Meta", QStringList());
|
||||
group.writeEntry("Alt", QStringList());
|
||||
group.writeEntry("Shift", QStringList{s_serviceName, s_path, s_serviceName, QStringLiteral("shortcut")});
|
||||
group.writeEntry("Control", QStringList());
|
||||
group.sync();
|
||||
workspace()->slotReconfigure();
|
||||
|
||||
// first test that the normal shortcut triggers
|
||||
quint32 timestamp = 1;
|
||||
const int modifier = KEY_LEFTSHIFT;
|
||||
Test::keyboardKeyPressed(modifier, timestamp++);
|
||||
Test::keyboardKeyReleased(modifier, timestamp++);
|
||||
QCOMPARE(triggeredSpy.count(), 1);
|
||||
|
||||
// now capslock
|
||||
Test::keyboardKeyPressed(KEY_CAPSLOCK, timestamp++);
|
||||
Test::keyboardKeyReleased(KEY_CAPSLOCK, timestamp++);
|
||||
QCOMPARE(input()->keyboardModifiers(), Qt::NoModifier);
|
||||
QCOMPARE(triggeredSpy.count(), 1);
|
||||
|
||||
// currently caps lock is on
|
||||
// shift still triggers
|
||||
Test::keyboardKeyPressed(modifier, timestamp++);
|
||||
Test::keyboardKeyReleased(modifier, timestamp++);
|
||||
QCOMPARE(input()->keyboardModifiers(), Qt::NoModifier);
|
||||
QCOMPARE(triggeredSpy.count(), 2);
|
||||
|
||||
// meta should also trigger
|
||||
group.writeEntry("Meta", QStringList{s_serviceName, s_path, s_serviceName, QStringLiteral("shortcut")});
|
||||
group.writeEntry("Alt", QStringList());
|
||||
group.writeEntry("Shift", QStringList{});
|
||||
group.writeEntry("Control", QStringList());
|
||||
group.sync();
|
||||
workspace()->slotReconfigure();
|
||||
Test::keyboardKeyPressed(KEY_LEFTMETA, timestamp++);
|
||||
QCOMPARE(input()->keyboardModifiers(), Qt::MetaModifier);
|
||||
QCOMPARE(input()->keyboard()->xkb()->modifiersRelevantForGlobalShortcuts(), Qt::MetaModifier);
|
||||
Test::keyboardKeyReleased(KEY_LEFTMETA, timestamp++);
|
||||
QCOMPARE(triggeredSpy.count(), 3);
|
||||
|
||||
// set back to shift to ensure we don't trigger with capslock
|
||||
group.writeEntry("Meta", QStringList());
|
||||
group.writeEntry("Alt", QStringList());
|
||||
group.writeEntry("Shift", QStringList{s_serviceName, s_path, s_serviceName, QStringLiteral("shortcut")});
|
||||
group.writeEntry("Control", QStringList());
|
||||
group.sync();
|
||||
workspace()->slotReconfigure();
|
||||
|
||||
// release caps lock
|
||||
Test::keyboardKeyPressed(KEY_CAPSLOCK, timestamp++);
|
||||
Test::keyboardKeyReleased(KEY_CAPSLOCK, timestamp++);
|
||||
QCOMPARE(input()->keyboardModifiers(), Qt::NoModifier);
|
||||
QCOMPARE(triggeredSpy.count(), 3);
|
||||
}
|
||||
|
||||
void ModifierOnlyShortcutTest::testGlobalShortcutsDisabled_data()
|
||||
{
|
||||
QTest::addColumn<QStringList>("metaConfig");
|
||||
QTest::addColumn<QStringList>("altConfig");
|
||||
QTest::addColumn<QStringList>("controlConfig");
|
||||
QTest::addColumn<QStringList>("shiftConfig");
|
||||
QTest::addColumn<int>("modifier");
|
||||
|
||||
const QStringList trigger = QStringList{s_serviceName, s_path, s_serviceName, QStringLiteral("shortcut")};
|
||||
const QStringList e = QStringList();
|
||||
|
||||
QTest::newRow("leftMeta") << trigger << e << e << e << KEY_LEFTMETA;
|
||||
QTest::newRow("rightMeta") << trigger << e << e << e << KEY_RIGHTMETA;
|
||||
QTest::newRow("leftAlt") << e << trigger << e << e << KEY_LEFTALT;
|
||||
QTest::newRow("rightAlt") << e << trigger << e << e << KEY_RIGHTALT;
|
||||
QTest::newRow("leftControl") << e << e << trigger << e << KEY_LEFTCTRL;
|
||||
QTest::newRow("rightControl") << e << e << trigger << e << KEY_RIGHTCTRL;
|
||||
QTest::newRow("leftShift") << e << e << e << trigger << KEY_LEFTSHIFT;
|
||||
QTest::newRow("rightShift") << e << e << e << trigger << KEY_RIGHTSHIFT;
|
||||
}
|
||||
|
||||
void ModifierOnlyShortcutTest::testGlobalShortcutsDisabled()
|
||||
{
|
||||
// this test verifies that when global shortcuts are disabled inside KWin (e.g. through a window rule)
|
||||
// the modifier only shortcuts do not trigger.
|
||||
// see BUG: 370146
|
||||
Target target;
|
||||
QSignalSpy triggeredSpy(&target, &Target::shortcutTriggered);
|
||||
|
||||
KConfigGroup group = kwinApp()->config()->group(QStringLiteral("ModifierOnlyShortcuts"));
|
||||
QFETCH(QStringList, metaConfig);
|
||||
QFETCH(QStringList, altConfig);
|
||||
QFETCH(QStringList, shiftConfig);
|
||||
QFETCH(QStringList, controlConfig);
|
||||
group.writeEntry("Meta", metaConfig);
|
||||
group.writeEntry("Alt", altConfig);
|
||||
group.writeEntry("Shift", shiftConfig);
|
||||
group.writeEntry("Control", controlConfig);
|
||||
group.sync();
|
||||
workspace()->slotReconfigure();
|
||||
|
||||
// trigger once to verify the shortcut works
|
||||
quint32 timestamp = 1;
|
||||
QFETCH(int, modifier);
|
||||
QVERIFY(!workspace()->globalShortcutsDisabled());
|
||||
Test::keyboardKeyPressed(modifier, timestamp++);
|
||||
Test::keyboardKeyReleased(modifier, timestamp++);
|
||||
QCOMPARE(triggeredSpy.count(), 1);
|
||||
triggeredSpy.clear();
|
||||
|
||||
// now disable global shortcuts
|
||||
workspace()->disableGlobalShortcutsForClient(true);
|
||||
QVERIFY(workspace()->globalShortcutsDisabled());
|
||||
// Should not get triggered
|
||||
Test::keyboardKeyPressed(modifier, timestamp++);
|
||||
Test::keyboardKeyReleased(modifier, timestamp++);
|
||||
QCOMPARE(triggeredSpy.count(), 0);
|
||||
triggeredSpy.clear();
|
||||
|
||||
// enable again
|
||||
workspace()->disableGlobalShortcutsForClient(false);
|
||||
QVERIFY(!workspace()->globalShortcutsDisabled());
|
||||
// should get triggered again
|
||||
Test::keyboardKeyPressed(modifier, timestamp++);
|
||||
Test::keyboardKeyReleased(modifier, timestamp++);
|
||||
QCOMPARE(triggeredSpy.count(), 1);
|
||||
}
|
||||
|
||||
WAYLANDTEST_MAIN(ModifierOnlyShortcutTest)
|
||||
#include "modifier_only_shortcut_test.moc"
|
|
@ -26,8 +26,6 @@
|
|||
using namespace KWin;
|
||||
|
||||
static const QString s_socketName = QStringLiteral("wayland_test_kwin_no_global_shortcuts-0");
|
||||
static const QString s_serviceName = QStringLiteral("org.kde.KWin.Test.ModifierOnlyShortcut");
|
||||
static const QString s_path = QStringLiteral("/Test");
|
||||
|
||||
Q_DECLARE_METATYPE(KWin::ElectricBorder)
|
||||
|
||||
|
@ -42,8 +40,6 @@ private Q_SLOTS:
|
|||
void init();
|
||||
void cleanup();
|
||||
|
||||
void testTrigger_data();
|
||||
void testTrigger();
|
||||
void testKGlobalAccel();
|
||||
void testPointerShortcut();
|
||||
void testAxisShortcut_data();
|
||||
|
@ -54,7 +50,6 @@ private Q_SLOTS:
|
|||
class Target : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_CLASSINFO("D-Bus Interface", "org.kde.KWin.Test.ModifierOnlyShortcut")
|
||||
|
||||
public:
|
||||
Target();
|
||||
|
@ -70,14 +65,10 @@ Q_SIGNALS:
|
|||
Target::Target()
|
||||
: QObject()
|
||||
{
|
||||
QDBusConnection::sessionBus().registerService(s_serviceName);
|
||||
QDBusConnection::sessionBus().registerObject(s_path, s_serviceName, this, QDBusConnection::ExportScriptableSlots);
|
||||
}
|
||||
|
||||
Target::~Target()
|
||||
{
|
||||
QDBusConnection::sessionBus().unregisterObject(s_path);
|
||||
QDBusConnection::sessionBus().unregisterService(s_serviceName);
|
||||
}
|
||||
|
||||
void Target::shortcut()
|
||||
|
@ -113,62 +104,6 @@ void NoGlobalShortcutsTest::cleanup()
|
|||
{
|
||||
}
|
||||
|
||||
void NoGlobalShortcutsTest::testTrigger_data()
|
||||
{
|
||||
QTest::addColumn<QStringList>("metaConfig");
|
||||
QTest::addColumn<QStringList>("altConfig");
|
||||
QTest::addColumn<QStringList>("controlConfig");
|
||||
QTest::addColumn<QStringList>("shiftConfig");
|
||||
QTest::addColumn<int>("modifier");
|
||||
QTest::addColumn<QList<int>>("nonTriggeringMods");
|
||||
|
||||
const QStringList trigger = QStringList{s_serviceName, s_path, s_serviceName, QStringLiteral("shortcut")};
|
||||
const QStringList e = QStringList();
|
||||
|
||||
QTest::newRow("leftMeta") << trigger << e << e << e << KEY_LEFTMETA << QList<int>{KEY_LEFTALT, KEY_RIGHTALT, KEY_LEFTCTRL, KEY_RIGHTCTRL, KEY_LEFTSHIFT, KEY_RIGHTSHIFT};
|
||||
QTest::newRow("rightMeta") << trigger << e << e << e << KEY_RIGHTMETA << QList<int>{KEY_LEFTALT, KEY_RIGHTALT, KEY_LEFTCTRL, KEY_RIGHTCTRL, KEY_LEFTSHIFT, KEY_RIGHTSHIFT};
|
||||
QTest::newRow("leftAlt") << e << trigger << e << e << KEY_LEFTALT << QList<int>{KEY_LEFTMETA, KEY_RIGHTMETA, KEY_LEFTCTRL, KEY_RIGHTCTRL, KEY_LEFTSHIFT, KEY_RIGHTSHIFT};
|
||||
QTest::newRow("rightAlt") << e << trigger << e << e << KEY_RIGHTALT << QList<int>{KEY_LEFTMETA, KEY_RIGHTMETA, KEY_LEFTCTRL, KEY_RIGHTCTRL, KEY_LEFTSHIFT, KEY_RIGHTSHIFT};
|
||||
QTest::newRow("leftControl") << e << e << trigger << e << KEY_LEFTCTRL << QList<int>{KEY_LEFTALT, KEY_RIGHTALT, KEY_LEFTMETA, KEY_RIGHTMETA, KEY_LEFTSHIFT, KEY_RIGHTSHIFT};
|
||||
QTest::newRow("rightControl") << e << e << trigger << e << KEY_RIGHTCTRL << QList<int>{KEY_LEFTALT, KEY_RIGHTALT, KEY_LEFTMETA, KEY_RIGHTMETA, KEY_LEFTSHIFT, KEY_RIGHTSHIFT};
|
||||
QTest::newRow("leftShift") << e << e << e << trigger << KEY_LEFTSHIFT << QList<int>{KEY_LEFTALT, KEY_RIGHTALT, KEY_LEFTCTRL, KEY_RIGHTCTRL, KEY_LEFTMETA, KEY_RIGHTMETA};
|
||||
QTest::newRow("rightShift") << e << e << e << trigger << KEY_RIGHTSHIFT << QList<int>{KEY_LEFTALT, KEY_RIGHTALT, KEY_LEFTCTRL, KEY_RIGHTCTRL, KEY_LEFTMETA, KEY_RIGHTMETA};
|
||||
}
|
||||
|
||||
void NoGlobalShortcutsTest::testTrigger()
|
||||
{
|
||||
// test based on ModifierOnlyShortcutTest::testTrigger
|
||||
Target target;
|
||||
QSignalSpy triggeredSpy(&target, &Target::shortcutTriggered);
|
||||
|
||||
KConfigGroup group = kwinApp()->config()->group(QStringLiteral("ModifierOnlyShortcuts"));
|
||||
QFETCH(QStringList, metaConfig);
|
||||
QFETCH(QStringList, altConfig);
|
||||
QFETCH(QStringList, shiftConfig);
|
||||
QFETCH(QStringList, controlConfig);
|
||||
group.writeEntry("Meta", metaConfig);
|
||||
group.writeEntry("Alt", altConfig);
|
||||
group.writeEntry("Shift", shiftConfig);
|
||||
group.writeEntry("Control", controlConfig);
|
||||
group.sync();
|
||||
workspace()->slotReconfigure();
|
||||
|
||||
// configured shortcut should trigger
|
||||
quint32 timestamp = 1;
|
||||
QFETCH(int, modifier);
|
||||
Test::keyboardKeyPressed(modifier, timestamp++);
|
||||
Test::keyboardKeyReleased(modifier, timestamp++);
|
||||
QCOMPARE(triggeredSpy.count(), 0);
|
||||
|
||||
// the other shortcuts should not trigger
|
||||
QFETCH(QList<int>, nonTriggeringMods);
|
||||
for (auto it = nonTriggeringMods.constBegin(), end = nonTriggeringMods.constEnd(); it != end; it++) {
|
||||
Test::keyboardKeyPressed(*it, timestamp++);
|
||||
Test::keyboardKeyReleased(*it, timestamp++);
|
||||
QCOMPARE(triggeredSpy.count(), 0);
|
||||
}
|
||||
}
|
||||
|
||||
void NoGlobalShortcutsTest::testKGlobalAccel()
|
||||
{
|
||||
std::unique_ptr<QAction> action(new QAction(nullptr));
|
||||
|
|
|
@ -120,7 +120,6 @@ target_sources(kwin PRIVATE
|
|||
layershellv1window.cpp
|
||||
lidswitchtracker.cpp
|
||||
main.cpp
|
||||
modifier_only_shortcuts.cpp
|
||||
mousebuttons.cpp
|
||||
onscreennotification.cpp
|
||||
opengl/abstract_opengl_context_attribute_builder.cpp
|
||||
|
|
|
@ -21,7 +21,6 @@
|
|||
#include "effect/globals.h"
|
||||
#include "effect/xcb.h"
|
||||
#include "input.h"
|
||||
#include "modifier_only_shortcuts.h"
|
||||
#include "workspace.h"
|
||||
#include "x11eventfilter.h"
|
||||
|
||||
|
@ -280,9 +279,6 @@ void XInputIntegration::startListening()
|
|||
m_xiEventFilter->setDisplay(display());
|
||||
m_keyPressFilter = std::make_unique<XKeyPressReleaseEventFilter>(XCB_KEY_PRESS);
|
||||
m_keyReleaseFilter = std::make_unique<XKeyPressReleaseEventFilter>(XCB_KEY_RELEASE);
|
||||
|
||||
// install the input event spies also relevant for X11 platform
|
||||
input()->installInputEventSpy(new ModifierOnlyShortcuts);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -15,7 +15,6 @@
|
|||
#include "inputmethod.h"
|
||||
#include "keyboard_layout.h"
|
||||
#include "keyboard_repeat.h"
|
||||
#include "modifier_only_shortcuts.h"
|
||||
#include "wayland/datadevice.h"
|
||||
#include "wayland/keyboard.h"
|
||||
#include "wayland/seat.h"
|
||||
|
@ -129,10 +128,6 @@ void KeyboardInputRedirection::init()
|
|||
m_keyboardLayout->init();
|
||||
m_input->installInputEventSpy(m_keyboardLayout);
|
||||
|
||||
if (waylandServer()->hasGlobalShortcutSupport()) {
|
||||
m_input->installInputEventSpy(new ModifierOnlyShortcuts);
|
||||
}
|
||||
|
||||
KeyboardRepeat *keyRepeatSpy = new KeyboardRepeat(m_xkb.get());
|
||||
connect(keyRepeatSpy, &KeyboardRepeat::keyRepeat, this,
|
||||
std::bind(&KeyboardInputRedirection::processKey, this, std::placeholders::_1, InputRedirection::KeyboardKeyAutoRepeat, std::placeholders::_2, nullptr));
|
||||
|
|
|
@ -1,43 +0,0 @@
|
|||
/*
|
||||
KWin - the KDE window manager
|
||||
This file is part of the KDE project.
|
||||
|
||||
SPDX-FileCopyrightText: 2016, 2017 Martin Gräßlin <mgraesslin@kde.org>
|
||||
|
||||
SPDX-License-Identifier: GPL-2.0-or-later
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include "input_event_spy.h"
|
||||
#include <kwin_export.h>
|
||||
|
||||
#include <QObject>
|
||||
#include <QSet>
|
||||
|
||||
namespace KWin
|
||||
{
|
||||
|
||||
class KWIN_EXPORT ModifierOnlyShortcuts : public QObject, public InputEventSpy
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit ModifierOnlyShortcuts();
|
||||
~ModifierOnlyShortcuts() override;
|
||||
|
||||
void keyEvent(KeyEvent *event) override;
|
||||
void pointerEvent(MouseEvent *event) override;
|
||||
void wheelEvent(WheelEvent *event) override;
|
||||
|
||||
void reset()
|
||||
{
|
||||
m_modifier = Qt::NoModifier;
|
||||
}
|
||||
|
||||
private:
|
||||
Qt::KeyboardModifier m_modifier = Qt::NoModifier;
|
||||
Qt::KeyboardModifiers m_cachedMods;
|
||||
Qt::MouseButtons m_pressedButtons;
|
||||
QSet<quint32> m_pressedKeys;
|
||||
};
|
||||
|
||||
}
|
|
@ -742,20 +742,6 @@ void Options::loadConfig()
|
|||
setCommandAll2(mouseCommand(config.readEntry("CommandAll2", "Toggle raise and lower"), false));
|
||||
setCommandAll3(mouseCommand(config.readEntry("CommandAll3", "Resize"), false));
|
||||
|
||||
// Modifier Only Shortcuts
|
||||
config = KConfigGroup(m_settings->config(), QStringLiteral("ModifierOnlyShortcuts"));
|
||||
m_modifierOnlyShortcuts.clear();
|
||||
if (config.hasKey("Shift")) {
|
||||
m_modifierOnlyShortcuts.insert(Qt::ShiftModifier, config.readEntry("Shift", QStringList()));
|
||||
}
|
||||
if (config.hasKey("Control")) {
|
||||
m_modifierOnlyShortcuts.insert(Qt::ControlModifier, config.readEntry("Control", QStringList()));
|
||||
}
|
||||
if (config.hasKey("Alt")) {
|
||||
m_modifierOnlyShortcuts.insert(Qt::AltModifier, config.readEntry("Alt", QStringList()));
|
||||
}
|
||||
m_modifierOnlyShortcuts.insert(Qt::MetaModifier, config.readEntry("Meta", QStringList{QStringLiteral("org.kde.plasmashell"), QStringLiteral("/PlasmaShell"), QStringLiteral("org.kde.PlasmaShell"), QStringLiteral("activateLauncherMenu")}));
|
||||
|
||||
// Compositing
|
||||
config = KConfigGroup(m_settings->config(), QStringLiteral("Compositing"));
|
||||
bool useCompositing = false;
|
||||
|
@ -1050,11 +1036,6 @@ Options::WindowOperation Options::operationMaxButtonClick(Qt::MouseButtons butto
|
|||
: opMaxButtonLeftClick;
|
||||
}
|
||||
|
||||
QStringList Options::modifierOnlyDBusShortcut(Qt::KeyboardModifier mod) const
|
||||
{
|
||||
return m_modifierOnlyShortcuts.value(mod);
|
||||
}
|
||||
|
||||
bool Options::isUseCompositing() const
|
||||
{
|
||||
return m_useCompositing;
|
||||
|
|
|
@ -712,7 +712,6 @@ public:
|
|||
return m_windowsBlockCompositing;
|
||||
}
|
||||
|
||||
QStringList modifierOnlyDBusShortcut(Qt::KeyboardModifier mod) const;
|
||||
bool allowTearing() const;
|
||||
|
||||
// setters
|
||||
|
@ -1056,8 +1055,6 @@ private:
|
|||
|
||||
bool m_allowTearing = true;
|
||||
|
||||
QHash<Qt::KeyboardModifier, QStringList> m_modifierOnlyShortcuts;
|
||||
|
||||
MouseCommand wheelToMouseCommand(MouseWheelCommand com, int delta) const;
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue