Allow building KWin without KGlobalAccel

Signed-off-by: Falko Becker <falko.becker@mbition.io>
This commit is contained in:
Aleix Pol Gonzalez 2023-11-20 23:28:23 +01:00
parent 25a976e559
commit b853de3d29
19 changed files with 127 additions and 16 deletions

View file

@ -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

View file

@ -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)

View file

@ -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()

View file

@ -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);

View file

@ -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)"));

View file

@ -35,7 +35,9 @@
#include <unistd.h>
Q_IMPORT_PLUGIN(KWinIntegrationPlugin)
#if KWIN_BUILD_GLOBALSHORTCUTS
Q_IMPORT_PLUGIN(KGlobalAccelImpl)
#endif
Q_IMPORT_PLUGIN(KWindowSystemKWinPlugin)
Q_IMPORT_PLUGIN(KWinIdleTimePoller)

View file

@ -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<QAction> 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<Qt::Orientation>("direction");
QTest::addColumn<int>("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<QAction> action(new QAction(nullptr));
QSignalSpy actionSpy(action.get(), &QAction::triggered);
action->setProperty("componentName", QStringLiteral("kwin"));

View file

@ -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<KWayland::Client::Surface> surface(Test::createSurface());
QVERIFY(surface != nullptr);
std::unique_ptr<Test::XdgToplevel> shellSurface(Test::createXdgToplevelSurface(surface.get()));

View file

@ -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.

View file

@ -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

View file

@ -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;

View file

@ -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());

View file

@ -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

View file

@ -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}");

View file

@ -881,6 +881,7 @@ private:
QMap<quint32, QPointF> 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<InputRedirection::KeyboardKeyState>();
qRegisterMetaType<InputRedirection::PointerButtonState>();
@ -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<TabBoxInputFilter>();
installInputEventFilter(m_tabboxFilter.get());
#endif
#if KWIN_BUILD_GLOBALSHORTCUTS
if (hasGlobalShortcutSupport) {
m_globalShortcutFilter = std::make_unique<GlobalShortcutFilter>();
installInputEventFilter(m_globalShortcutFilter.get());
}
#endif
m_effectsFilter = std::make_unique<EffectsFilter>();
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<void(qreal)> cb)
{
#if KWIN_BUILD_GLOBALSHORTCUTS
m_shortcuts->registerTouchpadSwipe(direction, fingerCount, action, cb);
#endif
}
void InputRedirection::registerTouchpadPinchShortcut(PinchDirection direction, uint fingerCount, QAction *onUp, std::function<void(qreal)> 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<void(qreal)> progressCallback)
{
#if KWIN_BUILD_GLOBALSHORTCUTS
m_shortcuts->registerTouchscreenSwipe(direction, fingerCount, action, progressCallback);
#endif
}
void InputRedirection::forceRegisterTouchscreenSwipeShortcut(SwipeDirection direction, uint fingerCount, QAction *action, std::function<void(qreal)> progressCallback)
{
#if KWIN_BUILD_GLOBALSHORTCUTS
m_shortcuts->forceRegisterTouchscreenSwipe(direction, fingerCount, action, progressCallback);
#endif
}
void InputRedirection::warpPointer(const QPointF &pos)

View file

@ -20,6 +20,7 @@
#include <KSharedConfig>
#include <QSet>
#include "config-kwin.h"
#include <functional>
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<std::unique_ptr<InputBackend>> m_inputBackends;
QList<InputDevice *> m_inputDevices;

View file

@ -52,7 +52,9 @@
#include <iostream>
Q_IMPORT_PLUGIN(KWinIntegrationPlugin)
#if KWIN_BUILD_GLOBALSHORTCUTS
Q_IMPORT_PLUGIN(KGlobalAccelImpl)
#endif
Q_IMPORT_PLUGIN(KWindowSystemKWinPlugin)
Q_IMPORT_PLUGIN(KWinIdleTimePoller)

View file

@ -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()

View file

@ -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)