Skip to main content

WindowOptions

Struct WindowOptions 

Source
pub struct WindowOptions {
Show 18 fields pub window_bounds: Option<WindowBounds>, pub titlebar: Option<TitlebarOptions>, pub focus: bool, pub show: bool, pub kind: WindowKind, pub is_movable: bool, pub app_owns_titlebar_drag: bool, pub inactive_frame_interval: Option<Duration>, pub is_resizable: bool, pub is_minimizable: bool, pub display_id: Option<DisplayId>, pub linux_window_background: LinuxWindowBackground, pub app_id: Option<String>, pub window_min_size: Option<Size<Pixels>>, pub window_decorations: Option<WindowDecorations>, pub icon: Option<Arc<RgbaImage>>, pub tabbing_identifier: Option<String>, pub use_display_p3: bool,
}
Expand description

Options for creating a window, passed to App::open_window.

Start from WindowOptions::default (or WindowOptions::new, which is the same) and chain setters for the fields you want to change. Each setter takes the value itself, or an Option to clear the field. The defaults give a focused, shown, resizable, movable normal window with a titlebar, at the platform’s default size and position.

Not every platform reads every field. The web backend uses WindowOptions::kind, WindowOptions::show, and web_window_background. The page’s canvas is the window, so bounds, the titlebar, the minimum size and the resize options are ignored. Each field’s docs say which platforms use it. See platforms.

§Examples

Start from the defaults and change only what you need:

use gpui::{Bounds, WindowBounds, WindowOptions, point, px, size};

let bounds = Bounds::new(point(px(100.), px(100.)), size(px(800.), px(600.)));
let options = WindowOptions::default()
    .window_bounds(WindowBounds::Windowed(bounds))
    .is_resizable(false)
    .titlebar(None);

assert_eq!(options.window_bounds, Some(WindowBounds::Windowed(bounds)));
assert!(!options.is_resizable);
assert!(options.titlebar.is_none());
assert!(options.focus);

Create a window that doesn’t take focus and opens hidden, so you can show it later:

use gpui::WindowOptions;

let options = WindowOptions::new().focus(false).show(false);

assert!(!options.focus);
assert!(!options.show);

Fields§

§window_bounds: Option<WindowBounds>

The window’s state and bounds in screen coordinates, in logical pixels.

None inherits the bounds from the platform, and Some opens the window in the given state. A Windowed window opens at the rectangle, and Maximized and Fullscreen restore to the rectangle when left. Ignored on the web.

§titlebar: Option<TitlebarOptions>

The titlebar, or None for a window without one. Ignored on the web.

The default is TitlebarOptions::default, which shows the platform’s titlebar with no title.

§focus: bool

Whether the window takes keyboard focus when it opens. Defaults to true.

§show: bool

Whether the window appears when it opens. Set it to false to show the window later with PlatformWindow::set_visible.

§kind: WindowKind

The kind of window to create. Defaults to WindowKind::Normal. On the web, only Normal works.

§is_movable: bool

Whether the user can drag the window. Defaults to true. macOS and Windows use this value. Linux and the web ignore it. Programmatic moves still work.

§app_owns_titlebar_drag: bool

Whether the application owns dragging of the (custom) titlebar, rather than AppKit. Only has an effect on macOS.

Set this to true for windows that draw their own titlebar and move the window themselves via Window::start_window_move. It marks the whole content view as app-owned titlebar content, so AppKit neither drags the window from the titlebar nor delays titlebar clicks while disambiguating double-clicks (a delay first observed on macOS 27). It is independent of is_movable, so such windows stay user-movable (via their own drag) and keep the Window-menu tiling items enabled.

Leave this false for windows that rely on AppKit’s native titlebar dragging.

§inactive_frame_interval: Option<Duration>

The minimum time between animation frames while the window is inactive.

Defaults to about 30 frames per second. Set None to draw inactive windows at the full frame rate.

§is_resizable: bool

Whether the user can resize the window. Defaults to true. Ignored on the web.

§is_minimizable: bool

Whether the user can minimize the window. Defaults to true. Ignored on the web.

§display_id: Option<DisplayId>

The display to open the window on, or None for the primary display. Ignored on the web.

§linux_window_background: LinuxWindowBackground

The background appearance of a Linux window.

§app_id: Option<String>

The application id that desktop environments use to group windows and find the desktop entry.

Linux only. Other platforms ignore it.

§window_min_size: Option<Size<Pixels>>

The smallest size the user can resize the window to, in logical pixels. None sets no minimum. Ignored on the web.

§window_decorations: Option<WindowDecorations>

Whether the window draws its own decorations (client-side) or the window server does (server-side).

None uses the server’s default. Linux’s Wayland and X11 backends honor it, and the other backends ignore it. The platform may ignore requests it can’t satisfy.

§icon: Option<Arc<RgbaImage>>

The window’s icon, from an RGBA image. Linux only, and Wayland needs the xdg-toplevel-icon protocol to show it.

§tabbing_identifier: Option<String>

