Skip to main content

WindowDesc

Struct WindowDesc 

Source
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 str

Title bar text. Also what the taskbar and window switcher show.

§app_id: &'a str

Application 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: LogicalSize

Requested 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: SizeConstraints

Resize limits and aspect lock; see SizeConstraints.

§mode: DisplayMode

Windowed 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: bool

Whether 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: bool

Whether 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: bool

Whether 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: bool

Whether 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.

§End to end

  1. The window. This flag, on a shell with TRANSPARENT. The shell hands it on in the window’s surface target (SurfaceTarget::transparent).
  2. The swapchain. crcbl::engine::GpuContext reads the target and asks for CompositeAlpha::PreMultiplied, and refuses the open (GpuError::Unusable) when no adapter’s surface offers it rather than drawing the window opaque. On Windows only the D3D12 backend can present it: Vulkan refuses the surface, and an open that named no backend moves on to D3D12, while one that named Vulkan fails with that refusal. A swapchain built by hand asks for premultiplied itself.
  3. The frame. Premultiplied colour, with alpha below one where the desktop should show. A forward renderer view with ViewBackground::Transparent clears to transparent black and writes its coverage as alpha beside straight colour. That is premultiplied output wherever the alpha is zero or one and an empty pixel holds no scattered light (a frame without volumetric fog); where the alpha is partial, such as water’s edge fade, it is not.

Trait Implementations§

Source§

impl<'a> Clone for WindowDesc<'a>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<'a> Copy for WindowDesc<'a>

Source§

impl<'a> Debug for WindowDesc<'a>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for WindowDesc<'_>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl<'a> Freeze for WindowDesc<'a>

§

impl<'a> RefUnwindSafe for WindowDesc<'a>

§

impl<'a> Send for WindowDesc<'a>

§

impl<'a> Sync for WindowDesc<'a>

§

impl<'a> Unpin for WindowDesc<'a>

§

impl<'a> UnsafeUnpin for WindowDesc<'a>

§

impl<'a> UnwindSafe for WindowDesc<'a>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.