XWayland: no forwarding with Shift keys

The shift key doesn't make sense to be one of the keys that will trigger
KWin to allow XWayland apps to process all keys when it's pressed,
because there aren't generally global shortcuts that consist of Shift
plus an alphanumeric character key. That's because this key combination
is used to type capital letters.

So we can safely exclude the shift key to improve security against key logging and not break any global
shortcut-using XWayland apps for people using this feature.

The shift key on it's own is still forwarded as that's a non-character key.
This commit is contained in:
David Edmundson 2023-11-28 20:10:37 +00:00
parent 831064f351
commit d18db74d5f
2 changed files with 6 additions and 9 deletions

View file

@ -68,7 +68,7 @@ KCM.SimpleKCM {
text: i18n("Only non-character keys")
}
QQC2.RadioButton {
text: i18n("As above, plus any key typed while a modifier key is pressed")
text: i18n("As above, plus any key typed while the Control, Alt, or Meta keys are pressed")
}
QQC2.RadioButton {
id: always

View file

@ -110,11 +110,10 @@ public:
void setMode(XwaylandEavesdropsMode mode)
{
static const QSet<quint32> modifierKeys = {
Qt::Key_Control,
Qt::Key_Shift,
Qt::Key_Alt,
Qt::Key_Meta,
static const Qt::KeyboardModifiers modifierKeys = {
Qt::ControlModifier,
Qt::AltModifier,
Qt::MetaModifier,
};
static const QSet<quint32> characterKeys = {
@ -347,9 +346,7 @@ public:
break;
case AllKeysWithModifier:
m_filter = [](int key, Qt::KeyboardModifiers m) {
return m != Qt::NoModifier
|| modifierKeys.contains(key)
|| !characterKeys.contains(key);
return m.testAnyFlags(modifierKeys) || !characterKeys.contains(key);
};
break;
case All: