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
impl Window
Sourcepub fn floating(cx: &Cx, window: FloatingWindow) -> Window
pub fn floating(cx: &Cx, window: FloatingWindow) -> Window
Builds window under a new child owner of cx, as
Window::new does for a panel.
Sourcepub fn floating_config(&self) -> Option<FloatingConfig>
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.
Sourcepub fn request_close(&self)
pub fn request_close(&self)
The user or compositor asked this floating window to close: its
on_close runs, or without one it hides.
Sourcepub fn take_requests(&self) -> Vec<WindowRequest>
pub fn take_requests(&self) -> Vec<WindowRequest>
Takes what the window’s widgets asked of it since the last call.
Source§impl Window
impl Window
Sourcepub fn pointer_motion(&self, position: Point) -> CursorShape
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.
Sourcepub fn pointer_leave(&self)
pub fn pointer_leave(&self)
The pointer left the window.
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.
Sourcepub fn pointer_scroll(&self, delta: ScrollDelta)
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.
Sourcepub fn pointer_scroll_end(&self)
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.
Sourcepub fn cursor(&self) -> CursorShape
pub fn cursor(&self) -> CursorShape
The cursor to show.
Source§impl Window
impl Window
Sourcepub fn keyboard_enter(&self)
pub fn keyboard_enter(&self)
The keyboard entered the window: its focused button shows its focus style again.
Sourcepub fn keyboard_leave(&self)
pub fn keyboard_leave(&self)
The keyboard left the window. The focused button stays focused for when it comes back.
Sourcepub fn key(&self, event: &KeyEvent) -> Option<Clipboard>
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§impl Window
impl Window
Sourcepub fn take_popups(&self) -> Vec<Window>
pub fn take_popups(&self) -> Vec<Window>
Takes the popups this window’s widgets opened since the last call.
Sourcepub fn anchor(&self) -> Option<Rect>
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.
Sourcepub fn placement(&self) -> Placement
pub fn placement(&self) -> Placement
Where this popup goes, as its config set it; the defaults for a panel.
Sourcepub fn limit_size(&self, limit: Option<Size>)
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.
Sourcepub fn wanted_size(&self) -> Size
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.
Sourcepub fn wants_close(&self) -> bool
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
impl Window
Sourcepub fn captures(&self) -> Vec<CaptureRequest>
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.
Sourcepub fn show_capture(&self, id: u64, frame: CaptureFrame) -> bool
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
impl Window
Sourcepub fn field(&self) -> Option<FieldState>
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.
Sourcepub fn commit_text(&self, text: &str)
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.
Sourcepub fn paste(&self, text: &str)
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.
Sourcepub fn delete_around(&self, before: usize, after: usize)
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.
Sourcepub fn set_preedit(&self, preedit: Option<Preedit>)
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
impl Window
Sourcepub fn new(cx: &Cx, panel: PanelWindow) -> Window
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.
Sourcepub fn surface(&self) -> SurfaceConfig
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.
Sourcepub fn blur(&self) -> Option<Region>
pub fn blur(&self) -> Option<Region>
The region a panel or floating window asks the compositor to blur
behind, as its blur property says.
Sourcepub fn inhibits_idle(&self) -> bool
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.
Sourcepub fn inhibits_shortcuts(&self) -> bool
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.
Sourcepub fn shortcuts_inhibited(&self) -> Option<Signal<bool>>
pub fn shortcuts_inhibited(&self) -> Option<Signal<bool>>
The signal a panel or floating window was given with
shortcuts_inhibited, which the platform writes.
Sourcepub fn focus_grab(&self) -> Option<Signal<bool>>
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.
Sourcepub fn compositor_opacity(&self) -> f32
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.
Sourcepub fn visible_mask(&self) -> Option<Region>
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.
Sourcepub fn take_surface_changed(&self) -> bool
pub fn take_surface_changed(&self) -> bool
Sourcepub fn size(&self) -> Size
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.
Sourcepub fn set_size(&self, size: Size)
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.
Sourcepub fn needs_layout(&self) -> bool
pub fn needs_layout(&self) -> bool
Whether something changed that needs layout.
Sourcepub fn layout(&self, text: &mut TextSystem)
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.
Sourcepub fn has_damage(&self) -> bool
pub fn has_damage(&self) -> bool
Whether any area needs repainting.
Sourcepub fn take_damage(&self) -> Vec<Rect>
pub fn take_damage(&self) -> Vec<Rect>
Takes the areas to repaint since the last call, in logical pixels. They may overlap.
Sourcepub fn view(&self) -> WindowView<'_>
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.