raise window owner
Intrepid/Prometeu/Runtime/pipeline/head This commit looks good

This commit is contained in:
2026-05-15 11:26:41 +01:00
parent 1663ab5413
commit a8e3040d1e
13 changed files with 107 additions and 40 deletions
@@ -3,4 +3,4 @@ pub mod memcard;
pub mod process;
pub mod task;
pub mod vm_runtime;
pub mod window_manager;
pub mod windows;
@@ -0,0 +1,8 @@
mod window;
mod window_manager;
mod window_owner;
pub use window::Window;
pub use window::WindowId;
pub use window_manager::WindowManager;
pub use window_owner::WindowOwner;
@@ -0,0 +1,16 @@
use crate::windows::WindowOwner;
use prometeu_hal::color::Color;
use prometeu_hal::primitives::Rect;
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub struct WindowId(pub u32);
#[derive(Debug, Clone)]
pub struct Window {
pub id: WindowId,
pub owner: WindowOwner,
pub viewport: Rect,
pub has_focus: bool,
pub title: String,
pub color: Color,
}
@@ -1,5 +1,7 @@
use crate::services::windows::window::{Window, WindowId};
use crate::windows::WindowOwner;
use prometeu_hal::color::Color;
use prometeu_hal::window::{Rect, Window, WindowId};
use prometeu_hal::primitives::Rect;
/// PROMETEU Window Manager.
pub struct WindowManager {
@@ -7,14 +9,26 @@ pub struct WindowManager {
pub focused: Option<WindowId>,
}
impl Default for WindowManager {
fn default() -> Self {
Self::new()
}
}
impl WindowManager {
pub fn new() -> Self {
Self { windows: Vec::new(), focused: None }
}
pub fn add_window(&mut self, title: String, viewport: Rect, color: Color) -> WindowId {
pub fn add_window(
&mut self,
title: String,
owner: WindowOwner,
viewport: Rect,
color: Color,
) -> WindowId {
let id = WindowId(self.windows.len() as u32);
let window = Window { id, viewport, has_focus: false, title, color };
let window = Window { id, owner, viewport, has_focus: false, title, color };
self.windows.push(window);
id
}
@@ -46,10 +60,15 @@ mod tests {
#[test]
fn test_window_manager_focus() {
let mut wm = WindowManager::new();
let id1 =
wm.add_window("Window 1".to_string(), Rect { x: 0, y: 0, w: 10, h: 10 }, Color::WHITE);
let id1 = wm.add_window(
"Window 1".to_string(),
WindowOwner::Hub,
Rect { x: 0, y: 0, w: 10, h: 10 },
Color::WHITE,
);
let id2 = wm.add_window(
"Window 2".to_string(),
WindowOwner::Hub,
Rect { x: 10, y: 10, w: 10, h: 10 },
Color::WHITE,
);
@@ -71,8 +90,12 @@ mod tests {
#[test]
fn test_window_manager_remove_window() {
let mut wm = WindowManager::new();
let id =
wm.add_window("Window".to_string(), Rect { x: 0, y: 0, w: 10, h: 10 }, Color::WHITE);
let id = wm.add_window(
"Window".to_string(),
WindowOwner::Hub,
Rect { x: 0, y: 0, w: 10, h: 10 },
Color::WHITE,
);
wm.set_focus(id);
assert_eq!(wm.focused, Some(id));
@@ -0,0 +1,21 @@
use crate::task::TaskId;
/// Identifies the logical owner of a shell window.
///
/// Game cartridges do not currently own WindowManager windows. Games run as
/// fullscreen firmware steps. The WindowManager is used for Hub/Home UI,
/// Shell task windows, and system overlays.
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum WindowOwner {
/// Window owned by the Prometeu Hub/Home.
Hub,
/// Window owned by a managed Shell task.
Task(TaskId),
/// Temporary system-owned window drawn above the current context.
///
/// Examples: notifications, crash dialogs, quick menus, debug panels,
/// permission prompts, and modal confirmations.
Overlay,
}