From 819778f292ee4e1294603b98662e083e49e23463 Mon Sep 17 00:00:00 2001 From: salmonik Date: Sat, 1 Aug 2026 19:52:05 +0200 Subject: rsnix v0.5.0: graphics layer + cursor compositor MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The first visible GUI surface: real rect primitives, a single shadow→display push path, and an on-screen mouse cursor that can never race the text surface. gop: - fill_rect + push_rect(x,y,w,h): every raster op rasterises into the RAM shadow, then push_rect copies the rect to the display (write-only, still never read) and composites the cursor on top. blit_glyph and scroll shifts now route through it. - cursor overlay: 12x16 pointer (const-fn built from column lists) drawn white with a black offset outline; position in one AtomicU64 (x:high 32, y:low 32) — unpack masks the low word (a bare 'as usize' cast is a no-op on 64-bit). The cursor never enters the shadow, so erasing is just a shadow push of the old rect. - cursor_redraw after scroll shifts and once at spawn (the vt diff never re-blits idle cells). cursor task (task 2, spawned at boot when a mouse is present): - owns the PS/2 ring; polls every 10 ms, moves the cursor (clamped), tracks buttons, and forwards every event to a task's queue when 'mouse ' armed it (the window-manager input path). - /dev/mouse is now a position device (x/y/buttons snapshot); 'mouse' watches the cursor live (prints on change); 'cursor' prints one-shot state; 'gfx' draws a status-bar demo; 'gfx check' is an in-kernel pixel self-test (shadow readback, display readback, cursor overlay purity) — PASS/FAIL per stage. Tests (headless QEMU + monitor injection): - make test-gfx (new): all four compositor checks PASS. - make test-mouse (rewritten): cursor tracks mouse_move deltas, buttons ride along, /dev/mouse snapshot, live watch, real-event queue routing. - make test-msg: task numbering shifted (cursor is task 2; msgrecv is task 3) — updated, still PASS. - make test-disk regression re-passes. 0 build warnings. --- rsnix/src/fs.rs | 37 +++++++++++++------------------------ 1 file changed, 13 insertions(+), 24 deletions(-) (limited to 'rsnix/src/fs.rs') diff --git a/rsnix/src/fs.rs b/rsnix/src/fs.rs index 0b7a772..5fc6d7a 100644 --- a/rsnix/src/fs.rs +++ b/rsnix/src/fs.rs @@ -713,34 +713,23 @@ fn dev_text(dev: CharDevice, _pos: u64) -> String { } } -/// Render `/dev/mouse`: drain every pending PS/2 event (up to 32) into one -/// line each, so `cat /dev/mouse` shows the movement that happened since -/// the last read. Falls back to a clear message when there is no device or -/// nothing pending. +/// Render `/dev/mouse`: the current cursor state (position + buttons). +/// The cursor task owns the PS/2 ring, so this is a position device — +/// the GUI-correct semantic — rather than an event drain. fn mouse_text() -> String { if !crate::ps2::mouse_present() { return String::from("mouse: no PS/2 mouse\n"); } - let mut s = String::new(); - for _ in 0..32 { - let Some(ev) = crate::ps2::try_poll_mouse() else { - break; - }; - let mut b = String::new(); - b.push(if ev.left { 'L' } else { '-' }); - b.push(if ev.right { 'R' } else { '-' }); - b.push(if ev.middle { 'M' } else { '-' }); - s.push_str(&alloc::format!( - "dx={:+} dy={:+} buttons={}\n", - ev.dx, - ev.dy, - b - )); - } - if s.is_empty() { - s.push_str("mouse: no events\n"); - } - s + let (x, y) = crate::gop::cursor_pos(); + let b = crate::gop::cursor_buttons(); + alloc::format!( + "x={} y={} buttons={}{}{}\n", + x, + y, + if b & 1 != 0 { 'L' } else { '-' }, + if b & 2 != 0 { 'R' } else { '-' }, + if b & 4 != 0 { 'M' } else { '-' } + ) } // --- self-test ------------------------------------------------------------ -- cgit v1.2.3