From ba304898b8e177d90afb58d201b4c3dd3c927c48 Mon Sep 17 00:00:00 2001 From: salmonik Date: Thu, 27 Aug 2026 17:23:34 +0200 Subject: GUI: window/event exports, paint binary, event-loop gate MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit rsapi: WmEvent (kind=u8 enum: 0=key, 1=mouse, 2=focus, 3=close), WmKeyKind (Char/Enter/Backspace/F1-F4/…), WmMouseEvent (x/y/buttons), WindowInfo (ptr/w/h). Five new exports: wm_create, wm_buffer, wm_flush, wm_destroy, wm_recv (non-blocking TaskMsg dispatch → WmEvent). Shell: abi_wm_* wrappers bridge rsapi types to rsnix::wm and sched::recv(); wm_recv translates TaskMsg::Key/Mouse/Focus/Close into flat WmEvent union. bins/paint: gate binary — create_window + buffer + event loop with Bresenham line drawing, color select (1-8), clear (c), F4 close. All via wm_* ABI exports. Fully migrated: date, mem, pci, cat, ls, mkdir, touch, rm, klog, info, paint (11 external binaries in /bin/cli/ + 3 gate binaries). --- rsapi/src/lib.rs | 72 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) (limited to 'rsapi') diff --git a/rsapi/src/lib.rs b/rsapi/src/lib.rs index dfe75d6..e5f2119 100644 --- a/rsapi/src/lib.rs +++ b/rsapi/src/lib.rs @@ -105,6 +105,66 @@ pub struct PciDevice { pub device_id: u16, } +// ---- GUI types (v2 window/event) ---- + +/// Window buffer info returned by wm_buffer. +#[repr(C)] +#[derive(Clone, Copy)] +pub struct WindowInfo { + pub ptr: *mut u32, + pub w: u32, + pub h: u32, +} + +/// Key event kind (flattened for ABI stability). +#[repr(u8)] +#[derive(Clone, Copy, PartialEq, Eq)] +pub enum WmKeyKind { + Char = 0, + Enter = 1, + Backspace = 2, + Tab = 3, + Escape = 4, + CtrlC = 5, + ArrowUp = 10, + ArrowDown = 11, + ArrowLeft = 12, + ArrowRight = 13, + Home = 14, + End = 15, + PageUp = 16, + PageDown = 17, + Delete = 18, + F1 = 20, + F2 = 21, + F3 = 22, + F4 = 23, + Unknown = 255, +} + +/// Mouse button state. +#[repr(C)] +#[derive(Clone, Copy)] +pub struct WmMouseEvent { + pub x: i32, + pub y: i32, + pub buttons: u8, +} + +/// One window manager event delivered to a GUI binary. +#[repr(C)] +#[derive(Clone, Copy)] +pub struct WmEvent { + pub kind: u8, // 0=key, 1=mouse, 2=focus, 3=close + pub key_kind: WmKeyKind, + pub key_char: u8, + pub mouse: WmMouseEvent, + pub focused: bool, + pub _pad: [u8; 4], +} + + + /// Kernel version information. #[derive(Clone, Copy)] pub struct KernelVersion { @@ -167,4 +227,16 @@ pub struct Exports { pub klog_dump: fn(buf: *mut u8, cap: u64) -> u64, /// Fill `out` with kernel version info. pub kernel_version: fn(out: &mut KernelVersion), + + // ---- window/events (v2 GUI) ---- + /// Create a window; returns window id or -1. + pub wm_create: fn(title: Line, w: u32, h: u32) -> i32, + /// Get the window's pixel buffer info. + pub wm_buffer: fn(id: i32, out: &mut WindowInfo) -> bool, + /// Composite the window to screen. + pub wm_flush: fn(id: i32), + /// Destroy a window. + pub wm_destroy: fn(id: i32), + /// Non-blocking: receive one event. Returns true if an event was delivered. + pub wm_recv: fn(out: &mut WmEvent) -> bool, } -- cgit v1.2.3