From 2f4cf666c0c7bd224932fa48973e7334360c1de3 Mon Sep 17 00:00:00 2001 From: salmonik Date: Fri, 21 Aug 2026 20:13:59 +0200 Subject: input: total keyboard routing + per-terminal discipline (ADR 0006 ph1) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit wm: FOCUSED is now a plain window id — window 0 (home terminal) is an ordinary focusable window in the z-order. The CONSOLE sentinel (usize::MAX) and the focused()==0 special cases are gone; focus_console() is an alias for focus(0). Desktop clicks focus window 0. The WM input pump routes every key unconditionally: IRQ ring -> pump -> focused window's owner; nothing polls the scancode rings directly any more. tty: read_line() reads from the calling task's message queue (the old global-ring read_line and the duplicate read_line_from_queue are merged); raw mode (read_byte/try_read_byte) consumes the same queue; interrupt_pressed drains the queue instead of the ring. shell: task 0 owns home terminal window 0 and blocks on its queue like a windowed shell; cat/hexdump stdin paths pass the home terminal handle. sched: watchdog comments updated (shell parks on recv_blocking). Verified in QEMU: F1 spawns terminals, F2 cycles focus home->term1-> term2, keystrokes land only in the focused window, ^C cancels a line, edit runs raw over the queue and exits to a working prompt; test-disk regression PASS. --- scripts/test-focus.py | 56 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100755 scripts/test-focus.py (limited to 'scripts') diff --git a/scripts/test-focus.py b/scripts/test-focus.py new file mode 100755 index 0000000..e1bbe2d --- /dev/null +++ b/scripts/test-focus.py @@ -0,0 +1,56 @@ +#!/usr/bin/env python3 +"""Drive the focus-routing gate: 3 windows, type markers, verify routing. + +Connects to the QEMU monitor once and keeps the socket open (the per-call +scripts/sendkeys.py pattern loses the socket when the monitor resets). + +Usage: python3 scripts/test-focus.py /tmp/qmon.sock +""" +import socket +import sys +import time + +sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) +sock.connect(sys.argv[1] if len(sys.argv) > 1 else "/tmp/sysboot-mon.sock") + + +def sk(k, d=0.35): + sock.sendall(f"sendkey {k}\n".encode()) + time.sleep(d) + + +def line(txt, d=0.8): + for ch in txt: + if ch == " ": + sk("spc", 0.1) + elif ch.isupper(): + sk("shift-" + ch.lower(), 0.12) + else: + sk(ch, 0.12) + sk("ret", d) + + +time.sleep(0.5) + +# Home is focused at boot. +line("windows") # expect: home + nothing (or existing windows) +time.sleep(1.5) + +# F1 -> term1 (focused on creation) +sk("f1", 1.5) +line("echo TERM1MARK") +time.sleep(1.0) + +# F1 -> term2 (focused on creation) +sk("f1", 1.5) +line("echo TERM2MARK") +time.sleep(1.0) + +# F2 cycles z-order: term2 -> term1 +sk("f2", 0.8) +line("echo CYCLED") +time.sleep(1.0) + +# F2 again: term1 -> home (window 0, oldest) +sk("f2", 0.8) +line("windows") -- cgit v1.2.3