Members of the KDE Community are recommended to subscribe to the kde-community mailing list at https://mail.kde.org/mailman/listinfo/kde-community to allow them to participate in important discussions and receive other important announcements

Commit a0b482cb authored by Martin Flöser's avatar Martin Flöser

Introduce a command line option to disable any kind of global shortcuts

Summary:
This command line option is useful for KWin in embedded use case. That
is when KWin is just used as a compositor for one application instead of
a complete desktop environment. In such a setup global shortcuts are not
wanted and interfere with the application. E.g. one does not want Alt+F4
to close the window, that would render the system unusable.

This change introduces a command line option and disables the following
event filters and spies:
 * global shortcuts
 * modifier only shortcuts
 * terminate session
 * virtual terminal switching
 * screen edges

KGlobalAccel still gets inited, otherwise the (non-functional) binary
would be launched when KWin registers it's global shortcuts.

Test Plan:
New test added based on existing tests for the global
shortcuts, ctest passes

Reviewers: #kwin

Subscribers: kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D17304
parent 070b46f4
......@@ -58,6 +58,7 @@ integrationTest(WAYLAND_ONLY NAME testIdleInhibition SRCS idle_inhibition_test.c
integrationTest(WAYLAND_ONLY NAME testColorCorrectNightColor SRCS colorcorrect_nightcolor_test.cpp)
integrationTest(WAYLAND_ONLY NAME testDontCrashCursorPhysicalSizeEmpty SRCS dont_crash_cursor_physical_size_empty.cpp)
integrationTest(WAYLAND_ONLY NAME testDontCrashReinitializeCompositor SRCS dont_crash_reinitialize_compositor.cpp)
integrationTest(WAYLAND_ONLY NAME testNoGlobalShortcuts SRCS no_global_shortcuts_test.cpp)
if (XCB_ICCCM_FOUND)
integrationTest(NAME testMoveResize SRCS move_resize_window_test.cpp LIBS XCB::ICCCM)
......
This diff is collapsed.
......@@ -52,6 +52,7 @@ void StartTest::initTestCase()
QVERIFY(workspaceCreatedSpy.isValid());
kwinApp()->platform()->setInitialWindowSize(QSize(1280, 1024));
QVERIFY(waylandServer()->init(s_socketName.toLocal8Bit()));
QVERIFY(waylandServer()->hasGlobalShortcutSupport());
kwinApp()->start();
QVERIFY(workspaceCreatedSpy.wait());
}
......
......@@ -1751,25 +1751,32 @@ void InputRedirection::setupWorkspace()
void InputRedirection::setupInputFilters()
{
if (LogindIntegration::self()->hasSessionControl()) {
const bool hasGlobalShortcutSupport = !waylandServer() || waylandServer()->hasGlobalShortcutSupport();
if (LogindIntegration::self()->hasSessionControl() && hasGlobalShortcutSupport) {
installInputEventFilter(new VirtualTerminalFilter);
}
if (waylandServer()) {
installInputEventSpy(new TouchHideCursorSpy);
installInputEventFilter(new TerminateServerFilter);
if (hasGlobalShortcutSupport) {
installInputEventFilter(new TerminateServerFilter);
}
installInputEventFilter(new DragAndDropInputFilter);
installInputEventFilter(new LockScreenFilter);
installInputEventFilter(new PopupInputFilter);
m_windowSelector = new WindowSelectorFilter;
installInputEventFilter(m_windowSelector);
}
installInputEventFilter(new ScreenEdgeInputFilter);
if (hasGlobalShortcutSupport) {
installInputEventFilter(new ScreenEdgeInputFilter);
}
installInputEventFilter(new EffectsFilter);
installInputEventFilter(new MoveResizeFilter);
#ifdef KWIN_BUILD_TABBOX
installInputEventFilter(new TabBoxInputFilter);
#endif
installInputEventFilter(new GlobalShortcutFilter);
if (hasGlobalShortcutSupport) {
installInputEventFilter(new GlobalShortcutFilter);
}
installInputEventFilter(new DecorationEventFilter);
installInputEventFilter(new InternalWindowEventFilter);
if (waylandServer()) {
......
......@@ -122,7 +122,9 @@ void KeyboardInputRedirection::init()
m_keyboardLayout->init();
m_input->installInputEventSpy(m_keyboardLayout);
m_input->installInputEventSpy(new ModifierOnlyShortcuts);
if (waylandServer()->hasGlobalShortcutSupport()) {
m_input->installInputEventSpy(new ModifierOnlyShortcuts);
}
KeyboardRepeat *keyRepeatSpy = new KeyboardRepeat(m_xkb.data());
connect(keyRepeatSpy, &KeyboardRepeat::keyRepeat, this,
......
......@@ -676,6 +676,10 @@ int main(int argc, char * argv[])
i18n("Starts the session without lock screen support."));
parser.addOption(noScreenLockerOption);
QCommandLineOption noGlobalShortcutsOption(QStringLiteral("no-global-shortcuts"),
i18n("Starts the session without global shortcuts support."));
parser.addOption(noScreenLockerOption);
QCommandLineOption exitWithSessionOption(QStringLiteral("exit-with-session"),
i18n("Exit after the session application, which is started by KWin, closed."),
QStringLiteral("/path/to/session"));
......@@ -792,6 +796,9 @@ int main(int argc, char * argv[])
} else if (parser.isSet(noScreenLockerOption)) {
flags = KWin::WaylandServer::InitalizationFlag::NoLockScreenIntegration;
}
if (parser.isSet(noGlobalShortcutsOption)) {
flags |= KWin::WaylandServer::InitalizationFlag::NoGlobalShortcuts;
}
if (!server->init(parser.value(waylandSocketOption).toUtf8(), flags)) {
std::cerr << "FATAL ERROR: could not create Wayland server" << std::endl;
return 1;
......
......@@ -795,6 +795,11 @@ bool WaylandServer::hasScreenLockerIntegration() const
return !m_initFlags.testFlag(InitalizationFlag::NoLockScreenIntegration);
}
bool WaylandServer::hasGlobalShortcutSupport() const
{
return !m_initFlags.testFlag(InitalizationFlag::NoGlobalShortcuts);
}
void WaylandServer::simulateUserActivity()
{
if (m_idle) {
......
......@@ -79,7 +79,8 @@ public:
enum class InitalizationFlag {
NoOptions = 0x0,
LockScreen = 0x1,
NoLockScreenIntegration = 0x2
NoLockScreenIntegration = 0x2,
NoGlobalShortcuts = 0x4
};
Q_DECLARE_FLAGS(InitalizationFlags, InitalizationFlag)
......@@ -153,6 +154,11 @@ public:
**/
bool hasScreenLockerIntegration() const;
/**
* @returns whether any kind of global shortcuts are supported.
**/
bool hasGlobalShortcutSupport() const;
void createInternalConnection();
void initWorkspace();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment