aboutsummaryrefslogtreecommitdiff
path: root/src/layout/workspace.rs
diff options
context:
space:
mode:
authorIvan Molodetskikh <yalterz@gmail.com>2024-05-04 11:10:02 +0400
committerIvan Molodetskikh <yalterz@gmail.com>2024-05-04 11:10:02 +0400
commit73cc0079d628e66b1d64168ed1a10b13b23ab5d0 (patch)
tree168aa5d885c2061c8ec9090e1cd46b865a6f2a42 /src/layout/workspace.rs
parent69aeba2a4d93b34eb24319c3694ad354dc608a87 (diff)
downloadniri-73cc0079d628e66b1d64168ed1a10b13b23ab5d0.tar.gz
niri-73cc0079d628e66b1d64168ed1a10b13b23ab5d0.tar.bz2
niri-73cc0079d628e66b1d64168ed1a10b13b23ab5d0.zip
Split update_render_elements() from advance_animations()
advance_animations() is called from places like input, whereas update_render_elements() is strictly for rendering.
Diffstat (limited to 'src/layout/workspace.rs')
-rw-r--r--src/layout/workspace.rs55
1 files changed, 37 insertions, 18 deletions
diff --git a/src/layout/workspace.rs b/src/layout/workspace.rs
index 3205d82b..05d5f280 100644
--- a/src/layout/workspace.rs
+++ b/src/layout/workspace.rs
@@ -289,7 +289,7 @@ impl<W: LayoutElement> Workspace<W> {
self.id
}
- pub fn advance_animations(&mut self, current_time: Duration, is_active: bool) {
+ pub fn advance_animations(&mut self, current_time: Duration) {
if let Some(ViewOffsetAdjustment::Animation(anim)) = &mut self.view_offset_adj {
anim.set_current_time(current_time);
self.view_offset = anim.value().round() as i32;
@@ -300,9 +300,8 @@ impl<W: LayoutElement> Workspace<W> {
self.view_offset = gesture.current_view_offset.round() as i32;
}
- for (col_idx, col) in self.columns.iter_mut().enumerate() {
- let is_active = is_active && col_idx == self.active_column_idx;
- col.advance_animations(current_time, is_active);
+ for col in &mut self.columns {
+ col.advance_animations(current_time);
}
self.closing_windows.retain_mut(|closing| {
@@ -325,6 +324,16 @@ impl<W: LayoutElement> Workspace<W> {
|| !self.closing_windows.is_empty()
}
+ pub fn update_render_elements(&mut self, is_active: bool) {
+ let mut view_rect = Rectangle::from_loc_and_size((self.view_pos(), 0), self.view_size);
+
+ for (col_idx, col) in self.columns.iter_mut().enumerate() {
+ let is_active = is_active && col_idx == self.active_column_idx;
+ col.update_render_elements(is_active, view_rect);
+ view_rect.loc.x -= col.width() + self.options.gaps;
+ }
+ }
+
pub fn update_config(&mut self, options: Rc<Options>) {
for column in &mut self.columns {
column.update_config(options.clone());
@@ -1198,7 +1207,7 @@ impl<W: LayoutElement> Workspace<W> {
.map(|o| Scale::from(o.current_scale().fractional_scale()))
.unwrap_or(Scale::from(1.));
- tile.store_unmap_snapshot_if_empty(renderer, output_scale, self.view_size);
+ tile.store_unmap_snapshot_if_empty(renderer, output_scale);
}
pub fn clear_unmap_snapshot(&mut self, window: &W::Id) {
@@ -1947,15 +1956,8 @@ impl<W: LayoutElement> Workspace<W> {
first = false;
rv.extend(
- tile.render(
- renderer,
- tile_pos,
- output_scale,
- self.view_size,
- focus_ring,
- target,
- )
- .map(Into::into),
+ tile.render(renderer, tile_pos, output_scale, focus_ring, target)
+ .map(Into::into),
);
}
@@ -2298,7 +2300,7 @@ impl<W: LayoutElement> Column<W> {
self.update_tile_sizes(true);
}
- pub fn advance_animations(&mut self, current_time: Duration, is_active: bool) {
+ pub fn advance_animations(&mut self, current_time: Duration) {
match &mut self.move_animation {
Some(anim) => {
anim.set_current_time(current_time);
@@ -2309,9 +2311,8 @@ impl<W: LayoutElement> Column<W> {
None => (),
}
- for (tile_idx, tile) in self.tiles.iter_mut().enumerate() {
- let is_active = is_active && tile_idx == self.active_tile_idx;
- tile.advance_animations(current_time, is_active);
+ for tile in &mut self.tiles {
+ tile.advance_animations(current_time);
}
}
@@ -2319,6 +2320,24 @@ impl<W: LayoutElement> Column<W> {
self.move_animation.is_some() || self.tiles.iter().any(Tile::are_animations_ongoing)
}
+ pub fn update_render_elements(
+ &mut self,
+ is_active: bool,
+ mut view_rect: Rectangle<i32, Logical>,
+ ) {
+ view_rect.loc -= self.render_offset();
+
+ if !self.is_fullscreen {
+ view_rect.loc.y -= self.working_area.loc.y + self.options.gaps;
+ }
+
+ for (tile_idx, tile) in self.tiles.iter_mut().enumerate() {
+ let is_active = is_active && tile_idx == self.active_tile_idx;
+ tile.update(is_active, view_rect);
+ view_rect.loc.y -= tile.tile_size().h + self.options.gaps;
+ }
+ }
+
pub fn render_offset(&self) -> Point<i32, Logical> {
let mut offset = Point::from((0., 0.));