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/vt.rs | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'rsnix/src/vt.rs') diff --git a/rsnix/src/vt.rs b/rsnix/src/vt.rs index 9444063..c5fc5fd 100644 --- a/rsnix/src/vt.rs +++ b/rsnix/src/vt.rs @@ -147,6 +147,31 @@ pub fn size() -> (usize, usize) { unsafe { (ROWS, COLS) } } +/// Re-render the console's cells into the shadow for a pixel region, so the +/// window manager can restore the console (layer 0) beneath a window that +/// moved, closed, or was minimized. Does not push — the caller pushes once. +pub fn repaint_region(x: usize, y: usize, w: usize, h: usize) { + unsafe { + if CELLS.is_null() { + return; + } + let (cols, rows) = (COLS, ROWS); + let c0 = x / 8; + let c1 = (x + w).div_ceil(8).min(cols); + let r0 = y / 16; + let r1 = (y + h).div_ceil(16).min(rows); + let cells = &*CELLS; + for r in r0..r1 { + for c in c0..c1 { + let cell = cells[r * cols + c]; + let fg = PALETTE[cell.fg as usize]; + let bg = PALETTE[cell.bg as usize]; + crate::gop::shadow_glyph_px(c * 8, r * 16, cell.ch, fg, bg); + } + } + } +} + /// DEBUG (crash-family): read one cell's raw word (ch | fg<<16 | bg<<24) /// from the live cells grid and the rendered grid, for the given text /// row/col. Returns (raw_cell, raw_rendered). -- cgit v1.2.3