From 1cd5235afe02f68a676dcee2cb7168978aac65c5 Mon Sep 17 00:00:00 2001 From: David Redondo Date: Tue, 5 Nov 2024 14:03:13 +0100 Subject: [PATCH] keystate: Do not send modifier enums to clients that dont know them --- src/wayland/keystate.cpp | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/wayland/keystate.cpp b/src/wayland/keystate.cpp index 0696474b91..f823e5ac20 100644 --- a/src/wayland/keystate.cpp +++ b/src/wayland/keystate.cpp @@ -40,18 +40,23 @@ public: send_stateChanged(resource->handle, k, state_locked); } else if (input()->keyboard()->xkb()->latchedModifiers().testFlag(mod)) { send_stateChanged(resource->handle, k, state_latched); - } else if (input()->keyboard()->xkb()->depressedModifiers().testFlag(mod)) { + } else if (input()->keyboard()->xkb()->depressedModifiers().testFlag(mod) && resource->version() >= ORG_KDE_KWIN_KEYSTATE_STATE_PRESSED_SINCE_VERSION) { send_stateChanged(resource->handle, k, state_pressed); } else { send_stateChanged(resource->handle, k, state_unlocked); } }; - sendModifier(key_alt, Xkb::Mod1); - sendModifier(key_shift, Xkb::Shift); - sendModifier(key_control, Xkb::Control); - sendModifier(key_meta, Xkb::Mod4); - sendModifier(key_altgr, Xkb::Mod5); + static constexpr int modifierSinceVersion = ORG_KDE_KWIN_KEYSTATE_KEY_ALT_SINCE_VERSION; + + if (resource->version() >= modifierSinceVersion) { + sendModifier(key_alt, Xkb::Mod1); + sendModifier(key_shift, Xkb::Shift); + sendModifier(key_control, Xkb::Control); + sendModifier(key_meta, Xkb::Mod4); + sendModifier(key_altgr, Xkb::Mod5); + } + sendModifier(key_capslock, Xkb::Lock); sendModifier(key_numlock, Xkb::Num); }