teksilo_core/window/decorations.rs
1// SPDX-License-Identifier: MPL-2.0
2// SPDX-FileCopyrightText: 2026 FernTech
3
4//! Window decoration mode.
5
6/// How a window's chrome is drawn.
7///
8/// Three-valued and explicit. Replaces the older `custom_chrome: bool`
9/// flag on `WindowConfig`, which could not represent the
10/// "borderless / no host" case.
11#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
12pub enum DecorationsMode {
13 /// OS-provided title bar, borders, and resize handles. The default
14 /// for application windows on every platform.
15 #[default]
16 Native,
17 /// No native title bar; a
18 /// [`PlatformTitleBarHost`](crate::PlatformTitleBarHost) is
19 /// constructed and attached to the tree so the app can paint its
20 /// own chrome. Falls back to `Native` on window systems that do
21 /// not support custom chrome — on X11 that means a window manager without
22 /// `_NET_WM_MOVERESIZE`, since a borderless window would otherwise be
23 /// impossible to move or resize.
24 CustomChrome,
25 /// No decorations at all — neither OS chrome nor a host. Use for
26 /// splash screens, borderless popups, or fully chrome-less embeds.
27 None,
28}
29
30impl DecorationsMode {
31 /// Returns `true` when this mode wants a
32 /// [`PlatformTitleBarHost`](crate::PlatformTitleBarHost) to be
33 /// constructed during window creation.
34 pub fn wants_custom_chrome_host(self) -> bool {
35 matches!(self, DecorationsMode::CustomChrome)
36 }
37
38 /// Returns `true` when the OS should draw its own chrome.
39 pub fn wants_native_decorations(self) -> bool {
40 matches!(self, DecorationsMode::Native)
41 }
42}
43
44#[cfg(test)]
45mod tests {
46 use super::*;
47
48 #[test]
49 fn default_is_native() {
50 assert_eq!(DecorationsMode::default(), DecorationsMode::Native);
51 }
52
53 #[test]
54 fn predicates() {
55 assert!(DecorationsMode::Native.wants_native_decorations());
56 assert!(!DecorationsMode::Native.wants_custom_chrome_host());
57 assert!(DecorationsMode::CustomChrome.wants_custom_chrome_host());
58 assert!(!DecorationsMode::CustomChrome.wants_native_decorations());
59 assert!(!DecorationsMode::None.wants_custom_chrome_host());
60 assert!(!DecorationsMode::None.wants_native_decorations());
61 }
62}