From 09a44f15678f27dd3d07f90e9ed0e71cf0e771ff Mon Sep 17 00:00:00 2001 From: salmonik Date: Wed, 19 Aug 2026 18:46:35 +0200 Subject: wm: integrate home terminal as window 0 + fix console focus after close - wm rewrite: chrome flag per window, create_home_window for the console (window 0, chrome-less, bottom-pinned, never closed), composite_rect fills desktop background then blits windows bottom-to-top, draw_window_intersect handles chrome-less windows, hit_test returns Content for chrome-less, destroy/move_window no-op for id 0. - vt: add window_params() so main.rs can wire the Terminal to wm window 0. - main.rs: create home terminal window 0 and attach Terminal after wm::init(). - Focus fix: focus(0) now stores CONSOLE sentinel (not raw 0) so focused() returns None when the home terminal has focus. Without this, closing a GUI window left FOCUSED=0, which tty::poll_key() interpreted as 'a GUI app has focus', spinning forever and swallowing all keyboard input. --- rsnix/src/vt.rs | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'rsnix/src/vt.rs') diff --git a/rsnix/src/vt.rs b/rsnix/src/vt.rs index 90264f6..12e2cdc 100644 --- a/rsnix/src/vt.rs +++ b/rsnix/src/vt.rs @@ -80,6 +80,7 @@ pub struct Terminal { cur: usize, pending_scrolls: usize, last_sync_tick: u64, + dirty_all: bool, buffer: Vec, w: usize, h: usize, @@ -128,6 +129,7 @@ impl Terminal { cur: 0, pending_scrolls: 0, last_sync_tick: 0, + dirty_all: true, buffer: vec![0; w * h], w, h, @@ -140,6 +142,11 @@ impl Terminal { self.window_id = Some(id); } + /// Buffer pointer and pixel dimensions (for the WM to composite). + pub fn window_params(&self) -> (*const u32, usize, usize) { + (self.buffer.as_ptr(), self.w, self.h) + } + pub fn ready(&self) -> bool { self.rows != 0 } @@ -193,6 +200,7 @@ impl Terminal { } self.pending_scrolls = 0; self.last_sync_tick = crate::interrupts::TICKS.load(core::sync::atomic::Ordering::Relaxed); + self.dirty_all = true; self.flush(); } @@ -509,7 +517,12 @@ impl Terminal { let n = rows * cols; let cursor_visible = self.cursor_visible; let (cr, cc) = (self.cursor_r, self.cursor_c); - let mut dirty: Option<(usize, usize, usize, usize)> = None; + let mut dirty = if self.dirty_all { + self.dirty_all = false; + Some((0, 0, self.w, self.h)) + } else { + None + }; // Diff cells vs rendered, re-blitting changed cells into the buffer. for i in 0..n { -- cgit v1.2.3