From d1d3401b9f6671a0e96d4d5643cb969a11c993de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Gr=C3=A4=C3=9Flin?= Date: Wed, 10 Jul 2013 11:45:51 +0200 Subject: [PATCH] Register KWin's global shortcuts with the new shortcut system All the KWin core shortcuts get also registered inside the new global shortcut system so that they are still triggered when running KWin on Wayland. --- autotests/test_virtual_desktops.cpp | 9 +++++++++ scripting/scriptingutils.h | 5 ++++- tabbox/tabbox.cpp | 2 ++ useractions.cpp | 2 ++ virtualdesktops.cpp | 3 +++ 5 files changed, 20 insertions(+), 1 deletion(-) diff --git a/autotests/test_virtual_desktops.cpp b/autotests/test_virtual_desktops.cpp index 2d6787eda6..7a27ca1cc6 100644 --- a/autotests/test_virtual_desktops.cpp +++ b/autotests/test_virtual_desktops.cpp @@ -18,6 +18,7 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . *********************************************************************/ #include "../virtualdesktops.h" +#include "../input.h" // KDE #include @@ -28,6 +29,14 @@ namespace KWin { int screen_number = 0; +InputRedirection *InputRedirection::s_self = nullptr; + +void InputRedirection::registerShortcut(const QKeySequence &shortcut, QAction *action) +{ + Q_UNUSED(shortcut) + Q_UNUSED(action) +} + } Q_DECLARE_METATYPE(Qt::Orientation) diff --git a/scripting/scriptingutils.h b/scripting/scriptingutils.h index dff15aa92a..e92923bda0 100644 --- a/scripting/scriptingutils.h +++ b/scripting/scriptingutils.h @@ -21,6 +21,7 @@ along with this program. If not, see . #ifndef KWIN_SCRIPTINGUTILS_H #define KWIN_SCRIPTINGUTILS_H +#include "input.h" #include "workspace.h" #ifdef KWIN_BUILD_SCREENEDGES #include "screenedge.h" @@ -117,8 +118,10 @@ QScriptValue globalShortcut(QScriptContext *context, QScriptEngine *engine) QAction* a = new QAction(script); a->setObjectName(context->argument(0).toString()); a->setText(context->argument(1).toString()); - KGlobalAccel::self()->setShortcut(a, QList() << QKeySequence(context->argument(2).toString())); + const QKeySequence shortcut = QKeySequence(context->argument(2).toString()); + KGlobalAccel::self()->setShortcut(a, QList() << shortcut); script->registerShortcut(a, context->argument(3)); + input()->registerShortcut(shortcut, a); return engine->newVariant(true); } diff --git a/tabbox/tabbox.cpp b/tabbox/tabbox.cpp index 589cd8fabb..200222c595 100644 --- a/tabbox/tabbox.cpp +++ b/tabbox/tabbox.cpp @@ -34,6 +34,7 @@ along with this program. If not, see . #endif #include "client.h" #include "effects.h" +#include "input.h" #include "focuschain.h" #ifdef KWIN_BUILD_SCREENEDGES #include "screenedge.h" @@ -492,6 +493,7 @@ void TabBox::key(const char *actionName, Slot slot, const QKeySequence &shortcut a->setText(i18n(actionName)); KGlobalAccel::self()->setShortcut(a, QList() << shortcut); connect(a, &QAction::triggered, TabBox::self(), slot); + input()->registerShortcut(shortcut, a); auto cuts = KGlobalAccel::self()->shortcut(a); globalShortcutChanged(a, cuts.isEmpty() ? QKeySequence() : cuts.first()); } diff --git a/useractions.cpp b/useractions.cpp index 2d3767cd39..a483d8d93f 100755 --- a/useractions.cpp +++ b/useractions.cpp @@ -35,6 +35,7 @@ along with this program. If not, see . #include "cursor.h" #include "client.h" #include "decorations.h" +#include "input.h" #include "workspace.h" #include "effects.h" #include "screens.h" @@ -921,6 +922,7 @@ void Workspace::initShortcut(const QString &actionName, const QString &descripti KGlobalAccel::self()->setDefaultShortcut(a, QList() << shortcut); KGlobalAccel::self()->setShortcut(a, QList() << shortcut); connect(a, &QAction::triggered, this, slot); + input()->registerShortcut(shortcut, a); } /*! diff --git a/virtualdesktops.cpp b/virtualdesktops.cpp index d6afab5a5b..393d5ed5b3 100644 --- a/virtualdesktops.cpp +++ b/virtualdesktops.cpp @@ -19,6 +19,7 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . *********************************************************************/ #include "virtualdesktops.h" +#include "input.h" // KDE #include #include @@ -453,6 +454,7 @@ void VirtualDesktopManager::addAction(const QString &name, const KLocalizedStrin a->setData(value); connect(a, &QAction::triggered, this, slot); KGlobalAccel::self()->setShortcut(a, QList() << key); + input()->registerShortcut(key, a); } void VirtualDesktopManager::addAction(const QString &name, const QString &label, void (VirtualDesktopManager::*slot)()) @@ -462,6 +464,7 @@ void VirtualDesktopManager::addAction(const QString &name, const QString &label, a->setText(label); connect(a, &QAction::triggered, this, slot); KGlobalAccel::self()->setShortcut(a, QList()); + input()->registerShortcut(QKeySequence(), a); } void VirtualDesktopManager::slotSwitchTo()