From 2317021a7c4a7296606533d38f1fdce96826f7dc Mon Sep 17 00:00:00 2001 From: Ivan Molodetskikh Date: Fri, 23 Feb 2024 13:57:56 +0400 Subject: Implement explicit unmapped window state tracking --- src/window.rs | 71 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 src/window.rs (limited to 'src/window.rs') diff --git a/src/window.rs b/src/window.rs new file mode 100644 index 00000000..68d1e3a0 --- /dev/null +++ b/src/window.rs @@ -0,0 +1,71 @@ +use smithay::desktop::Window; +use smithay::output::Output; + +use crate::layout::workspace::ColumnWidth; + +#[derive(Debug)] +pub struct Unmapped { + pub window: Window, + pub state: InitialConfigureState, +} + +#[derive(Debug)] +pub enum InitialConfigureState { + /// The window has not been initially configured yet. + NotConfigured { + /// Whether the window requested to be fullscreened, and the requested output, if any. + wants_fullscreen: Option>, + }, + /// The window has been configured. + Configured { + /// Up-to-date rules. + /// + /// We start tracking window rules when sending the initial configure, since they don't + /// affect anything before that. + rules: ResolvedWindowRules, + + /// Resolved default width for this window. + /// + /// `None` means that the window will pick its own width. + width: Option, + + /// Output to open this window on. + /// + /// This can be `None` in cases like: + /// + /// - There are no outputs connected. + /// - This is a dialog with a parent, and there was no explicit output set, so this dialog + /// should fetch the parent's current output again upon mapping. + output: Option, + }, +} + +/// Rules fully resolved for a window. +#[derive(Debug, Default)] +pub struct ResolvedWindowRules { + /// Default width for this window. + /// + /// - `None`: unset (global default should be used). + /// - `Some(None)`: set to empty (window picks its own width). + /// - `Some(Some(width))`: set to a particular width. + pub default_width: Option>, + + /// Output to open this window on. + pub open_on_output: Option, +} + +impl Unmapped { + /// Wraps a newly created window that hasn't been initially configured yet. + pub fn new(window: Window) -> Self { + Self { + window, + state: InitialConfigureState::NotConfigured { + wants_fullscreen: None, + }, + } + } + + pub fn needs_initial_configure(&self) -> bool { + matches!(self.state, InitialConfigureState::NotConfigured { .. }) + } +} -- cgit