diff options
| author | Ivan Molodetskikh <yalterz@gmail.com> | 2024-05-11 08:26:49 +0400 |
|---|---|---|
| committer | Ivan Molodetskikh <yalterz@gmail.com> | 2024-05-11 08:26:49 +0400 |
| commit | 34bcc6ea9369fda19f4fb776e59f37e5dafc0051 (patch) | |
| tree | 01a93ed2c0e8e95ca3bad020dece55c45e71065d /src | |
| parent | 9dfa121b8e31082314d1c9347a60ef2e596494cb (diff) | |
| download | niri-34bcc6ea9369fda19f4fb776e59f37e5dafc0051.tar.gz niri-34bcc6ea9369fda19f4fb776e59f37e5dafc0051.tar.bz2 niri-34bcc6ea9369fda19f4fb776e59f37e5dafc0051.zip | |
Split get resize data from update
Diffstat (limited to 'src')
| -rw-r--r-- | src/layout/mod.rs | 7 | ||||
| -rw-r--r-- | src/layout/workspace.rs | 10 | ||||
| -rw-r--r-- | src/window/mapped.rs | 32 |
3 files changed, 31 insertions, 18 deletions
diff --git a/src/layout/mod.rs b/src/layout/mod.rs index ad241d94..22aaa7fa 100644 --- a/src/layout/mod.rs +++ b/src/layout/mod.rs @@ -176,7 +176,8 @@ pub trait LayoutElement { fn set_interactive_resize(&mut self, data: Option<InteractiveResizeData>); fn cancel_interactive_resize(&mut self); - fn interactive_resize_data(&mut self, serial: Serial) -> Option<InteractiveResizeData>; + fn update_interactive_resize(&mut self, serial: Serial); + fn interactive_resize_data(&self) -> Option<InteractiveResizeData>; } #[derive(Debug)] @@ -2209,7 +2210,9 @@ mod tests { fn cancel_interactive_resize(&mut self) {} - fn interactive_resize_data(&mut self, _serial: Serial) -> Option<InteractiveResizeData> { + fn update_interactive_resize(&mut self, _serial: Serial) {} + + fn interactive_resize_data(&self) -> Option<InteractiveResizeData> { None } } diff --git a/src/layout/workspace.rs b/src/layout/workspace.rs index 1b6b14ff..a069abbf 100644 --- a/src/layout/workspace.rs +++ b/src/layout/workspace.rs @@ -1189,13 +1189,15 @@ impl<W: LayoutElement> Workspace<W> { let tile = &mut col.tiles[tile_idx]; let window = tile.window_mut(); - let resize = serial.and_then(|serial| window.interactive_resize_data(serial)); + let resize = window.interactive_resize_data(); + + if let Some(serial) = serial { + window.update_interactive_resize(serial); + } // If this was the last resize commit, this function will now return None. This way we // can animate the window into view after the last resize commit. - let resize_still_ongoing = serial - .and_then(|serial| window.interactive_resize_data(serial)) - .is_some(); + let resize_still_ongoing = window.interactive_resize_data().is_some(); if let Some(resize) = resize { // If this is an interactive resize commit of an active window, then we need to diff --git a/src/window/mapped.rs b/src/window/mapped.rs index e863e2ca..952a2bf3 100644 --- a/src/window/mapped.rs +++ b/src/window/mapped.rs @@ -77,6 +77,16 @@ enum InteractiveResize { }, } +impl InteractiveResize { + fn data(&self) -> InteractiveResizeData { + match self { + InteractiveResize::Ongoing(data) => *data, + InteractiveResize::WaitingForLastConfigure(data) => *data, + InteractiveResize::WaitingForLastCommit { data, .. } => *data, + } + } +} + impl Mapped { pub fn new(window: Window, rules: ResolvedWindowRules, hook: HookId) -> Self { Self { @@ -520,19 +530,17 @@ impl LayoutElement for Mapped { self.interactive_resize = None; } - fn interactive_resize_data(&mut self, commit_serial: Serial) -> Option<InteractiveResizeData> { - let resize = self.interactive_resize.as_ref()?; - match resize { - InteractiveResize::Ongoing(data) | InteractiveResize::WaitingForLastConfigure(data) => { - Some(*data) - } - InteractiveResize::WaitingForLastCommit { data, serial } => { - let rv = Some(*data); - if commit_serial.is_no_older_than(serial) { - self.interactive_resize = None; - } - rv + fn update_interactive_resize(&mut self, commit_serial: Serial) { + if let Some(InteractiveResize::WaitingForLastCommit { serial, .. }) = + &self.interactive_resize + { + if commit_serial.is_no_older_than(serial) { + self.interactive_resize = None; } } } + + fn interactive_resize_data(&self) -> Option<InteractiveResizeData> { + Some(self.interactive_resize.as_ref()?.data()) + } } |
