pub struct WindowDesc<'a> {
pub title: &'a str,
pub app_id: &'a str,
pub size: LogicalSize,
pub constraints: SizeConstraints,
pub mode: DisplayMode,
pub resizable: bool,
pub visible: bool,
pub accept_drops: bool,
pub role: WindowRole<'a>,
pub transparent: bool,
}Expand description
Everything needed to create a window.
POD apart from the borrowed title, and Copy-free only because of it. The
lifetime is deliberate: a shell never needs to own the string past the call,
and forcing a String on every caller would allocate on a path that runs
once.
Fields§
§title: &'a strTitle bar text. Also what the taskbar and window switcher show.
app_id: &'a strApplication identifier, e.g. "sh.kryptic.crcbl.sandbox".
Wayland’s xdg_toplevel.set_app_id and X11’s WM_CLASS. This is how a
desktop environment matches a window to its .desktop file for the icon
and the taskbar grouping, and getting it wrong is why some applications
show a generic gear icon. There is no useful default, so it is
required.
size: LogicalSizeRequested client-area size, in logical units.
A request, not a demand — a tiling window manager will size the window
however it likes and the first
ShellEvent::Resized is the authority.
Never size a swapchain from this field.
constraints: SizeConstraintsResize limits and aspect lock; see SizeConstraints.
mode: DisplayModeWindowed or borderless at creation.
Setting it here rather than creating windowed and immediately switching avoids a visible flash of a decorated window, which is what every engine that gets this wrong looks like on startup.
resizable: boolWhether the window is resizable at all.
Distinct from min == max in SizeConstraints: this also removes the
maximize button and the resize handles, which is a different visual
result even where the enforced size is identical.
visible: boolWhether to map the window immediately.
false creates it hidden, so the first frame can be rendered before
anything is shown — the fix for the black-window flash on startup.
Reveal it with
set_visible once there is something to
look at.
accept_drops: boolWhether files dropped on the window should produce
ShellEvent::DroppedFile.
Off by default because accepting a drop means advertising it to the window system, and a game that ignores drops should not show a drop cursor.
role: WindowRole<'a>What kind of window: an application window, a panel or a popup. See
WindowRole.
transparent: boolWhether the desktop shows through where the frame’s alpha is below one: a bar with no background, a launcher with rounded corners.
Asked for at creation because every window system decides it then —
the visual, the swapchain, the window’s own background. A backend that
cannot do it refuses the window
(ShellCaps::TRANSPARENT) rather
than draw it opaque. The frame’s alpha is premultiplied.