forge
Explore
Log in

Don't you dare go Hollow

Split get resize data from update

Browse files at this commit

34bcc6ea9369fda19f4fb776e59f37e5dafc0051Ivan MolodetskikhParent: 9dfa121
niri-visual-tests/src/test_window.rsmodified+3 -1
@@ -244,7 +244,9 @@ impl LayoutElement for TestWindow {
244 244
245 fn cancel_interactive_resize(&mut self) {}245 fn cancel_interactive_resize(&mut self) {}
246 246
247- fn interactive_resize_data(&mut self, _serial: Serial) -> Option<InteractiveResizeData> {247+ fn update_interactive_resize(&mut self, _serial: Serial) {}
248+
249+ fn interactive_resize_data(&self) -> Option<InteractiveResizeData> {
248 None250 None
249 }251 }
250 }252 }
src/layout/mod.rsmodified+5 -2
@@ -176,7 +176,8 @@ pub trait LayoutElement {
176 176
177 fn set_interactive_resize(&mut self, data: Option<InteractiveResizeData>);177 fn set_interactive_resize(&mut self, data: Option<InteractiveResizeData>);
178 fn cancel_interactive_resize(&mut self);178 fn cancel_interactive_resize(&mut self);
179- fn interactive_resize_data(&mut self, serial: Serial) -> Option<InteractiveResizeData>;179+ fn update_interactive_resize(&mut self, serial: Serial);
180+ fn interactive_resize_data(&self) -> Option<InteractiveResizeData>;
180 }181 }
181 182
182 #[derive(Debug)]183 #[derive(Debug)]
@@ -2209,7 +2210,9 @@ mod tests {
2209 2210
2210 fn cancel_interactive_resize(&mut self) {}2211 fn cancel_interactive_resize(&mut self) {}
2211 2212
2212- fn interactive_resize_data(&mut self, _serial: Serial) -> Option<InteractiveResizeData> {2213+ fn update_interactive_resize(&mut self, _serial: Serial) {}
2214+
2215+ fn interactive_resize_data(&self) -> Option<InteractiveResizeData> {
2213 None2216 None
2214 }2217 }
2215 }2218 }
src/layout/workspace.rsmodified+6 -4
@@ -1189,13 +1189,15 @@ impl<W: LayoutElement> Workspace<W> {
1189 let tile = &mut col.tiles[tile_idx];1189 let tile = &mut col.tiles[tile_idx];
1190 let window = tile.window_mut();1190 let window = tile.window_mut();
1191 1191
1192- let resize = serial.and_then(|serial| window.interactive_resize_data(serial));1192+ let resize = window.interactive_resize_data();
1193+
1194+ if let Some(serial) = serial {
1195+ window.update_interactive_resize(serial);
1196+ }
1193 1197
1194 // If this was the last resize commit, this function will now return None. This way we1198 // If this was the last resize commit, this function will now return None. This way we
1195 // can animate the window into view after the last resize commit.1199 // can animate the window into view after the last resize commit.
1196- let resize_still_ongoing = serial1200+ let resize_still_ongoing = window.interactive_resize_data().is_some();
1197- .and_then(|serial| window.interactive_resize_data(serial))
1198- .is_some();
1199 1201
1200 if let Some(resize) = resize {1202 if let Some(resize) = resize {
1201 // If this is an interactive resize commit of an active window, then we need to1203 // If this is an interactive resize commit of an active window, then we need to
src/window/mapped.rsmodified+20 -12
@@ -77,6 +77,16 @@ enum InteractiveResize {
77 },77 },
78 }78 }
79 79
80+impl InteractiveResize {
81+ fn data(&self) -> InteractiveResizeData {
82+ match self {
83+ InteractiveResize::Ongoing(data) => *data,
84+ InteractiveResize::WaitingForLastConfigure(data) => *data,
85+ InteractiveResize::WaitingForLastCommit { data, .. } => *data,
86+ }
87+ }
88+}
89+
80 impl Mapped {90 impl Mapped {
81 pub fn new(window: Window, rules: ResolvedWindowRules, hook: HookId) -> Self {91 pub fn new(window: Window, rules: ResolvedWindowRules, hook: HookId) -> Self {
82 Self {92 Self {
@@ -520,19 +530,17 @@ impl LayoutElement for Mapped {
520 self.interactive_resize = None;530 self.interactive_resize = None;
521 }531 }
522 532
523- fn interactive_resize_data(&mut self, commit_serial: Serial) -> Option<InteractiveResizeData> {533+ fn update_interactive_resize(&mut self, commit_serial: Serial) {
524- let resize = self.interactive_resize.as_ref()?;534+ if let Some(InteractiveResize::WaitingForLastCommit { serial, .. }) =
525- match resize {535+ &self.interactive_resize
526- InteractiveResize::Ongoing(data) | InteractiveResize::WaitingForLastConfigure(data) => {536+ {
527- Some(*data)537+ if commit_serial.is_no_older_than(serial) {
528- }538+ self.interactive_resize = None;
529- InteractiveResize::WaitingForLastCommit { data, serial } => {
530- let rv = Some(*data);
531- if commit_serial.is_no_older_than(serial) {
532- self.interactive_resize = None;
533- }
534- rv
535 }539 }
536 }540 }
537 }541 }
542+
543+ fn interactive_resize_data(&self) -> Option<InteractiveResizeData> {
544+ Some(self.interactive_resize.as_ref()?.data())
545+ }
538 }546 }