feat(desktop): home app (system-only launch cap, LAUNCH_BADGE: apps+launch only), pm starts it with session (relaunch <=5); display keys F1/Alt+Tab next, F2 home, F4 close app (ROLE from launcher, terminal exempt), close returns to previous window; closed window -> app exits; shell 'name &'; launch by id; pm stack 8, storage 16 clients
This commit is contained in:
@@ -37,6 +37,12 @@ pub fn set_accent(window: CapSlot, rgb: u32) -> bool {
|
||||
syscall::request(window, [w::ACCENT, rgb as usize, 0, 0]).is_ok_and(|r| r[0] == w::OK)
|
||||
}
|
||||
|
||||
/// A launcher says what the window it opened is (`window::role`), before
|
||||
/// the app runs; whether the display took it.
|
||||
pub fn set_role(window: CapSlot, role: usize) -> bool {
|
||||
syscall::request(window, [w::ROLE, role, 0, 0]).is_ok_and(|r| r[0] == w::OK)
|
||||
}
|
||||
|
||||
/// Closes `window`: every copy of it, and its buffer, stop working.
|
||||
pub fn close(window: CapSlot) {
|
||||
let _ = syscall::request(window, [w::CLOSE, 0, 0, 0]);
|
||||
@@ -62,15 +68,20 @@ pub enum Event {
|
||||
Input(crate::input::InputEvent),
|
||||
/// Ask for the theme again (`theme`).
|
||||
ThemeChanged,
|
||||
/// The window is gone (the user closed it, or the display went):
|
||||
/// the app is done.
|
||||
Closed,
|
||||
}
|
||||
|
||||
/// `window`'s next event, if one is waiting; ones not known here are
|
||||
/// skipped.
|
||||
pub fn poll(window: CapSlot) -> Option<Event> {
|
||||
loop {
|
||||
let words = syscall::request(window, [w::POLL, 0, 0, 0]).ok()?;
|
||||
let Ok(words) = syscall::request(window, [w::POLL, 0, 0, 0]) else { return Some(Event::Closed) };
|
||||
match words[0] {
|
||||
0 => return None,
|
||||
// What the display answers through a window it has closed.
|
||||
usize::MAX => return Some(Event::Closed),
|
||||
w::THEME_CHANGED => return Some(Event::ThemeChanged),
|
||||
_ => {
|
||||
if let Some(e) = crate::input::decode(words) {
|
||||
@@ -81,11 +92,14 @@ pub fn poll(window: CapSlot) -> Option<Event> {
|
||||
}
|
||||
}
|
||||
|
||||
/// `window`'s next input event, if one is waiting.
|
||||
/// `window`'s next input event, if one is waiting. A program whose window
|
||||
/// is gone exits here.
|
||||
pub fn poll_input(window: CapSlot) -> Option<crate::input::InputEvent> {
|
||||
loop {
|
||||
if let Event::Input(e) = poll(window)? {
|
||||
return Some(e);
|
||||
match poll(window)? {
|
||||
Event::Input(e) => return Some(e),
|
||||
Event::Closed => syscall::exit(),
|
||||
Event::ThemeChanged => {}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user