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 floating(cx: &Cx, window: FloatingWindow) -> Window

Builds window under a new child owner of cx, as Window::new does for a panel.

Source

pub fn floating_config(&self) -> Option<FloatingConfig>

A floating window’s settings; None for a panel or popup. Read them only after the first flush, as surface.

Source

pub fn request_close(&self)

The user or compositor asked this floating window to close: its on_close runs, or without one it hides.

Source

pub fn take_requests(&self) -> Vec<WindowRequest>

Takes what the window’s widgets asked of it since the last call.

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. Without one, the innermost scroll view under the pointer scrolls.

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 keyboard_enter(&self)

The keyboard entered the window: its focused button shows its focus style again.

Source

pub fn keyboard_leave(&self)

The keyboard left the window. The focused button stays focused for when it comes back.

Source

pub fn key(&self, event: &KeyEvent) -> Option<Clipboard>

A key was pressed or repeated. A focused text field edits with it first. Then the focused button’s on_key gets it, then the window’s; a handler returns true when it used the key. Otherwise Tab and Shift+Tab move the focus between buttons and fields, and Enter or Space clicks the focused button.

Returns what the platform should do with the clipboard: copy a field’s selection on Ctrl+C or Ctrl+X, or paste into the focused field with paste on Ctrl+V.

Source

pub fn focused(&self) -> Option<String>

The path of the focused button, for tests and logs.

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 placement(&self) -> Placement

Where this popup goes, as its config set it; the defaults for a panel.

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 captures(&self) -> Vec<CaptureRequest>

The views to capture for, in the order they were built: those with a source and a box that isn’t empty at the last layout.

Source

pub fn show_capture(&self, id: u64, frame: CaptureFrame) -> bool

Shows frame in view id, repainting only that view, and returns whether it did. A frame the same as the one shown repaints nothing, so a live view of its own output settles. A view no longer in the window is ignored.

Source§

impl Window

Source

pub fn field(&self) -> Option<FieldState>

The focused text field, while the window has the keyboard, for an input method. Never a password: input methods learn what is typed.

Source

pub fn commit_text(&self, text: &str)

Inserts text from an input method at the focused field’s caret, replacing its selection. A password field takes nothing.

Source

pub fn paste(&self, text: &str)

Pastes text from the clipboard into the focused field, replacing its selection; line breaks become spaces. Unlike an input method’s text, a paste goes into a password field too.

Source

pub fn delete_around(&self, before: usize, after: usize)

Deletes before bytes before the focused field’s selection, or its caret, and after bytes after it, for an input method; the selection itself stays. Lengths that would split a character are ignored.

Source

pub fn set_preedit(&self, preedit: Option<Preedit>)

Shows preedit at the focused field’s caret, replacing its selection, or clears it. A password field shows none.

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 blur(&self) -> Option<Region>

The region a panel or floating window asks the compositor to blur behind, as its blur property says.

Source

pub fn inhibits_idle(&self) -> bool

Whether a panel or floating window asks to keep the screen from idling, as its inhibit_idle property says.

Source

pub fn inhibits_shortcuts(&self) -> bool

Whether a panel or floating window asks for the compositor’s shortcuts while it has the keyboard, as its inhibit_shortcuts property says.

Source

pub fn shortcuts_inhibited(&self) -> Option<Signal<bool>>

The signal a panel or floating window was given with shortcuts_inhibited, which the platform writes.

Source

pub fn focus_grab(&self) -> Option<Signal<bool>>

The signal a panel or floating window was given with focus_grab: windows given the same one share a grab.

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