diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 43f47f547f..a991ec95d7 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -11,4 +11,4 @@ suse_tumbleweed_qt66_reduced_featureset: extends: suse_tumbleweed_qt66 script: - git config --global --add safe.directory $CI_PROJECT_DIR - - python3 -u ci-utilities/run-ci-build.py --project $CI_PROJECT_NAME --branch $CI_COMMIT_REF_NAME --platform Linux --extra-cmake-args="-DKWIN_BUILD_KCMS=OFF -DKWIN_BUILD_SCREENLOCKER=OFF -DKWIN_BUILD_TABBOX=OFF -DKWIN_BUILD_ACTIVITIES=OFF -DKWIN_BUILD_RUNNERS=OFF -DKWIN_BUILD_NOTIFICATIONS=OFF" --skip-publishing + - python3 -u ci-utilities/run-ci-build.py --project $CI_PROJECT_NAME --branch $CI_COMMIT_REF_NAME --platform Linux --extra-cmake-args="-DKWIN_BUILD_KCMS=OFF -DKWIN_BUILD_SCREENLOCKER=OFF -DKWIN_BUILD_TABBOX=OFF -DKWIN_BUILD_ACTIVITIES=OFF -DKWIN_BUILD_RUNNERS=OFF -DKWIN_BUILD_NOTIFICATIONS=OFF -DKWIN_BUILD_GLOBALSHORTCUTS=OFF" --skip-publishing diff --git a/CMakeLists.txt b/CMakeLists.txt index de7b03a8b9..4b7ec2b23a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -355,7 +355,10 @@ set_package_properties(QAccessibilityClient6 PROPERTIES ) set(HAVE_ACCESSIBILITY ${QAccessibilityClient6_FOUND}) -find_package(KGlobalAccelD REQUIRED) +option(KWIN_BUILD_GLOBALSHORTCUTS "Enable building of KWin with global shortcuts support" ON) +if(KWIN_BUILD_GLOBALSHORTCUTS) + find_package(KGlobalAccelD REQUIRED) +endif() pkg_check_modules(libdisplayinfo IMPORTED_TARGET display-info) if (NOT libdisplayinfo_FOUND) pkg_check_modules(libdisplayinfo REQUIRED IMPORTED_TARGET libdisplay-info) diff --git a/autotests/integration/CMakeLists.txt b/autotests/integration/CMakeLists.txt index 2a94febe1d..8eb2135441 100644 --- a/autotests/integration/CMakeLists.txt +++ b/autotests/integration/CMakeLists.txt @@ -44,10 +44,13 @@ target_link_libraries(KWinIntegrationTestFramework # Static plugins KWinQpaPlugin - KF6GlobalAccelKWinPlugin KF6WindowSystemKWinPlugin KF6IdleTimeKWinPlugin ) +if(TARGET KF6GlobalAccelKWinPlugin) + target_link_libraries(KWinIntegrationTestFramework PUBLIC KF6GlobalAccelKWinPlugin) +endif() + if(TARGET PW::KScreenLocker) target_link_libraries(KWinIntegrationTestFramework PUBLIC PW::KScreenLocker) endif() @@ -97,7 +100,6 @@ integrationTest(NAME testKeyboardLayout SRCS keyboard_layout_test.cpp LIBS KF6:: integrationTest(NAME testKeymapCreationFailure SRCS keymap_creation_failure_test.cpp LIBS KF6::GlobalAccel) integrationTest(NAME testShowingDesktop SRCS showing_desktop_test.cpp) integrationTest(NAME testDontCrashUseractionsMenu SRCS dont_crash_useractions_menu.cpp LIBS KF6::I18n) -integrationTest(NAME testKWinBindings SRCS kwinbindings_test.cpp LIBS KF6::I18n) integrationTest(NAME testLayerShellV1Window SRCS layershellv1window_test.cpp) integrationTest(NAME testVirtualDesktop SRCS virtual_desktop_test.cpp) integrationTest(NAME testXdgShellWindowRules SRCS xdgshellwindow_rules_test.cpp) @@ -122,7 +124,6 @@ integrationTest(NAME testXwaylandInput SRCS xwayland_input_test.cpp LIBS XCB::IC integrationTest(NAME testWindowRules SRCS window_rules_test.cpp LIBS XCB::ICCCM) integrationTest(NAME testX11Window SRCS x11_window_test.cpp LIBS XCB::ICCCM) integrationTest(NAME testQuickTiling SRCS quick_tiling_test.cpp LIBS XCB::ICCCM KDecoration2::KDecoration) -integrationTest(NAME testGlobalShortcuts SRCS globalshortcuts_test.cpp LIBS XCB::ICCCM KF6::GlobalAccel KF6::I18n XKB::XKB) integrationTest(NAME testStackingOrder SRCS stacking_order_test.cpp LIBS XCB::ICCCM) integrationTest(NAME testDbusInterface SRCS dbus_interface_test.cpp LIBS XCB::ICCCM) integrationTest(NAME testXwaylandServerCrash SRCS xwaylandserver_crash_test.cpp LIBS XCB::ICCCM) @@ -134,6 +135,10 @@ integrationTest(NAME testStickyKeys SRCS sticky_keys_test.cpp) qt_add_dbus_interfaces(DBUS_SRCS ${CMAKE_BINARY_DIR}/src/org.kde.kwin.VirtualKeyboard.xml) integrationTest(NAME testVirtualKeyboardDBus SRCS test_virtualkeyboard_dbus.cpp ${DBUS_SRCS}) +if (KWIN_BUILD_GLOBALSHORTCUTS) +integrationTest(NAME testGlobalShortcuts SRCS globalshortcuts_test.cpp LIBS XCB::ICCCM KF6::GlobalAccel KF6::I18n XKB::XKB) +integrationTest(NAME testKWinBindings SRCS kwinbindings_test.cpp LIBS KF6::I18n) +endif() if (TARGET K::KPipeWire) integrationTest(NAME testScreencasting SRCS screencasting_test.cpp LIBS K::KPipeWire) endif() diff --git a/autotests/integration/effects/scripted_effects_test.cpp b/autotests/integration/effects/scripted_effects_test.cpp index cf0ba6ee3a..2cb206b5bf 100644 --- a/autotests/integration/effects/scripted_effects_test.cpp +++ b/autotests/integration/effects/scripted_effects_test.cpp @@ -222,6 +222,11 @@ void ScriptedEffectsTest::testEffectsContext() void ScriptedEffectsTest::testShortcuts() { +#if !KWIN_BUILD_GLOBALSHORTCUTS + QSKIP("Can't test shortcuts without shortcuts"); + return; +#endif + // this tests method registerShortcut auto *effect = new ScriptedEffectWithDebugSpy; // cleaned up in ::clean QSignalSpy effectOutputSpy(effect, &ScriptedEffectWithDebugSpy::testOutput); diff --git a/autotests/integration/keyboard_layout_test.cpp b/autotests/integration/keyboard_layout_test.cpp index 6b832b0010..83e85b61a4 100644 --- a/autotests/integration/keyboard_layout_test.cpp +++ b/autotests/integration/keyboard_layout_test.cpp @@ -256,6 +256,11 @@ void KeyboardLayoutTest::testChangeLayoutThroughDBus() void KeyboardLayoutTest::testPerLayoutShortcut() { +#if !KWIN_BUILD_GLOBALSHORTCUTS + QSKIP("Can't test shortcuts without shortcuts"); + return; +#endif + // this test verifies that per-layout global shortcuts are working correctly. // first configure layouts layoutGroup.writeEntry("LayoutList", QStringLiteral("us,de,de(neo)")); diff --git a/autotests/integration/kwin_wayland_test.cpp b/autotests/integration/kwin_wayland_test.cpp index 482b30996b..d5ac6a6963 100644 --- a/autotests/integration/kwin_wayland_test.cpp +++ b/autotests/integration/kwin_wayland_test.cpp @@ -35,7 +35,9 @@ #include Q_IMPORT_PLUGIN(KWinIntegrationPlugin) +#if KWIN_BUILD_GLOBALSHORTCUTS Q_IMPORT_PLUGIN(KGlobalAccelImpl) +#endif Q_IMPORT_PLUGIN(KWindowSystemKWinPlugin) Q_IMPORT_PLUGIN(KWinIdleTimePoller) diff --git a/autotests/integration/lockscreen.cpp b/autotests/integration/lockscreen.cpp index 129052df7d..cde709dbcc 100644 --- a/autotests/integration/lockscreen.cpp +++ b/autotests/integration/lockscreen.cpp @@ -592,6 +592,11 @@ void LockScreenTest::testMoveWindow() void LockScreenTest::testPointerShortcut() { +#if !KWIN_BUILD_GLOBALSHORTCUTS + QSKIP("Can't test shortcuts without shortcuts"); + return; +#endif + std::unique_ptr action(new QAction(nullptr)); QSignalSpy actionSpy(action.get(), &QAction::triggered); input()->registerPointerShortcut(Qt::MetaModifier, Qt::LeftButton, action.get()); @@ -624,6 +629,11 @@ void LockScreenTest::testPointerShortcut() void LockScreenTest::testAxisShortcut_data() { +#if !KWIN_BUILD_GLOBALSHORTCUTS + QSKIP("Can't test shortcuts without shortcuts"); + return; +#endif + QTest::addColumn("direction"); QTest::addColumn("sign"); @@ -677,6 +687,11 @@ void LockScreenTest::testAxisShortcut() void LockScreenTest::testKeyboardShortcut() { +#if !KWIN_BUILD_GLOBALSHORTCUTS + QSKIP("Can't test shortcuts without shortcuts"); + return; +#endif + std::unique_ptr action(new QAction(nullptr)); QSignalSpy actionSpy(action.get(), &QAction::triggered); action->setProperty("componentName", QStringLiteral("kwin")); diff --git a/autotests/integration/quick_tiling_test.cpp b/autotests/integration/quick_tiling_test.cpp index aa2579ab0d..4e325ab5da 100644 --- a/autotests/integration/quick_tiling_test.cpp +++ b/autotests/integration/quick_tiling_test.cpp @@ -688,6 +688,11 @@ void QuickTilingTest::testShortcut_data() void QuickTilingTest::testShortcut() { +#if !KWIN_BUILD_GLOBALSHORTCUTS + QSKIP("Can't test shortcuts without shortcuts"); + return; +#endif + std::unique_ptr surface(Test::createSurface()); QVERIFY(surface != nullptr); std::unique_ptr shellSurface(Test::createXdgToplevelSurface(surface.get())); diff --git a/autotests/integration/scripting/minimizeall_test.cpp b/autotests/integration/scripting/minimizeall_test.cpp index f814c97bcc..cb6537b290 100644 --- a/autotests/integration/scripting/minimizeall_test.cpp +++ b/autotests/integration/scripting/minimizeall_test.cpp @@ -98,6 +98,11 @@ void MinimizeAllScriptTest::cleanup() void MinimizeAllScriptTest::testMinimizeUnminimize() { +#if !KWIN_BUILD_GLOBALSHORTCUTS + QSKIP("Can't test shortcuts without shortcuts"); + return; +#endif + // This test verifies that all windows are minimized when Meta+Shift+D // is pressed, and unminimized when the shortcut is pressed once again. diff --git a/autotests/integration/tabbox_test.cpp b/autotests/integration/tabbox_test.cpp index 7c92b048b5..fcf2b62499 100644 --- a/autotests/integration/tabbox_test.cpp +++ b/autotests/integration/tabbox_test.cpp @@ -71,6 +71,11 @@ void TabBoxTest::cleanup() void TabBoxTest::testCapsLock() { +#if !KWIN_BUILD_GLOBALSHORTCUTS + QSKIP("Can't test shortcuts without shortcuts"); + return; +#endif + // this test verifies that Alt+tab works correctly also when Capslock is on // bug 368590 @@ -133,6 +138,11 @@ void TabBoxTest::testCapsLock() void TabBoxTest::testMoveForward() { +#if !KWIN_BUILD_GLOBALSHORTCUTS + QSKIP("Can't test shortcuts without shortcuts"); + return; +#endif + // this test verifies that Alt+tab works correctly moving forward // first create three windows @@ -182,6 +192,11 @@ void TabBoxTest::testMoveForward() void TabBoxTest::testMoveBackward() { +#if !KWIN_BUILD_GLOBALSHORTCUTS + QSKIP("Can't test shortcuts without shortcuts"); + return; +#endif + // this test verifies that Alt+Shift+tab works correctly moving backward // first create three windows diff --git a/autotests/integration/touch_input_test.cpp b/autotests/integration/touch_input_test.cpp index 85dc4ee9ef..ee92c48014 100644 --- a/autotests/integration/touch_input_test.cpp +++ b/autotests/integration/touch_input_test.cpp @@ -359,6 +359,11 @@ void TouchInputTest::testUpdateFocusOnDecorationDestroy() void TouchInputTest::testGestureDetection() { +#if !KWIN_BUILD_GLOBALSHORTCUTS + QSKIP("Can't test shortcuts without shortcuts"); + return; +#endif + bool callbackTriggered = false; const auto callback = [&callbackTriggered](float progress) { callbackTriggered = true; diff --git a/autotests/integration/xdgshellwindow_rules_test.cpp b/autotests/integration/xdgshellwindow_rules_test.cpp index 25181a8bd8..cf606b50d2 100644 --- a/autotests/integration/xdgshellwindow_rules_test.cpp +++ b/autotests/integration/xdgshellwindow_rules_test.cpp @@ -2255,6 +2255,11 @@ void TestXdgShellWindowRules::testKeepBelowForceTemporarily() void TestXdgShellWindowRules::testShortcutDontAffect() { +#if !KWIN_BUILD_GLOBALSHORTCUTS + QSKIP("Can't test shortcuts without shortcuts"); + return; +#endif + setWindowRule("shortcut", "Ctrl+Alt+1", int(Rules::DontAffect)); createTestWindow(); @@ -2279,6 +2284,10 @@ void TestXdgShellWindowRules::testShortcutDontAffect() void TestXdgShellWindowRules::testShortcutApply() { +#if !KWIN_BUILD_GLOBALSHORTCUTS + QSKIP("Can't test shortcuts without shortcuts"); + return; +#endif setWindowRule("shortcut", "Ctrl+Alt+1", int(Rules::Apply)); createTestWindow(); @@ -2430,6 +2439,11 @@ void TestXdgShellWindowRules::testShortcutForce() void TestXdgShellWindowRules::testShortcutApplyNow() { +#if !KWIN_BUILD_GLOBALSHORTCUTS + QSKIP("Can't test shortcuts without shortcuts"); + return; +#endif + createTestWindow(); QVERIFY(m_window->shortcut().isEmpty()); diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 322519595d..1983176022 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -100,7 +100,6 @@ target_sources(kwin PRIVATE focuschain.cpp ftrace.cpp gestures.cpp - globalshortcuts.cpp group.cpp hide_cursor_spy.cpp idle_inhibition.cpp @@ -254,8 +253,6 @@ target_link_libraries(kwin KDecoration2::KDecoration KDecoration2::KDecoration2Private - K::KGlobalAccelD - XCB::COMPOSITE XCB::CURSOR XCB::DAMAGE @@ -281,6 +278,11 @@ target_link_libraries(kwin PkgConfig::libdisplayinfo ) +if (TARGET K::KGlobalAccelD) + target_sources(kwin PRIVATE globalshortcuts.cpp) + target_link_libraries(kwin PRIVATE K::KGlobalAccelD) +endif() + if (KWIN_BUILD_NOTIFICATIONS) target_link_libraries(kwin PRIVATE KF6::Notifications) endif() @@ -391,11 +393,14 @@ endif() target_link_libraries(kwin_wayland KWinQpaPlugin - KF6GlobalAccelKWinPlugin KF6WindowSystemKWinPlugin KF6IdleTimeKWinPlugin ) +if (TARGET KF6GlobalAccelKWinPlugin) + target_link_libraries(kwin_wayland KF6GlobalAccelKWinPlugin) +endif() + add_custom_target( KWinDBusInterfaces ALL diff --git a/src/config-kwin.h.cmake b/src/config-kwin.h.cmake index ffbf1b32e9..c68a3eae17 100644 --- a/src/config-kwin.h.cmake +++ b/src/config-kwin.h.cmake @@ -9,6 +9,7 @@ #cmakedefine01 KWIN_BUILD_SCREENLOCKER #cmakedefine01 KWIN_BUILD_TABBOX #cmakedefine01 KWIN_BUILD_ACTIVITIES +#cmakedefine01 KWIN_BUILD_GLOBALSHORTCUTS constexpr QLatin1String KWIN_CONFIG("kwinrc"); constexpr QLatin1String KWIN_VERSION_STRING("${PROJECT_VERSION}"); constexpr QLatin1String XCB_VERSION_STRING("${XCB_VERSION}"); diff --git a/src/input.cpp b/src/input.cpp index 9516a6ecb5..d5679e8a9e 100644 --- a/src/input.cpp +++ b/src/input.cpp @@ -881,6 +881,7 @@ private: QMap m_touchPoints; }; +#if KWIN_BUILD_GLOBALSHORTCUTS class GlobalShortcutFilter : public InputEventFilter { public: @@ -1127,6 +1128,7 @@ private: QTimer m_powerDown; }; +#endif namespace { @@ -2658,7 +2660,9 @@ InputRedirection::InputRedirection(QObject *parent) , m_pointer(new PointerInputRedirection(this)) , m_tablet(new TabletInputRedirection(this)) , m_touch(new TouchInputRedirection(this)) +#if KWIN_BUILD_GLOBALSHORTCUTS , m_shortcuts(new GlobalShortcutsManager(this)) +#endif { qRegisterMetaType(); qRegisterMetaType(); @@ -2707,8 +2711,9 @@ void InputRedirection::init() m_inputConfigWatcher = KConfigWatcher::create(kwinApp()->inputConfig()); connect(m_inputConfigWatcher.data(), &KConfigWatcher::configChanged, this, &InputRedirection::handleInputConfigChanged); - +#if KWIN_BUILD_GLOBALSHORTCUTS m_shortcuts->init(); +#endif } void InputRedirection::setupWorkspace() @@ -2948,10 +2953,12 @@ void InputRedirection::setupInputFilters() m_tabboxFilter = std::make_unique(); installInputEventFilter(m_tabboxFilter.get()); #endif +#if KWIN_BUILD_GLOBALSHORTCUTS if (hasGlobalShortcutSupport) { m_globalShortcutFilter = std::make_unique(); installInputEventFilter(m_globalShortcutFilter.get()); } +#endif m_effectsFilter = std::make_unique(); installInputEventFilter(m_effectsFilter.get()); @@ -3333,37 +3340,51 @@ Qt::KeyboardModifiers InputRedirection::modifiersRelevantForGlobalShortcuts() co void InputRedirection::registerPointerShortcut(Qt::KeyboardModifiers modifiers, Qt::MouseButton pointerButtons, QAction *action) { +#if KWIN_BUILD_GLOBALSHORTCUTS m_shortcuts->registerPointerShortcut(action, modifiers, pointerButtons); +#endif } void InputRedirection::registerAxisShortcut(Qt::KeyboardModifiers modifiers, PointerAxisDirection axis, QAction *action) { +#if KWIN_BUILD_GLOBALSHORTCUTS m_shortcuts->registerAxisShortcut(action, modifiers, axis); +#endif } void InputRedirection::registerTouchpadSwipeShortcut(SwipeDirection direction, uint fingerCount, QAction *action, std::function cb) { +#if KWIN_BUILD_GLOBALSHORTCUTS m_shortcuts->registerTouchpadSwipe(direction, fingerCount, action, cb); +#endif } void InputRedirection::registerTouchpadPinchShortcut(PinchDirection direction, uint fingerCount, QAction *onUp, std::function progressCallback) { +#if KWIN_BUILD_GLOBALSHORTCUTS m_shortcuts->registerTouchpadPinch(direction, fingerCount, onUp, progressCallback); +#endif } void InputRedirection::registerGlobalAccel(KGlobalAccelInterface *interface) { +#if KWIN_BUILD_GLOBALSHORTCUTS m_shortcuts->setKGlobalAccelInterface(interface); +#endif } void InputRedirection::registerTouchscreenSwipeShortcut(SwipeDirection direction, uint fingerCount, QAction *action, std::function progressCallback) { +#if KWIN_BUILD_GLOBALSHORTCUTS m_shortcuts->registerTouchscreenSwipe(direction, fingerCount, action, progressCallback); +#endif } void InputRedirection::forceRegisterTouchscreenSwipeShortcut(SwipeDirection direction, uint fingerCount, QAction *action, std::function progressCallback) { +#if KWIN_BUILD_GLOBALSHORTCUTS m_shortcuts->forceRegisterTouchscreenSwipe(direction, fingerCount, action, progressCallback); +#endif } void InputRedirection::warpPointer(const QPointF &pos) diff --git a/src/input.h b/src/input.h index b4fa56014f..0f66579eca 100644 --- a/src/input.h +++ b/src/input.h @@ -20,6 +20,7 @@ #include #include +#include "config-kwin.h" #include class KGlobalAccelInterface; @@ -166,10 +167,12 @@ public: void removeIdleInhibitor(Window *inhibitor); Window *findToplevel(const QPointF &pos); +#if KWIN_BUILD_GLOBALSHORTCUTS GlobalShortcutsManager *shortcuts() const { return m_shortcuts; } +#endif /** * Sends an event through all InputFilters. @@ -318,7 +321,9 @@ private: TouchInputRedirection *m_touch; QObject *m_lastInputDevice = nullptr; +#if KWIN_BUILD_GLOBALSHORTCUTS GlobalShortcutsManager *m_shortcuts; +#endif std::vector> m_inputBackends; QList m_inputDevices; diff --git a/src/main_wayland.cpp b/src/main_wayland.cpp index 5fb8219e94..f58271d193 100644 --- a/src/main_wayland.cpp +++ b/src/main_wayland.cpp @@ -52,7 +52,9 @@ #include Q_IMPORT_PLUGIN(KWinIntegrationPlugin) +#if KWIN_BUILD_GLOBALSHORTCUTS Q_IMPORT_PLUGIN(KGlobalAccelImpl) +#endif Q_IMPORT_PLUGIN(KWindowSystemKWinPlugin) Q_IMPORT_PLUGIN(KWinIdleTimePoller) diff --git a/src/plugins/CMakeLists.txt b/src/plugins/CMakeLists.txt index c750b8d796..7fe83d6e19 100644 --- a/src/plugins/CMakeLists.txt +++ b/src/plugins/CMakeLists.txt @@ -69,7 +69,6 @@ add_subdirectory(glide) add_subdirectory(highlightwindow) add_subdirectory(idletime) add_subdirectory(invert) -add_subdirectory(kglobalaccel) add_subdirectory(kpackage) add_subdirectory(kscreen) add_subdirectory(login) @@ -122,3 +121,6 @@ endif() if (KWIN_BUILD_RUNNERS) add_subdirectory(krunner-integration) endif() +if(TARGET K::KGlobalAccelD) + add_subdirectory(kglobalaccel) +endif() diff --git a/src/plugins/kglobalaccel/CMakeLists.txt b/src/plugins/kglobalaccel/CMakeLists.txt index 4594d68180..6b1e53af8a 100644 --- a/src/plugins/kglobalaccel/CMakeLists.txt +++ b/src/plugins/kglobalaccel/CMakeLists.txt @@ -1,7 +1,3 @@ -set(kglobalaccel_plugin_SRCS - kglobalaccel_plugin.cpp -) - -add_library(KF6GlobalAccelKWinPlugin OBJECT ${kglobalaccel_plugin_SRCS}) +add_library(KF6GlobalAccelKWinPlugin OBJECT kglobalaccel_plugin.cpp) target_compile_definitions(KF6GlobalAccelKWinPlugin PRIVATE QT_STATICPLUGIN) target_link_libraries(KF6GlobalAccelKWinPlugin K::KGlobalAccelD kwin)