Skip to main content

Window

Struct Window 

Source
pub struct Window { /* private fields */ }
Expand description

A live window: the tree of nodes built from a PanelWindow.

The platform owns one per layer surface. Each event-loop iteration it runs the reactive flush, then calls layout if needs_layout, then draws take_damage from view. When nothing changed, there is nothing to lay out or draw.

Dropping the window disposes its owner, which frees every node, binding and handler in it.

Implementations§

Source§

impl Window

Source

pub fn pointer_motion(&self, position: Point) -> CursorShape

The pointer entered the window or moved, to position in logical pixels. Returns the cursor to show.

Source

pub fn pointer_leave(&self)

The pointer left the window.

Source

pub fn pointer_button(&self, button: PointerButton, pressed: bool)

A pointer button went down or up. Releasing it over the button it went down on runs that button’s on_click, on_right_click or on_middle_click.

Source

pub fn pointer_scroll(&self, delta: ScrollDelta)

The pointer scrolled. Once whole steps add up, the on_scroll of the button under the pointer runs with them.

Source

pub fn pointer_scroll_end(&self)

A touchpad scroll gesture ended (wl_pointer.axis_stop): scrolling that hasn’t added up to a whole step is dropped, so it doesn’t carry into the next gesture. A wheel’s partial notch is kept.

Source

pub fn cursor(&self) -> CursorShape

The cursor to show.

Source§

impl Window

Source

pub fn take_popups(&self) -> Vec<Window>

Takes the popups this window’s widgets opened since the last call.

Source

pub fn anchor(&self) -> Option<Rect>

For a popup, the rectangle of the widget that opened it, at its window’s last layout, in that window’s logical pixels. The platform places the popup next to it. None for a panel, once the widget is gone, or before its first layout.

Source

pub fn is_popup(&self) -> bool

Whether this window is a popup.

Source

pub fn wants_close(&self) -> bool

Whether this popup should close: Cx::close_popup asked, or the widget that opened it is gone. Always false for a panel.

Source§

impl Window

Source

pub fn new(cx: &Cx, panel: PanelWindow) -> Window

Builds panel under a new child owner of cx.

Properties set to values take effect now. Bindings are effects, so they first run at the next Runtime::flush; run it before the first layout.

Source

pub fn output(&self) -> Output

The output the window is on.

Source

pub fn surface(&self) -> SurfaceConfig

The layer-surface settings. Read them only after the first Runtime::flush: settings given as closures are bindings, which first run then, and until they do these are the defaults.

Source

pub fn take_surface_changed(&self) -> bool

Whether the settings in surface changed since the last call. The first call returns true, even before the first flush, when surface still holds the defaults.

Source

pub fn size(&self) -> Size

The window’s size in logical pixels: the size the compositor gave a panel, or the size a popup’s content wants, from its last layout.

Source

pub fn set_size(&self, size: Size)

Sets the size the compositor gave the window, from a configure event. A new size needs a layout.

Source

pub fn needs_layout(&self) -> bool

Whether something changed that needs layout.

Source

pub fn layout(&self, text: &mut TextSystem)

Lays the window out at its size, measuring text with text, and records the areas that moved or changed as damage.

Source

pub fn has_damage(&self) -> bool

Whether any area needs repainting.

Source

pub fn take_damage(&self) -> Vec<Rect>

Takes the areas to repaint since the last call, in logical pixels. They may overlap.

Source

pub fn view(&self) -> WindowView<'_>

A read-only view of the laid-out tree, for drawing. Release it before the next flush or pointer event.

Trait Implementations§

Source§

impl Drop for Window

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more

Auto Trait Implementations§

§

impl !RefUnwindSafe for Window

§

impl !Send for Window

§

impl !Sync for Window

§

impl !UnwindSafe for Window

§

impl Forget for Window

§

impl Freeze for Window

§

impl Move for Window

§

impl Unpin for Window

§

impl UnsafeUnpin for Window

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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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