Expand description
Windows as data: what a frame declares about the OS windows it wants, and the commands a frame driver applies to the real ones.
You meet this module in three places. WindowConfig is what
Ui::window / Core::declare_window take to say that a named window
exists this frame; NodeSpec::window_drag and NodeSpec::window_button
make a node part of the window chrome; and a driver drains the resulting
WindowCommands with Core::take_window_commands and applies them.
The core never touches a window itself, so a headless driver simply
never drains. Facts about the host window flow back in through
WindowEnv on Env.
use kui_core::{Rect, WindowCommand, WindowConfig, WindowId, WindowKind};
// A second window, opened on the first frame that declares it.
let palette = WindowConfig::sized(320.0, 480.0);
assert_eq!(palette.kind, WindowKind::Normal);
// A dropdown surface anchored to a field's rect; it does not take focus.
let field = Rect::new(20.0, 40.0, 200.0, 24.0);
let menu = WindowConfig::popup(field, 200.0, 160.0);
assert_eq!(menu.kind, WindowKind::Popup);
assert!(!menu.activates);
// What a driver does with the commands it drains.
fn apply(cmd: WindowCommand) {
match cmd {
WindowCommand::Open { id, config, .. } => println!("open {id:?} at {:?}", config.size),
WindowCommand::Close(WindowId::MAIN) => println!("exit"),
WindowCommand::Close(id) => println!("close {id:?}"),
WindowCommand::SetSize { window, size } => println!("resize {window:?} to {size:?}"),
other => println!("{}", other.kind_name()),
}
}
apply(WindowCommand::Close(WindowId::MAIN));Structs§
- Window
Config - What a frame says about a window it declares (
Ui::window,Core::declare_window). Plain data, no title and no callbacks, so aWindowCommandstaysCopyand two declarations of one name compare by value. - Window
Env - What the host knows about its window, pushed into
Envby the frame driver. Views (e.g.widgets::titlebar) read this to adapt: reserve space for native controls, pick the maximize/restore glyph, or render nothing at all under native decorations. - Window
Id - Which OS window something belongs to: an opaque integer the core
assigns when it opens a window, not a handle an app builds.
WindowId::MAINis 0, the window the launcher opens, which is always live. Apps name windows with a stable string (Core::declare_window); the id is how the driver andUiEvent::windowrefer to the surface that string opened.
Enums§
- Backdrop
- What shows through a window where its frame paints nothing, or paints with alpha (backlog F126): named for the effect, not for where an app uses it. The app decides which regions show it — a sidebar, a toolbar — by painting them with alpha and the rest opaque; kui knows nothing of sidebars.
- Dismiss
Reason - Why a window was asked to go away (
Core::dismiss_window): the same two reasons amodalnode has, one level up. - Window
Button - Window
Command - A window-level intent for the frame driver, drained with
Core::take_window_commandsafter each input dispatch and each frame. Three things produce one: input on a chrome node, the diff of the declared window set, and an app asking directly (Core::set_window_size,Core::focus_window,Core::push_window_command). A headless driver never drains. - Window
Kind - What kind of OS surface a declared window is.
- Window
Role - Role a node plays in window chrome (set via
NodeSpec::window_drag/NodeSpec::window_button). Chrome nodes never emitUiEvents — their interactions becomeWindowCommands for the driver instead.