The name of the native tab group. Windows with the same identifier open as tabs of one window. macOS only.

§use_display_p3: bool

Whether to render the window using the Display P3 color space on macOS.

Implementations§

Source§

impl WindowOptions

Source

pub fn window_bounds(self, value: impl Into<Option<WindowBounds>>) -> Self

Sets the window_bounds field of this struct.

Source

pub fn titlebar(self, value: impl Into<Option<TitlebarOptions>>) -> Self

Sets the titlebar field of this struct.

Source

pub fn focus(self, value: impl Into<bool>) -> Self

Sets the focus field of this struct.

Source

pub fn show(self, value: impl Into<bool>) -> Self

Sets the show field of this struct.

Source

pub fn kind(self, value: impl Into<WindowKind>) -> Self

Sets the kind field of this struct.

Source

pub fn is_movable(self, value: impl Into<bool>) -> Self

Sets the is_movable field of this struct.

Source

pub fn app_owns_titlebar_drag(self, value: impl Into<bool>) -> Self

Sets the app_owns_titlebar_drag field of this struct.

Source

pub fn inactive_frame_interval(self, value: impl Into<Option<Duration>>) -> Self

Sets the inactive_frame_interval field of this struct.

Source

pub fn is_resizable(self, value: impl Into<bool>) -> Self

Sets the is_resizable field of this struct.

Source

pub fn is_minimizable(self, value: impl Into<bool>) -> Self

Sets the is_minimizable field of this struct.

Source

pub fn display_id(self, value: impl Into<Option<DisplayId>>) -> Self

Sets the display_id field of this struct.

Source

pub fn linux_window_background( self, value: impl Into<LinuxWindowBackground>, ) -> Self

Sets the linux_window_background field of this struct.

Source

pub fn app_id(self, value: impl Into<Option<String>>) -> Self

Sets the app_id field of this struct.

Source

pub fn window_min_size(self, value: impl Into<Option<Size<Pixels>>>) -> Self

Sets the window_min_size field of this struct.

Source

pub fn window_decorations( self, value: impl Into<Option<WindowDecorations>>, ) -> Self

Sets the window_decorations field of this struct.

Source

pub fn icon(self, value: impl Into<Option<Arc<RgbaImage>>>) -> Self

Sets the icon field of this struct.

Source

pub fn tabbing_identifier(self, value: impl Into<Option<String>>) -> Self

Sets the tabbing_identifier field of this struct.

Source

pub fn use_display_p3(self, value: impl Into<bool>) -> Self

Sets the use_display_p3 field of this struct.

Source§

impl WindowOptions

Source

pub fn new() -> Self

Returns window options with the platform’s defaults: a focused, shown, resizable, minimizable, movable normal window with a titlebar.

Source

pub fn background_appearance(&self) -> WindowBackgroundAppearance

Returns the window’s background appearance for the current platform, erased into the renderer-facing WindowBackgroundAppearance.

Trait Implementations§

Source§

impl Debug for WindowOptions

Source§

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

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

impl Default for WindowOptions

Source§

fn default() -> Self

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

impl FluentBuilder for WindowOptions

Source§

fn map<U>(self, f: impl FnOnce(Self) -> U) -> U
where Self: Sized,

Passes self to f, and returns the result. Use it to continue a chain with a closure.
Source§

fn when(self, condition: bool, then: impl FnOnce(Self) -> Self) -> Self
where Self: Sized,

Calls then with self if condition is true. Otherwise returns self unchanged.
Source§

fn when_else( self, condition: bool, then: impl FnOnce(Self) -> Self, else_fn: impl FnOnce(Self) -> Self, ) -> Self
where Self: Sized,

Calls then with self if condition is true, and else_fn with self otherwise.
Source§

fn when_some<T>( self, option: Option<T>, then: impl FnOnce(Self, T) -> Self, ) -> Self
where Self: Sized,

Calls then with self and the value inside option if the option is Some. Returns self unchanged for None.
Source§

fn when_none<T>( self, option: &Option<T>, then: impl FnOnce(Self) -> Self, ) -> Self
where Self: Sized,

Calls then with self if option is None. The option is taken by reference, so you can still use it afterward.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<S, D, Swp, Dwp, T> AdaptInto<D, Swp, Dwp, T> for S
where T: Real + Zero + Arithmetics + Clone, Swp: WhitePoint<T>, Dwp: WhitePoint<T>, D: AdaptFrom<S, Swp, Dwp, T>,

Source§

fn adapt_into_using<M>(self, method: M) -> D
where M: TransformMatrix<T>,

👎Deprecated since 0.7.7:

replaced by palette::chromatic_adaptation::AdaptIntoUnclamped

Convert the source color to the destination color using the specified method.
Source§

fn adapt_into(self) -> D

👎Deprecated since 0.7.7:

replaced by palette::chromatic_adaptation::AdaptIntoUnclamped

Convert the source color to the destination color using the bradford method by default.
Source§

