diff --git a/autotests/test_screen_edges.cpp b/autotests/test_screen_edges.cpp --- a/autotests/test_screen_edges.cpp +++ b/autotests/test_screen_edges.cpp @@ -87,11 +87,6 @@ Q_UNUSED(action) } -void InputRedirection::registerShortcutForGlobalAccelTimestamp(QAction *action) -{ - Q_UNUSED(action) -} - void updateXTime() { } diff --git a/autotests/test_virtual_desktops.cpp b/autotests/test_virtual_desktops.cpp --- a/autotests/test_virtual_desktops.cpp +++ b/autotests/test_virtual_desktops.cpp @@ -44,11 +44,6 @@ Q_UNUSED(action) } -void InputRedirection::registerShortcutForGlobalAccelTimestamp(QAction *action) -{ - Q_UNUSED(action) -} - } Q_DECLARE_METATYPE(Qt::Orientation) diff --git a/input.h b/input.h --- a/input.h +++ b/input.h @@ -267,7 +267,6 @@ private: void setupLibInput(); void setupLibInputWithScreens(); - void registerShortcutForGlobalAccelTimestamp(QAction *action); void setupWorkspace(); void reconfigure(); void setupInputFilters(); diff --git a/input.cpp b/input.cpp --- a/input.cpp +++ b/input.cpp @@ -1807,7 +1807,7 @@ void InputRedirection::registerShortcut(const QKeySequence &shortcut, QAction *action) { m_shortcuts->registerShortcut(action, shortcut); - registerShortcutForGlobalAccelTimestamp(action); + kwinApp()->platform()->setupActionForGlobalAccel(action); } void InputRedirection::registerPointerShortcut(Qt::KeyboardModifiers modifiers, Qt::MouseButton pointerButtons, QAction *action) @@ -1825,18 +1825,6 @@ m_shortcuts->setKGlobalAccelInterface(interface); } -void InputRedirection::registerShortcutForGlobalAccelTimestamp(QAction *action) -{ - connect(action, &QAction::triggered, kwinApp(), [action] { - QVariant timestamp = action->property("org.kde.kglobalaccel.activationTimestamp"); - bool ok = false; - const quint32 t = timestamp.toULongLong(&ok); - if (ok) { - kwinApp()->setX11Time(t); - } - }); -} - void InputRedirection::warpPointer(const QPointF &pos) { m_pointer->warp(pos); diff --git a/platform.h b/platform.h --- a/platform.h +++ b/platform.h @@ -28,6 +28,8 @@ #include +class QAction; + namespace KWayland { namespace Server { class OutputConfigurationInterface; @@ -195,6 +197,22 @@ **/ virtual void startInteractivePositionSelection(std::function callback); + /** + * Platform specific preparation for an @p action which is used for KGlobalAccel. + * + * A platform might need to do preparation for an @p action before + * it can be used with KGlobalAccel. + * + * Code using KGlobalAccel should invoke this method for the @p action + * prior to setting up any shortcuts and connections. + * + * The default implementation does nothing. + * + * @param action The action which will be used with KGlobalAccel. + * @since 5.10 + **/ + virtual void setupActionForGlobalAccel(QAction *action); + bool usesSoftwareCursor() const { return m_softWareCursor; } diff --git a/platform.cpp b/platform.cpp --- a/platform.cpp +++ b/platform.cpp @@ -386,4 +386,9 @@ input()->startInteractivePositionSelection(callback); } +void Platform::setupActionForGlobalAccel(QAction *action) +{ + Q_UNUSED(action) +} + } diff --git a/plugins/platforms/x11/standalone/x11_platform.h b/plugins/platforms/x11/standalone/x11_platform.h --- a/plugins/platforms/x11/standalone/x11_platform.h +++ b/plugins/platforms/x11/standalone/x11_platform.h @@ -53,6 +53,8 @@ PlatformCursorImage cursorImage() const override; + void setupActionForGlobalAccel(QAction *action) override; + protected: void doHideCursor() override; void doShowCursor() override; diff --git a/plugins/platforms/x11/standalone/x11_platform.cpp b/plugins/platforms/x11/standalone/x11_platform.cpp --- a/plugins/platforms/x11/standalone/x11_platform.cpp +++ b/plugins/platforms/x11/standalone/x11_platform.cpp @@ -282,4 +282,16 @@ m_windowSelector->start(callback, cursorName); } +void X11StandalonePlatform::setupActionForGlobalAccel(QAction *action) +{ + connect(action, &QAction::triggered, kwinApp(), [action] { + QVariant timestamp = action->property("org.kde.kglobalaccel.activationTimestamp"); + bool ok = false; + const quint32 t = timestamp.toULongLong(&ok); + if (ok) { + kwinApp()->setX11Time(t); + } + }); +} + }