fix: desktop session: Shift no longer stays held after typing capitals on a physical keyboard (#766)

* fix: desktop session: Shift no longer stays held after typing capitals on a physical keyboard

Android repeats a held key as more key presses. Those were forwarded to the
session as more wl_keyboard presses, and KWin's xkb counts every press of a
modifier, so Shift held for a few capitals took several presses and one
release and stayed held: digits typed !@#, letters stayed capital. The same
applied to Ctrl and Alt.

- the compositor no longer sends a press for a key that is already down;
  releases always go through (clients repeat keys themselves from the
  repeat_info it already sends)
- the app stops forwarding Android's repeat events for keyboard keys

Reported by whatsupbros with a Keychron Q7 over USB - thank you.

* Remove stale comments from statx patch

---------

Co-authored-by: The412Banner <the412banner@users.noreply.github.com>
Co-authored-by: xXJsonDeruloXx <danielhimebauch@gmail.com>
This commit is contained in:
authored and GitHub committed 2026-10-13 22:03:28 -04:00
1 parent 0d0465d19e
commit d310e59fce
3 files changed
+9 -18

No files matched your search

@@ -397,6 +397,7 @@ static struct seat_keyboard g_kbs[MAX_PTRS];
static int g_nkbs;
static uint32_t g_mods_depressed, g_mods_locked;
static uint32_t g_mod_keys_held;
static uint8_t g_keys_down[0x300 / 8];
static struct seat_touch g_touches[MAX_PTRS];
static int g_ntouches;
@@ -2845,6 +2846,11 @@ static int update_modifiers(uint32_t evdev, int pressed) {
}
static void key_event(uint32_t evdev, int pressed) {
if (evdev < 0x300) {
uint8_t bit = (uint8_t)(1u << (evdev & 7));
if (pressed && (g_keys_down[evdev >> 3] & bit)) return;
if (pressed) g_keys_down[evdev >> 3] |= bit; else g_keys_down[evdev >> 3] &= (uint8_t)~bit;
}
int mods_changed = update_modifiers(evdev, pressed);
struct surface *target = NULL;
struct wl_resource *ime = droiddeck_ime_target();
@@ -1577,6 +1577,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback {
if (event.keyCode != KeyEvent.KEYCODE_BACK && padBridge?.onKeyEvent(event) == true) return true
if (CompositorHost.isStarted && event.keyCode != KeyEvent.KEYCODE_BACK && !fromController) {
val down = event.action == KeyEvent.ACTION_DOWN
if (down && event.repeatCount > 0) return true
if (down || event.action == KeyEvent.ACTION_UP) {
var evdev = EvdevKeys.fromKeyCode(event.keyCode)
val ch = event.unicodeChar