Commit 06d562a5 authored by Martin Flöser's avatar Martin Flöser

Block modifier only shortcuts when screen is/gets locked

If the screen is locked the modifier only shortcuts should not trigger.
Also if the screen gets locked while a modifier is hold the shortcuts
should not trigger.

Reviewed-By: bshah
parent ca50a247
......@@ -233,13 +233,11 @@ void ModifierOnlyShortcutTest::testTrigger()
kwinApp()->platform()->keyboardKeyPressed(modifier, timestamp++);
QVERIFY(Test::lockScreen());
kwinApp()->platform()->keyboardKeyReleased(modifier, timestamp++);
QEXPECT_FAIL("", "Screen locking does not quit trigger yet", Continue);
QCOMPARE(triggeredSpy.count(), 2);
// now trigger while screen is locked, should also not work
kwinApp()->platform()->keyboardKeyPressed(modifier, timestamp++);
kwinApp()->platform()->keyboardKeyReleased(modifier, timestamp++);
QEXPECT_FAIL("", "Screen locking does not prevent trigger yet", Continue);
QCOMPARE(triggeredSpy.count(), 2);
QVERIFY(Test::unlockScreen());
......
......@@ -22,6 +22,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "abstract_client.h"
#include "options.h"
#include "utils.h"
#include "screenlockerwatcher.h"
#include "toplevel.h"
#include "wayland_server.h"
#include "workspace.h"
......@@ -101,6 +102,7 @@ Xkb::Xkb(InputRedirection *input)
};
QObject::connect(m_input, &InputRedirection::pointerButtonStateChanged, resetModOnlyShortcut);
QObject::connect(m_input, &InputRedirection::pointerAxisChanged, resetModOnlyShortcut);
QObject::connect(ScreenLockerWatcher::self(), &ScreenLockerWatcher::locked, m_input, resetModOnlyShortcut);
}
Xkb::~Xkb()
......@@ -250,6 +252,7 @@ void Xkb::updateKey(uint32_t key, InputRedirection::KeyboardKeyState state)
if (state == InputRedirection::KeyboardKeyPressed) {
m_modOnlyShortcut.pressCount++;
if (m_modOnlyShortcut.pressCount == 1 &&
!ScreenLockerWatcher::self()->isLocked() &&
m_input->qtButtonStates() == Qt::NoButton) {
m_modOnlyShortcut.modifier = Qt::KeyboardModifier(int(m_modifiers));
} else {
......@@ -257,7 +260,6 @@ void Xkb::updateKey(uint32_t key, InputRedirection::KeyboardKeyState state)
}
} else {
m_modOnlyShortcut.pressCount--;
// TODO: ignore on lock screen
if (m_modOnlyShortcut.pressCount == 0) {
if (m_modOnlyShortcut.modifier != Qt::NoModifier) {
const auto list = options->modifierOnlyDBusShortcut(m_modOnlyShortcut.modifier);
......
Markdown is supported
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