From 34bcc6ea9369fda19f4fb776e59f37e5dafc0051 Mon Sep 17 00:00:00 2001 From: Ivan Molodetskikh Date: Sat, 11 May 2024 08:26:49 +0400 Subject: Split get resize data from update --- src/window/mapped.rs | 32 ++++++++++++++++++++------------ 1 file changed, 20 insertions(+), 12 deletions(-) (limited to 'src/window') 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 { - 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 { + Some(self.interactive_resize.as_ref()?.data()) + } } -- cgit