Skip to main content

teksilo_core/window/
command.rs

1// SPDX-License-Identifier: MPL-2.0
2// SPDX-FileCopyrightText: 2026 FernTech
3
4//! Private queue element produced by `WindowState` observers.
5//!
6//! When an app-side signal write fires its observer, the observer pushes
7//! one of these into [`WindowStateInner::pending_os_commands`](
8//! super::state::WindowState). The app-level window manager drains that
9//! queue once per tick and translates each command into a winit call.
10
11use super::placement::WindowPlacement;
12
13/// Intensity level for a user-attention request.
14///
15/// Mirrors winit's `UserAttentionType` so platforms that distinguish a
16/// critical (red bouncing dock icon on macOS) vs informational
17/// (one-bounce / taskbar flash) request can honour it.
18#[derive(Debug, Clone, Copy, PartialEq, Eq)]
19pub enum UserAttentionKind {
20    /// Persistent until the window is focused — macOS red bouncing
21    /// dock, Windows flashing taskbar entry.
22    Critical,
23    /// One-shot — macOS single bounce, Windows brief taskbar highlight.
24    Informational,
25}
26
27/// App → OS command produced by a `WindowState` signal observer.
28///
29/// Queued on [`WindowState`](super::state::WindowState) and drained by
30/// the app-level window manager after event dispatch. Application code
31/// does not construct these directly; writing to a signal field on
32/// `WindowState` is how you emit one.
33#[derive(Debug, Clone, PartialEq)]
34pub enum WindowCommand {
35    SetPlacement(WindowPlacement),
36    SetTitle(String),
37    SetSize(u32, u32),
38    SetPosition(i32, i32),
39    SetResizable(bool),
40    SetAlwaysOnTop(bool),
41    RequestAttention(UserAttentionKind),
42    /// Raise + focus this window. `activation_token` is an opaque
43    /// `xdg_activation_v1` token carried across a process boundary for a Wayland
44    /// cross-process raise; `None` everywhere else, where `focus_window`
45    /// already suffices.
46    Focus {
47        activation_token: Option<String>,
48    },
49    Close,
50}