From 5558e3509d020a0e021a77f0617044497b2f2aee Mon Sep 17 00:00:00 2001 From: salmonik Date: Mon, 17 Aug 2026 18:56:04 +0200 Subject: Windowed GUI: wm module, input routing, and the paint app - Add the wm window-manager facility per ADR 0004: overlapping pixel-surface windows, damage-rectangle compositing, WM-drawn title bar, focus/minimize/close, and F1-F4 keybindings - Add gop shadow compositing primitives and vt::repaint_region so the console stays layer 0 beneath windows - Route mouse (absolute coords, press/release edges) and keyboard (focus-aware input pump) to the focused window - Add the rspaint drawing-program crate (pen, 8 colors, clear) and shell draw/windows/restore commands - Extend TaskMsg with AppMouse/Focus/Close and document the design in CONTEXT.md + ADR 0004 --- rsnix/src/tty.rs | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) (limited to 'rsnix/src/tty.rs') diff --git a/rsnix/src/tty.rs b/rsnix/src/tty.rs index 0783521..6102fb5 100644 --- a/rsnix/src/tty.rs +++ b/rsnix/src/tty.rs @@ -41,14 +41,31 @@ static mut RAW_LEN: usize = 0; /// Combined blocking key poll: USB HID keyboard first (polled UHCI), then /// the PS/2 path (which parks via `hlt` until an IRQ-fed scancode lands). fn poll_key() -> KeyEvent { - if let Some(ev) = crate::uhci::try_poll_key() { - return ev; + loop { + // A GUI window has focus: the keyboard pump owns the keys. Park so + // the shell/editor don't steal input from the focused app. + if crate::wm::focused().is_some() { + crate::sched::sleep_ms(5); + continue; + } + if let Some(ev) = crate::uhci::try_poll_key() { + return ev; + } + if let Some(ev) = ps2::try_poll_key() { + return ev; + } + // No key ready: park briefly, then re-check focus (so a focus change + // to a GUI window is noticed instead of blocking on a stolen key). + crate::sched::sleep_ms(5); } - ps2::poll_key() } -/// Combined non-blocking key poll (USB first, then PS/2). +/// Combined non-blocking key poll (USB first, then PS/2). Returns `None` +/// while a GUI window is focused (the keyboard pump owns the keys). fn try_poll_key() -> Option { + if crate::wm::focused().is_some() { + return None; + } crate::uhci::try_poll_key().or_else(ps2::try_poll_key) } -- cgit v1.2.3