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/>.
*********************************************************************/
#include "../virtualdesktops.h"
#include "../input.h"
// KDE
#include <KConfigGroup>
@ -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)

View file

@ -21,6 +21,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#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>() << 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));
input()->registerShortcut(shortcut, a);
return engine->newVariant(true);
}

View file

@ -34,6 +34,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#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<QKeySequence>() << 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());
}

View file

@ -35,6 +35,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#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<QKeySequence>() << shortcut);
KGlobalAccel::self()->setShortcut(a, QList<QKeySequence>() << shortcut);
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/>.
*********************************************************************/
#include "virtualdesktops.h"
#include "input.h"
// KDE
#include <KConfigGroup>
#include <KGlobalAccel>
@ -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<QKeySequence>() << 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<QKeySequence>());
input()->registerShortcut(QKeySequence(), a);
}
void VirtualDesktopManager::slotSwitchTo()