plat/pwin0.rs#
Source: lib/plat/pwin0.rs
pwin0 -- the single-window platform API on top of the window-indexed win_* functions
(window 0 = the main window), and the "current" window of the calls a UI pass makes
[src/plat/pwin0.s]
win_use(w) the window set_cursor / window_state / window_cmd /
begin_move / begin_resize refer to (-1 = none)
win_current() -> i32 that window
window_create(title, w_dip, h_dip, af_flags) -> bool window 0 (AF_* flags), shown
window_create_at(title, w_dip, h_dip, af_flags, x, y, maximized) -> bool the same at a
client origin (screen px; PW_DEFAULT: the system's), maximized
set_min_size(w_dip, h_dip) window 0 (before or after create)
window_size() -> (w, h) window 0, client pixels
dpi() -> i32 set_title(utf8) present(frame, rects) window 0
set_cursor(shape) window_state() -> WST_* window_cmd(cmd) begin_move()
begin_resize(edges) the current window
present_time() -> (frames, us) what showing frames cost so far (every window)
The OS layers (win_api.rs; linux_disp.rs -> Wayland / X11) implement the win_* calls.
fn present_time() -> (u64, u64)(frames handed to win_present, microseconds spent in the platform's present paths) since the start, all windows together: win_present itself plus the work it defers (X11: a segment that frees up, Wayland: the frame callback, the browser and Android: the composition and the hand-over to the host). For measurements (linuxtest --test pbench).fn present_account(t0: u64, frame: bool)add the time since t0 (time_us) to present_time; frame: a win_present call, or a frame the UI showed through the GPU insteadfn win_use(w: i32)the window the single-window per-window calls refer to (-1 = none)fn win_current() -> i32the window set by win_use (0 by default)fn window_create(title: &str, w_dip: i32, h_dip: i32, af: u32) -> boolthe main window (AF_CUSTOM_TITLEBAR: no system caption; AF_RESIZABLE), shown at oncefn window_create_at(title: &str, w_dip: i32, h_dip: i32, af: u32, x: i32, y: i32, maximized: bool) -> boolwindow_create with the client area's top left at x, y (screen px; PW_DEFAULT: where the system puts it) and maximized (its normal size w_dip x h_dip)fn set_min_size(w_dip: i32, h_dip: i32)minimum client size of the main window (DIP)fn window_size() -> (i32, i32)client pixels of the main windowfn dpi() -> i32dpi of the main window (96 = 100 %)fn set_title(title: &str)fn present(f: &Frame, rects: Option<&[[i32; 4]]>)show dirty rectangles (None = everything) of the main window's framebuffer; its pixels outside them must be what the last present showed (the backends keep whole frames up to date from it)fn set_cursor(shape: u32)CUR_* pointer shape of the current windowfn window_state() -> u32WST_* bits of the current windowfn window_cmd(cmd: u32)fn begin_move()let the system move the current window (on a button press)fn begin_resize(edges: u32)let the system resize the current window from an edge (EDGE_* bits)fn wait_refresh(deadline_us: u64, _refresh: &mut dyn FnMut()) -> u32wait(deadline) with a redraw closure for a modal move / size loop (Windows); the Linux backends have no modal loop: there it is wait() [main agent]