Skip to content

Commit

Permalink
layout: Rename update_interactive_resize() to on_commit()
Browse files Browse the repository at this point in the history
  • Loading branch information
YaLTeR committed Dec 21, 2024
1 parent 43cb873 commit 7f2e7d5
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 9 deletions.
2 changes: 1 addition & 1 deletion niri-visual-tests/src/test_window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ impl LayoutElement for TestWindow {

fn cancel_interactive_resize(&mut self) {}

fn update_interactive_resize(&mut self, _serial: Serial) {}
fn on_commit(&mut self, _serial: Serial) {}

fn interactive_resize_data(&self) -> Option<InteractiveResizeData> {
None
Expand Down
2 changes: 1 addition & 1 deletion src/layout/floating.rs
Original file line number Diff line number Diff line change
Expand Up @@ -752,7 +752,7 @@ impl<W: LayoutElement> FloatingSpace<W> {

// Do this before calling update_window() so it can get up-to-date info.
if let Some(serial) = serial {
tile.window_mut().update_interactive_resize(serial);
tile.window_mut().on_commit(serial);
}

let prev_size = data.size;
Expand Down
5 changes: 3 additions & 2 deletions src/layout/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -198,8 +198,9 @@ pub trait LayoutElement {

fn set_interactive_resize(&mut self, data: Option<InteractiveResizeData>);
fn cancel_interactive_resize(&mut self);
fn update_interactive_resize(&mut self, serial: Serial);
fn interactive_resize_data(&self) -> Option<InteractiveResizeData>;

fn on_commit(&mut self, serial: Serial);
}

#[derive(Debug)]
Expand Down Expand Up @@ -4076,7 +4077,7 @@ mod tests {

fn cancel_interactive_resize(&mut self) {}

fn update_interactive_resize(&mut self, _serial: Serial) {}
fn on_commit(&mut self, _serial: Serial) {}

fn interactive_resize_data(&self) -> Option<InteractiveResizeData> {
None
Expand Down
2 changes: 1 addition & 1 deletion src/layout/scrolling.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1071,7 +1071,7 @@ impl<W: LayoutElement> ScrollingSpace<W> {

// Do this before calling update_window() so it can get up-to-date info.
if let Some(serial) = serial {
tile.window_mut().update_interactive_resize(serial);
tile.window_mut().on_commit(serial);
}

let prev_width = self.data[col_idx].width;
Expand Down
9 changes: 5 additions & 4 deletions src/window/mapped.rs
Original file line number Diff line number Diff line change
Expand Up @@ -766,17 +766,18 @@ impl LayoutElement for Mapped {
self.interactive_resize = None;
}

fn update_interactive_resize(&mut self, commit_serial: Serial) {
fn interactive_resize_data(&self) -> Option<InteractiveResizeData> {
Some(self.interactive_resize.as_ref()?.data())
}

fn on_commit(&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())
}
}

0 comments on commit 7f2e7d5

Please sign in to comment.