From 2904d4a0be4509235d1b9d91b342dbb611f0e8a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Gr=C3=A4=C3=9Flin?= Date: Tue, 17 Jan 2017 07:12:44 +0100 Subject: [PATCH] Move X11 specific KGlobalAccel handling into the x11-standalone platform Summary: InputRedirection has a workaround to add a connect on a QAction which is used for a global shortcut. This is specific to the X11 platform as the xtime needs to be updated. This change adds a new virtual method to the Platform and moves the implementation into the X11 standalone platform. Thus it does no longer gets called on Wayland. Reviewers: #kwin, #plasma Subscribers: plasma-devel Tags: #kwin Differential Revision: https://phabricator.kde.org/D4168 --- autotests/test_screen_edges.cpp | 5 ----- autotests/test_virtual_desktops.cpp | 5 ----- input.cpp | 14 +------------- input.h | 1 - platform.cpp | 5 +++++ platform.h | 18 ++++++++++++++++++ .../platforms/x11/standalone/x11_platform.cpp | 12 ++++++++++++ .../platforms/x11/standalone/x11_platform.h | 2 ++ 8 files changed, 38 insertions(+), 24 deletions(-) diff --git a/autotests/test_screen_edges.cpp b/autotests/test_screen_edges.cpp index 0595f53c9a..8fe9bd0940 100644 --- a/autotests/test_screen_edges.cpp +++ b/autotests/test_screen_edges.cpp @@ -87,11 +87,6 @@ void InputRedirection::registerAxisShortcut(Qt::KeyboardModifiers modifiers, Poi 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 index 2626f6432d..03fcb5a752 100644 --- a/autotests/test_virtual_desktops.cpp +++ b/autotests/test_virtual_desktops.cpp @@ -44,11 +44,6 @@ void InputRedirection::registerAxisShortcut(Qt::KeyboardModifiers modifiers, Poi Q_UNUSED(action) } -void InputRedirection::registerShortcutForGlobalAccelTimestamp(QAction *action) -{ - Q_UNUSED(action) -} - } Q_DECLARE_METATYPE(Qt::Orientation) diff --git a/input.cpp b/input.cpp index ad432624e8..199e893cc5 100644 --- a/input.cpp +++ b/input.cpp @@ -1807,7 +1807,7 @@ Qt::KeyboardModifiers InputRedirection::modifiersRelevantForGlobalShortcuts() co 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 @@ void InputRedirection::registerGlobalAccel(KGlobalAccelInterface *interface) 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/input.h b/input.h index fa554d9b2e..88eacb4f43 100644 --- a/input.h +++ b/input.h @@ -267,7 +267,6 @@ Q_SIGNALS: private: void setupLibInput(); void setupLibInputWithScreens(); - void registerShortcutForGlobalAccelTimestamp(QAction *action); void setupWorkspace(); void reconfigure(); void setupInputFilters(); diff --git a/platform.cpp b/platform.cpp index 57f24c80f1..0a29a7f289 100644 --- a/platform.cpp +++ b/platform.cpp @@ -386,4 +386,9 @@ void Platform::startInteractivePositionSelection(std::functionstartInteractivePositionSelection(callback); } +void Platform::setupActionForGlobalAccel(QAction *action) +{ + Q_UNUSED(action) +} + } diff --git a/platform.h b/platform.h index 87ba3658d7..f4eb5fca26 100644 --- a/platform.h +++ b/platform.h @@ -28,6 +28,8 @@ along with this program. If not, see . #include +class QAction; + namespace KWayland { namespace Server { class OutputConfigurationInterface; @@ -195,6 +197,22 @@ public: **/ 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/plugins/platforms/x11/standalone/x11_platform.cpp b/plugins/platforms/x11/standalone/x11_platform.cpp index 36f1a18669..41e8165915 100644 --- a/plugins/platforms/x11/standalone/x11_platform.cpp +++ b/plugins/platforms/x11/standalone/x11_platform.cpp @@ -282,4 +282,16 @@ void X11StandalonePlatform::startInteractiveWindowSelection(std::functionstart(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); + } + }); +} + } diff --git a/plugins/platforms/x11/standalone/x11_platform.h b/plugins/platforms/x11/standalone/x11_platform.h index 719c94a981..7fa55261d8 100644 --- a/plugins/platforms/x11/standalone/x11_platform.h +++ b/plugins/platforms/x11/standalone/x11_platform.h @@ -53,6 +53,8 @@ public: PlatformCursorImage cursorImage() const override; + void setupActionForGlobalAccel(QAction *action) override; + protected: void doHideCursor() override; void doShowCursor() override;