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.
This commit is contained in:
Martin Gräßlin 2013-07-10 11:45:51 +02:00
parent 24b23dfc01
commit d1d3401b9f
5 changed files with 20 additions and 1 deletions

View file

@ -18,6 +18,7 @@ You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. along with this program. If not, see <http://www.gnu.org/licenses/>.
*********************************************************************/ *********************************************************************/
#include "../virtualdesktops.h" #include "../virtualdesktops.h"
#include "../input.h"
// KDE // KDE
#include <KConfigGroup> #include <KConfigGroup>
@ -28,6 +29,14 @@ namespace KWin {
int screen_number = 0; 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) Q_DECLARE_METATYPE(Qt::Orientation)

View file

@ -21,6 +21,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#ifndef KWIN_SCRIPTINGUTILS_H #ifndef KWIN_SCRIPTINGUTILS_H
#define KWIN_SCRIPTINGUTILS_H #define KWIN_SCRIPTINGUTILS_H
#include "input.h"
#include "workspace.h" #include "workspace.h"
#ifdef KWIN_BUILD_SCREENEDGES #ifdef KWIN_BUILD_SCREENEDGES
#include "screenedge.h" #include "screenedge.h"
@ -117,8 +118,10 @@ QScriptValue globalShortcut(QScriptContext *context, QScriptEngine *engine)
QAction* a = new QAction(script); QAction* a = new QAction(script);
a->setObjectName(context->argument(0).toString()); a->setObjectName(context->argument(0).toString());
a->setText(context->argument(1).toString()); a->setText(context->argument(1).toString());
KGlobalAccel::self()->setShortcut(a, QList<QKeySequence>() << QKeySequence(context->argument(2).toString())); const QKeySequence shortcut = QKeySequence(context->argument(2).toString());
KGlobalAccel::self()->setShortcut(a, QList<QKeySequence>() << shortcut);
script->registerShortcut(a, context->argument(3)); script->registerShortcut(a, context->argument(3));
input()->registerShortcut(shortcut, a);
return engine->newVariant(true); return engine->newVariant(true);
} }

View file

@ -34,6 +34,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#endif #endif
#include "client.h" #include "client.h"
#include "effects.h" #include "effects.h"
#include "input.h"
#include "focuschain.h" #include "focuschain.h"
#ifdef KWIN_BUILD_SCREENEDGES #ifdef KWIN_BUILD_SCREENEDGES
#include "screenedge.h" #include "screenedge.h"
@ -492,6 +493,7 @@ void TabBox::key(const char *actionName, Slot slot, const QKeySequence &shortcut
a->setText(i18n(actionName)); a->setText(i18n(actionName));
KGlobalAccel::self()->setShortcut(a, QList<QKeySequence>() << shortcut); KGlobalAccel::self()->setShortcut(a, QList<QKeySequence>() << shortcut);
connect(a, &QAction::triggered, TabBox::self(), slot); connect(a, &QAction::triggered, TabBox::self(), slot);
input()->registerShortcut(shortcut, a);
auto cuts = KGlobalAccel::self()->shortcut(a); auto cuts = KGlobalAccel::self()->shortcut(a);
globalShortcutChanged(a, cuts.isEmpty() ? QKeySequence() : cuts.first()); globalShortcutChanged(a, cuts.isEmpty() ? QKeySequence() : cuts.first());
} }

View file

@ -35,6 +35,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "cursor.h" #include "cursor.h"
#include "client.h" #include "client.h"
#include "decorations.h" #include "decorations.h"
#include "input.h"
#include "workspace.h" #include "workspace.h"
#include "effects.h" #include "effects.h"
#include "screens.h" #include "screens.h"
@ -921,6 +922,7 @@ void Workspace::initShortcut(const QString &actionName, const QString &descripti
KGlobalAccel::self()->setDefaultShortcut(a, QList<QKeySequence>() << shortcut); KGlobalAccel::self()->setDefaultShortcut(a, QList<QKeySequence>() << shortcut);
KGlobalAccel::self()->setShortcut(a, QList<QKeySequence>() << shortcut); KGlobalAccel::self()->setShortcut(a, QList<QKeySequence>() << shortcut);
connect(a, &QAction::triggered, this, slot); connect(a, &QAction::triggered, this, slot);
input()->registerShortcut(shortcut, a);
} }
/*! /*!

View file

@ -19,6 +19,7 @@ You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. along with this program. If not, see <http://www.gnu.org/licenses/>.
*********************************************************************/ *********************************************************************/
#include "virtualdesktops.h" #include "virtualdesktops.h"
#include "input.h"
// KDE // KDE
#include <KConfigGroup> #include <KConfigGroup>
#include <KGlobalAccel> #include <KGlobalAccel>
@ -453,6 +454,7 @@ void VirtualDesktopManager::addAction(const QString &name, const KLocalizedStrin
a->setData(value); a->setData(value);
connect(a, &QAction::triggered, this, slot); connect(a, &QAction::triggered, this, slot);
KGlobalAccel::self()->setShortcut(a, QList<QKeySequence>() << key); KGlobalAccel::self()->setShortcut(a, QList<QKeySequence>() << key);
input()->registerShortcut(key, a);
} }
void VirtualDesktopManager::addAction(const QString &name, const QString &label, void (VirtualDesktopManager::*slot)()) 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); a->setText(label);
connect(a, &QAction::triggered, this, slot); connect(a, &QAction::triggered, this, slot);
KGlobalAccel::self()->setShortcut(a, QList<QKeySequence>()); KGlobalAccel::self()->setShortcut(a, QList<QKeySequence>());
input()->registerShortcut(QKeySequence(), a);
} }
void VirtualDesktopManager::slotSwitchTo() void VirtualDesktopManager::slotSwitchTo()