Skip to main content

WindowState

Struct WindowState 

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

A refcounted handle to a single window’s reactive state.

Cloning gives you another handle to the same underlying state. Widgets should store a WindowState clone when they need to read or write window-level signals outside of a single build() call.

Implementations§

Source§

impl WindowState

Source

pub fn new(init: WindowStateInit) -> Self

Construct a new state from initial values.

Wires an observer on every signal that pushes a matching WindowCommand onto the pending queue, guarded by WindowStateInner::applying_from_os.

Source

pub fn id(&self) -> TeksiloWindowId

Source

pub fn string_id(&self) -> Option<&str>

Source

pub fn placement(&self) -> &Signal<WindowPlacement>

Source

pub fn title(&self) -> &Signal<String>

Source

pub fn size(&self) -> &Signal<(u32, u32)>

Source

pub fn position(&self) -> &Signal<(i32, i32)>

Source

pub fn focused(&self) -> &Signal<bool>

Source

pub fn resizable(&self) -> &Signal<bool>

Source

pub fn always_on_top(&self) -> &Signal<bool>

Source

pub fn caps_lock(&self) -> &Signal<bool>

Caps Lock active state. OS-driven only — the window manager toggles it on each Key::CapsLock press. Read this (e.g. via ctx.window()) to drive a Caps Lock warning on password fields.

Source

pub fn alt_down(&self) -> &Signal<bool>

Whether the Alt key is currently held down. OS-driven only — the window manager flips this from winit’s ModifiersChanged, where winit reports modifier keys. Read this to drive mnemonic-underline visibility on menus and menubars. See the menubar key-dispatch documentation for the full Alt-tap / Alt+letter / mnemonic-underline contract.

Source

pub fn other_key_pressed_during_alt(&self) -> bool

Read whether any non-Alt key has been pressed during the current Alt-hold window. false means the user has not composed a chord since pressing Alt, so the next Alt release is a bare-Alt tap if this window saw the press (see note_alt_key_from_os).

Source

pub fn install_menubar_dispatcher( &self, dispatcher: Rc<dyn MenubarDispatcher>, ) -> MenubarGuard

Install (or replace) the per-window menubar key dispatcher. Returns a super::menubar_dispatcher::MenubarGuard that clears the slot on drop iff it still points at this exact dispatcher (Rc::ptr_eq).

At most one dispatcher is supported per window. A second install while another is still live debug_assert!s and overwrites in release. This matches the “one MenuBar per window” invariant the framework enforces upstream.

Source

pub fn menubar_dispatcher(&self) -> Option<Rc<dyn MenubarDispatcher>>

Snapshot of the currently-installed menubar dispatcher. Used by teksilo-app’s key-event arm to consult the menubar BEFORE focus-based dispatch. Returns None when no MenuBar is mounted in this window.

Source

pub fn request_attention(&self, kind: UserAttentionKind)

Request user attention (bouncing dock icon on macOS, flashing taskbar on Windows). Queues a WindowCommand::RequestAttention command for the next drain.

Source

pub fn focus(&self)

Focus this window — raise it above others and give it keyboard focus. Queues a WindowCommand::Focus command for the next drain, carrying (and clearing) any token set via WindowState::set_activation_token.

Source

pub fn set_activation_token(&self, token: String)

Stash an xdg_activation_v1 token — an opaque string minted by the focused requester and handed across a process boundary — to be consumed by the next WindowState::focus. Only affects a Wayland raise; ignored on every other platform, where focus() raises on its own.

Source

pub fn close(&self)

Close this window. Queues a WindowCommand::Close command for the next drain.

Source§

impl WindowState

Source

pub fn drain_os_commands(&self) -> Vec<WindowCommand>

Drain the pending OS-command queue.

Source

pub fn set_placement_from_os(&self, p: WindowPlacement)

OS-originated placement write. Observers do not push back to the OS while the guard is set.

Source

pub fn set_title_from_os(&self, title: String)

Source

pub fn set_size_from_os(&self, size: (u32, u32))

Source

pub fn set_position_from_os(&self, position: (i32, i32))

Source

pub fn set_focused_from_os(&self, focused: bool)

Source

pub fn set_resizable_from_os(&self, resizable: bool)

Source

pub fn set_always_on_top_from_os(&self, on_top: bool)

Source

pub fn set_caps_lock_from_os(&self, active: bool)

Update Caps Lock state from the OS. No observer / command is wired (the app never drives the keyboard lock), so this writes the signal directly. Idempotent: skips the write when unchanged to avoid spurious repaints on auto-repeat.

Source

pub fn set_alt_from_os(&self, active: bool)

Update Alt-held state from the OS. Resets the other_key_pressed_during_alt flag on every Alt KeyDown edge so each Alt-hold window starts fresh. Idempotent.

Source

pub fn note_non_alt_keydown_during_alt(&self)

Mark that a non-Alt key was pressed while Alt is currently held. Sticky — only cleared by the next set_alt_from_os(true) edge. No-op when Alt is not held. Idempotent.

Source

pub fn note_close_request_from_os(&self)

The OS asked to close the window. With Alt held this was Alt+F4, whose F4 winit does not report on Windows (it leaves it to DefWindowProc), so the hold is a chord and its release no tap. The window stays open when an in-window modal took the request, and the release would otherwise put its menu bar in keyboard mode.

Source

pub fn note_alt_key_from_os(&self, pressed: bool, alone: bool) -> bool

A real press or release of an Alt key in this window, never a synthetic one (the keys a window is told are held as it takes or loses the focus). Returns true for the release that ends a bare Alt tap: this window saw the press, and no other key went down before the release.

alone is whether no other modifier (Control, Shift, Super) was already held as Alt went down; it is read on the press only. Alt+Shift, Ctrl+Alt and the like are chords, not the lone Alt that opens the menu bar, even when the key that completes them never reaches the window (an input method swallows it).

Trait Implementations§

Source§

impl Clone for WindowState

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for WindowState

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. 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.