impl<T, C> AdaptIntoUnclamped<T> for C
where T: AdaptFromUnclamped<C>,

Source§

type Scalar = <T as AdaptFromUnclamped<C>>::Scalar

The number type that’s used as the color’s components.
Source§

fn adapt_into_unclamped_with<M>(self) -> T

Adapt a color of type Self into a color of type T, using the custom matrix M. Read more
Source§

fn adapt_into_unclamped(self) -> T
where Bradford: LmsToXyz<Self::Scalar> + XyzToLms<Self::Scalar>,

Adapt a color of type Self into a color of type T, using the Bradford matrix. Read more
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, C> ArraysFrom<C> for T
where C: IntoArrays<T>,

Source§

fn arrays_from(colors: C) -> T

Cast a collection of colors into a collection of arrays.
Source§

impl<T, C> ArraysInto<C> for T
where C: FromArrays<T>,

Source§

fn arrays_into(self) -> C

Cast this collection of arrays into a collection of colors.
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<WpParam, T, U> Cam16IntoUnclamped<WpParam, T> for U
where T: FromCam16Unclamped<WpParam, U>,

Source§

type Scalar = <T as FromCam16Unclamped<WpParam, U>>::Scalar

The number type that’s used in parameters when converting.
Source§

fn cam16_into_unclamped( self, parameters: BakedParameters<WpParam, <U as Cam16IntoUnclamped<WpParam, T>>::Scalar>, ) -> T

Converts self into C, using the provided parameters.
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T, C> ComponentsFrom<C> for T
where C: IntoComponents<T>,

Source§

fn components_from(colors: C) -> T

Cast a collection of colors into a collection of color components.
Source§

impl<T, C> ComponentsInto<C> for T

Source§

fn components_into(self) -> C

Cast this collection of color components into a collection of colors. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> FromAngle<T> for T

Source§

fn from_angle(angle: T) -> T

Performs a conversion from angle.
Source§

impl<T, U> FromStimulus<U> for T
where U: IntoStimulus<T>,

Source§

fn from_stimulus(other: U) -> T

Converts other into Self, while performing the appropriate scaling, rounding and clamping.
Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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, U> IntoAngle<U> for T
where U: FromAngle<T>,

Source§

fn into_angle(self) -> U

Performs a conversion into T.
Source§

impl<WpParam, T, U> IntoCam16Unclamped<WpParam, T> for U
where T: Cam16FromUnclamped<WpParam, U>,

Source§

type Scalar = <T as Cam16FromUnclamped<WpParam, U>>::Scalar

The number type that’s used in parameters when converting.
Source§

fn into_cam16_unclamped( self, parameters: BakedParameters<WpParam, <U as IntoCam16Unclamped<WpParam, T>>::Scalar>, ) -> T

Converts self into C, using the provided parameters.
Source§

impl<T, U> IntoColor<U> for T
where U: FromColor<T>,

Source§

fn into_color(self) -> U

Convert into T with values clamped to the color defined bounds Read more
Source§

impl<T, U> IntoColorUnclamped<U> for T
where U: FromColorUnclamped<T>,

Source§

fn into_color_unclamped(self) -> U

Convert into T. The resulting color might be invalid in its color space Read more
Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> IntoStimulus<T> for T

Source§

fn into_stimulus(self) -> T

Converts self into T, while performing the appropriate scaling, rounding and clamping.
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<R, P> ReadPrimitive<R> for P
where R: Read + ReadEndian<P>, P: Default,

Source§

fn read_from_little_endian(read: &mut R) -> Result<Self, Error>

Read this value from the supplied reader. Same as ReadEndian::read_from_little_endian().
Source§

fn read_from_big_endian(read: &mut R) -> Result<Self, Error>

Read this value from the supplied reader. Same as ReadEndian::read_from_big_endian().
Source§

fn read_from_native_endian(read: &mut R) -> Result<Self, Error>

Read this value from the supplied reader. Same as ReadEndian::read_from_native_endian().
Source§

impl<T, C> TryComponentsInto<C> for T
where C: TryFromComponents<T>,

Source§

type Error = <C as TryFromComponents<T>>::Error

The error for when try_into_colors fails to cast.
Source§

fn try_components_into(self) -> Result<C, <T as TryComponentsInto<C>>::Error>

Try to cast this collection of color components into a collection of colors. 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.
Source§

impl<T, U> TryIntoColor<U> for T
where U: TryFromColor<T>,

Source§

fn try_into_color(self) -> Result<U, OutOfBounds<U>>

Convert into T, returning ok if the color is inside of its defined range, otherwise an OutOfBounds error is returned which contains the unclamped color. Read more
Source§

impl<C, U> UintsFrom<C> for U
where C: IntoUints<U>,

Source§

fn uints_from(colors: C) -> U

Cast a collection of colors into a collection of unsigned integers.
Source§

impl<C, U> UintsInto<C> for U
where C: FromUints<U>,

Source§

fn uints_into(self) -> C

Cast this collection of unsigned integers into a collection of colors.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more