From 6aceb3a798f0abde0ec2309b599687c05b792a68 Mon Sep 17 00:00:00 2001 From: Ivan Molodetskikh Date: Mon, 8 Apr 2024 19:48:52 +0400 Subject: Render active column in front Rather than just the active window. This is visible on the new window movement animations. --- src/layout/workspace.rs | 47 +++++++++++++++++++++++++++++++---------------- 1 file changed, 31 insertions(+), 16 deletions(-) (limited to 'src') diff --git a/src/layout/workspace.rs b/src/layout/workspace.rs index a8bc63f2..f5b425bd 100644 --- a/src/layout/workspace.rs +++ b/src/layout/workspace.rs @@ -1159,12 +1159,25 @@ impl Workspace { // Start with the active window since it's drawn on top. let col = &self.columns[self.active_column_idx]; let tile = &col.tiles[col.active_tile_idx]; - let tile_pos = Point::from(( - self.column_x(self.active_column_idx) - view_pos, - col.tile_y(col.active_tile_idx), - )) + col.render_offset(); + let tile_pos = + Point::from((-self.view_offset, col.tile_y(col.active_tile_idx))) + col.render_offset(); let first = iter::once((tile, tile_pos)); + // Next, the rest of the tiles in the active column, since it should be drawn on top as a + // whole during animations. + let next = + zip(&col.tiles, col.tile_ys()) + .enumerate() + .filter_map(move |(tile_idx, (tile, y))| { + if tile_idx == col.active_tile_idx { + // Active tile comes first. + return None; + } + + let tile_pos = Point::from((-self.view_offset, y)) + col.render_offset(); + Some((tile, tile_pos)) + }); + let mut x = -view_pos; let rest = self .columns @@ -1176,20 +1189,22 @@ impl Workspace { x += col.width() + self.options.gaps; rv }) - .flat_map(move |(col_idx, col, x)| { - zip(&col.tiles, col.tile_ys()).enumerate().filter_map( - move |(tile_idx, (tile, y))| { - if col_idx == self.active_column_idx && tile_idx == col.active_tile_idx { - // Active tile comes first. - return None; - } + .filter_map(|(col_idx, col, x)| { + if col_idx == self.active_column_idx { + // Active column comes before. + return None; + } - let tile_pos = Point::from((x, y)) + col.render_offset(); - Some((tile, tile_pos)) - }, - ) + Some((col, x)) + }) + .flat_map(move |(col, x)| { + zip(&col.tiles, col.tile_ys()).map(move |(tile, y)| { + let tile_pos = Point::from((x, y)) + col.render_offset(); + (tile, tile_pos) + }) }); - first.chain(rest) + + first.chain(next).chain(rest) } fn active_column_ref(&self) -> Option<&Column> { -- cgit