Skip to content

Commit c1a1221

Browse files
committed
Diagnose and patch Linux key event routing (WIP)
Add temporary logging and diagnostic patches for Linux/Wayland key event input issues: - Log all Tao key events (KEY_DOWN/UP/TYPED) with vk code, modifiers, codepoint - Disable permanent super_key() state from taffy that contaminates Tab/Backspace with unwanted Meta modifier - Fall through ModifiersChanged to emit KeyboardInput for modifier-only presses (Alt/Ctrl/Shift/Super release now observable on Linux vs upstream tao) Diagnostic code — remove once input routing is verified.
1 parent 0344221 commit c1a1221

3 files changed

Lines changed: 28 additions & 5 deletions

File tree

decorated-window-tao/src/main/kotlin/dev/nucleusframework/window/tao/render/TaoComposeSceneHostLinux.kt

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1021,6 +1021,21 @@ internal class TaoComposeSceneHostLinux(
10211021
modifiers: Int,
10221022
codePoint: Int,
10231023
): Boolean {
1024+
// TEMPORARY DIAGNOSTIC — log every Tao key event reaching the scene host
1025+
// so we can correlate user-visible bugs (Tab triggering shortcut without
1026+
// Alt, Backspace not deleting in TextField) with the exact native event
1027+
// shape (vk code, modifier bitmask, codePoint) Tao forwards from libtao.
1028+
// Remove once the input routing is verified.
1029+
val typeName =
1030+
when (type) {
1031+
TaoEventCode.KEY_DOWN -> "KEY_DOWN"
1032+
TaoEventCode.KEY_UP -> "KEY_UP"
1033+
TaoEventCode.KEY_TYPED -> "KEY_TYPED"
1034+
else -> "OTHER($type)"
1035+
}
1036+
println(
1037+
"[TAO_KEY] $typeName vk=$vkCode loc=$keyLocation mods=0b${modifiers.toString(2).padStart(4, '0')} cp=$codePoint",
1038+
)
10241039
val sc = scene ?: return false
10251040
val isCtrl = (modifiers and TaoModifierMask.CONTROL) != 0
10261041
val isMeta = (modifiers and TaoModifierMask.META) != 0

decorated-window-tao/src/main/native/src/events.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,12 @@ pub(crate) fn pack_modifiers(state: ModifiersState) -> i32 {
2222
if state.shift_key() { m |= MOD_MASK_SHIFT; }
2323
if state.control_key() { m |= MOD_MASK_CONTROL; }
2424
if state.alt_key() { m |= MOD_MASK_ALT; }
25-
if state.super_key() { m |= MOD_MASK_META; }
25+
// DIAGNOSTIC (Linux/Wayland): super_key() returns true permanently on some
26+
// compositors after the first ModifiersChanged tick, contaminating every
27+
// subsequent key event (Tab gets Meta, Backspace gets Meta → TextField
28+
// mapping fails). Temporarily disabled while we verify the workaround
29+
// approach. Re-enable once a per-key SuperLeft/SuperRight tracker is in.
30+
let _ = state.super_key();
2631
m
2732
}
2833

decorated-window-tao/src/main/native/vendor/tao/src/platform_impl/linux/event_loop.rs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -727,11 +727,14 @@ impl<T: 'static> EventLoop<T> {
727727
"Failed to send modifiers changed event to event channel: {}",
728728
e
729729
);
730-
} else {
731-
// stop here we don't want to send the key event
732-
// as we emit the `ModifiersChanged`
733-
return glib::ControlFlow::Continue;
734730
}
731+
// Nucleus patch: fall through and *also* emit `KeyboardInput`
732+
// for modifier-only keypresses so the JVM side can observe Alt
733+
// / Ctrl / Shift / Super press/release as plain Compose key
734+
// events (needed by app-level handlers like
735+
// `(ev.key == Key.AltLeft) && ev.type == KeyEventType.KeyUp`).
736+
// Upstream tao stops here, which makes those handlers dead on
737+
// the Linux backend.
735738
}
736739

737740
// todo: implement repeat?

0 commit comments

Comments
 (0)