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 repaint_image(&self, id: u64) -> bool

Repaints the box of image id, as when the renderer says a GIF’s next frame is due, and returns whether it did. An image in another window, removed, hidden or not laid out yet repaints nothing.

Source§

impl Window

Source

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

The pointer entered the window or moved, to position in logical pixels, now. See pointer_motion_at.

Source

pub fn pointer_motion_at(&self, position: Point, time: u32) -> CursorShape

The pointer moved to position at time, in milliseconds as wl_pointer.motion counts them, which a drag’s fling is timed by. A held left button that moved far enough drags: its button’s, or else a scroll view’s child. Returns the cursor to show.

Source

pub fn pointer_leave(&self)

The pointer left the window, or a touch was cancelled. A drag ends with its End, and a held button never clicks.

Source

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

A pointer button went down or up, now. See pointer_button_at.

Source

pub fn pointer_button_at(&self, button: PointerButton, pressed: bool, time: u32)

A pointer button went down or up at time, in milliseconds as wl_pointer.button counts them, which double clicks are timed by. Releasing the left button runs on_release of the button it went down on, then ends its drag, or else, over that button still, runs its on_click or on_double_click. The other buttons run on_right_click, on_middle_click, on_back or on_forward when released over the button they went down on.

Source

pub fn pointer_scroll(&self, wheel: Wheel)

The pointer scrolled. A button under the pointer with on_wheel gets every event, and one with on_scroll the whole vertical steps as they add up. Without either, the innermost scroll view under the pointer that can still move that way scrolls along its axis. A touchpad takes it past an end, and a fling keeps it going after the fingers lift. A vertical stop drops a touchpad’s partial step, so it doesn’t carry into the next gesture; a wheel’s partial notch is kept.

Source

pub fn pointer_scroll_at(&self, wheel: Wheel, time: u32)

The pointer scrolled at time, in milliseconds as wl_pointer.axis counts them, which a touchpad’s fling is timed by. See pointer_scroll.

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 limit_size(&self, limit: Option<Size>)

For a popup, the size the compositor shrank it to, so it fits on its output, or None once it takes the size it wants. It is laid out and drawn no larger, its content cut off. Other windows ignore it.

Source

pub fn wanted_size(&self) -> Size

The size the window asks the compositor for: a popup’s content size at its last layout, before any limit; another window’s size.

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

The opacity the window asks the compositor to show it at, as its compositor_opacity property says: always from 0.0 to 1.0.

Source

pub fn visible_mask(&self) -> Option<Region>

The part of the window it tells the compositor holds anything to see, as its visible_mask property says; None is all of it.

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

Whether the settings changed since the last take_surface_changed, leaving that to tell.

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 within any limit, 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.

Then it writes each moved widget’s geometry signal, tells lists their rows’ sizes and runs the effects that follow, which may change the layout, and lays out again, until nothing moves or 8 layouts have run.

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