From 34969ccf4488ad38222754b1ba3a5ce7c0459456 Mon Sep 17 00:00:00 2001 From: The412Banner <205237651+The412Banner@users.noreply.github.com> Date: Tue, 13 Oct 2026 22:03:28 -0400 Subject: [PATCH] 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 Co-authored-by: xXJsonDeruloXx --- app/src/main/cpp/waylandcomp/src/compositor.c | 6 ++++++ .../com/droiddeck/launcher/SessionActivity.kt | 1 + .../patches/0015-statx-mnt-id-fdinfo.patch | 20 ++----------------- 3 files changed, 9 insertions(+), 18 deletions(-) diff --git a/app/src/main/cpp/waylandcomp/src/compositor.c b/app/src/main/cpp/waylandcomp/src/compositor.c index 68911fc202..677937b52c 100644 --- a/app/src/main/cpp/waylandcomp/src/compositor.c +++ b/app/src/main/cpp/waylandcomp/src/compositor.c @@ -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(); diff --git a/app/src/main/java/com/droiddeck/launcher/SessionActivity.kt b/app/src/main/java/com/droiddeck/launcher/SessionActivity.kt index b414cd672d..1c6d32ddf2 100644 --- a/app/src/main/java/com/droiddeck/launcher/SessionActivity.kt +++ b/app/src/main/java/com/droiddeck/launcher/SessionActivity.kt @@ -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 diff --git a/tools/proot/patches/0015-statx-mnt-id-fdinfo.patch b/tools/proot/patches/0015-statx-mnt-id-fdinfo.patch index aa5b564f89..a0821997ae 100644 --- a/tools/proot/patches/0015-statx-mnt-id-fdinfo.patch +++ b/tools/proot/patches/0015-statx-mnt-id-fdinfo.patch @@ -11,20 +11,8 @@ diff --git a/src/syscall/seccomp.c b/src/syscall/seccomp.c index ee7b8acd68660f38fd52f56e951ffb94e9061d68..ff3a79b60e9092a296bb444c919bb3861338727f 100644 --- a/src/syscall/seccomp.c +++ b/src/syscall/seccomp.c -@@ -738,4 +738,4 @@ int enable_syscall_filtering(const Tracee *tracee) -- * the statx one emulates the call when it fails, which only a kernel -- * before 4.11 does for want of it - a statx Android's policy traps is -- * emulated from SIGSYS instead. Both stops re-read and re-translate -- * the path, and are paid on every call. -+ * the statx one emulates the syscall before 4.11 and supplies MNT_ID -+ * from fdinfo through 5.7. Android policy traps are still emulated from -+ * SIGSYS instead. Both stops re-read and re-translate the path, and are -+ * paid on every call. -@@ -764 +764,4 @@ static void drop_unneeded_exit_stops(void) +@@ -764 +764 @@ static void drop_unneeded_exit_stops(void) - if (major > 4 || (major == 4 && minor >= 11)) -+ /* Linux 4.11 introduced statx; Linux 5.8 added MNT_ID. -+ * Keep its exit stop through 5.7 so the missing ID can be -+ * recovered from the descriptor's fdinfo. */ + if (major > 5 || (major == 5 && minor >= 8)) diff --git a/src/tracee/statx.c b/src/tracee/statx.c index ca972f892e84461cb694dd13a37bfbc67527b320..824771ccf5934e1f870fc36a29fb22fdcad0a856 100644 @@ -32,11 +20,7 @@ index ca972f892e84461cb694dd13a37bfbc67527b320..824771ccf5934e1f870fc36a29fb22fd +++ b/src/tracee/statx.c @@ -4,0 +5 @@ +#include "tracee/statx_mnt_id.h" -@@ -125,0 +127,9 @@ int handle_statx_syscall(Tracee *tracee, bool from_sigsys) { -+ /* libglnx chases an already-open fd with AT_EMPTY_PATH and requires a -+ * mount ID. Kernels before 5.8 can succeed without returning that field. -+ * The tracee is stopped at this syscall exit; accept only the ordinary -+ * mount ID and verify the fdinfo inode against the statx result. */ +@@ -125,0 +127,5 @@ int handle_statx_syscall(Tracee *tracee, bool from_sigsys) { + if (droiddeck_proot_statx_fill_mnt_id(tracee->pid, (int) dirfd, + (int) flags, guest_path, (unsigned int) mask, + &state.statx_buf))