Commit 87e72506 authored by Aleix Pol Gonzalez's avatar Aleix Pol Gonzalez 🐧 Committed by Aleix Pol Gonzalez
Browse files

Add support for KGlobalAccelInterfaceV2::keyReleased

To be able to implement the XdgDesktopPortal for GlobalShortcuts, we
need to let kglobalaccel know when a shortcut is not deactivated
anymore.
parent 9a31b0d7
Pipeline #169982 passed with stage
in 16 minutes and 51 seconds
......@@ -232,6 +232,17 @@ bool GlobalShortcutsManager::processKey(Qt::KeyboardModifiers mods, int keyQt)
return false;
}
bool GlobalShortcutsManager::processKeyRelease(Qt::KeyboardModifiers mods, int keyQt)
{
if (m_kglobalAccelInterface) {
QMetaObject::invokeMethod(m_kglobalAccelInterface,
"checkKeyReleased",
Qt::DirectConnection,
Q_ARG(int, int(mods) | keyQt));
}
return false;
}
template<typename ShortcutKind, typename... Args>
bool match(QVector<GlobalShortcut> &shortcuts, Args... args)
{
......
......@@ -86,6 +86,7 @@ public:
* @return @c true if a shortcut triggered, @c false otherwise
*/
bool processKey(Qt::KeyboardModifiers modifiers, int keyQt);
bool processKeyRelease(Qt::KeyboardModifiers modifiers, int keyQt);
bool processPointerPressed(Qt::KeyboardModifiers modifiers, Qt::MouseButtons pointerButtons);
/**
* @brief Processes a pointer axis event to decide whether a shortcut needs to be triggered.
......
......@@ -1001,6 +1001,10 @@ public:
if (!waylandServer()->isKeyboardShortcutsInhibited()) {
return input()->shortcuts()->processKey(static_cast<KeyEvent *>(event)->modifiersRelevantForGlobalShortcuts(), event->key());
}
} else if (event->type() == QEvent::KeyRelease) {
if (!waylandServer()->isKeyboardShortcutsInhibited()) {
return input()->shortcuts()->processKeyRelease(static_cast<KeyEvent *>(event)->modifiersRelevantForGlobalShortcuts(), event->key());
}
}
return false;
}
......
......@@ -13,7 +13,7 @@
#include <QDebug>
KGlobalAccelImpl::KGlobalAccelImpl(QObject *parent)
: KGlobalAccelInterface(parent)
: KGlobalAccelInterfaceV2(parent)
{
}
......@@ -48,3 +48,8 @@ bool KGlobalAccelImpl::checkKeyPressed(int keyQt)
{
return keyPressed(keyQt);
}
bool KGlobalAccelImpl::checkKeyReleased(int keyQt)
{
return keyReleased(keyQt);
}
......@@ -13,7 +13,7 @@
#include <QObject>
class KGlobalAccelImpl : public KGlobalAccelInterface
class KGlobalAccelImpl : public KGlobalAccelInterfaceV2
{
Q_OBJECT
Q_PLUGIN_METADATA(IID KGlobalAccelInterface_iid FILE "kwin.json")
......@@ -28,6 +28,7 @@ public:
public Q_SLOTS:
bool checkKeyPressed(int keyQt);
bool checkKeyReleased(int keyQt);
private:
bool m_shuttingDown = false;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment