From 782f459010e8463a354d97f2fde21d65dbe6a613 Mon Sep 17 00:00:00 2001 From: Ivan Molodetskikh Date: Mon, 3 Aug 2026 10:38:14 +0300 Subject: [PATCH] layout: Animate column/tile movement between workspaces It'd probably make visual sense to "propagate" the "animating between workspaces" flag on actions such as consume and expel to the affected tiles, however that sounds somewhat annoying, and isn't all that visible normally. --- src/layout/floating.rs | 27 ++++- src/layout/mod.rs | 25 +++++ src/layout/monitor.rs | 222 +++++++++++++++++++++++++++++++--------- src/layout/scrolling.rs | 82 ++++++++++++--- src/layout/tile.rs | 34 +++++- src/layout/workspace.rs | 50 ++++++--- 6 files changed, 355 insertions(+), 85 deletions(-) diff --git a/src/layout/floating.rs b/src/layout/floating.rs index 48a3aba7..fd1b5afb 100644 --- a/src/layout/floating.rs +++ b/src/layout/floating.rs @@ -16,6 +16,7 @@ use super::{ ConfigureIntent, InteractiveResizeData, LayoutElement, Options, RemovedTile, SizeFrac, }; use crate::animation::{Animation, Clock}; +use crate::layout::RenderLayer; use crate::niri_render_elements; use crate::render_helpers::renderer::NiriRenderer; use crate::render_helpers::xray::XrayPos; @@ -265,9 +266,19 @@ impl FloatingSpace { self.tiles.iter().any(Tile::are_transitions_ongoing) || !self.closing_windows.is_empty() } - pub fn update_render_elements(&mut self, is_active: bool, view_rect: Rectangle) { + pub fn update_render_elements( + &mut self, + is_active: bool, + view_rect: Rectangle, + layer: RenderLayer, + ) { let active = self.active_window_id.clone(); for (tile, offset) in self.tiles_with_offsets_mut() { + // Skip tiles belonging to a different render layer. + if layer.is_normal() == tile.is_moving_between_workspaces() { + continue; + } + let id = tile.window().id(); let is_active = is_active && Some(id) == active.as_ref(); @@ -1057,6 +1068,7 @@ impl FloatingSpace { xray_pos: XrayPos, view_rect: Rectangle, focus_ring: bool, + layer: RenderLayer, push: &mut dyn FnMut(FloatingSpaceRenderElement), ) { let scale = Scale::from(self.scale); @@ -1064,13 +1076,20 @@ impl FloatingSpace { // Draw the closing windows on top of the other windows. // // FIXME: I guess this should rather preserve the stacking order when the window is closed. - for closing in self.closing_windows.iter().rev() { - let elem = closing.render(ctx.as_gles(), view_rect, scale); - push(elem.into()); + if layer.is_normal() { + for closing in self.closing_windows.iter().rev() { + let elem = closing.render(ctx.as_gles(), view_rect, scale); + push(elem.into()); + } } let active = self.active_window_id.clone(); for (tile, tile_pos) in self.tiles_with_render_positions() { + // Skip tiles belonging to a different render layer. + if layer.is_normal() == tile.is_moving_between_workspaces() { + continue; + } + // For the active tile, draw the focus ring. let focus_ring = focus_ring && Some(tile.window().id()) == active.as_ref(); diff --git a/src/layout/mod.rs b/src/layout/mod.rs index 657c5950..6e203998 100644 --- a/src/layout/mod.rs +++ b/src/layout/mod.rs @@ -558,6 +558,14 @@ struct OverviewGesture { value: f64, } +/// Layer of windows to render. +#[derive(Clone, Copy)] +pub enum RenderLayer { + Normal, + /// Windows currently moving between workspaces. + MovingBetweenWorkspaces, +} + impl SizingMode { #[must_use] pub fn is_normal(&self) -> bool { @@ -687,6 +695,16 @@ impl OverviewProgress { } } +impl RenderLayer { + /// Returns `true` if the render layer is [`Normal`]. + /// + /// [`Normal`]: RenderLayer::Normal + #[must_use] + pub fn is_normal(&self) -> bool { + matches!(self, Self::Normal) + } +} + impl Layout { pub fn new(clock: Clock, config: &Config) -> Self { Self::with_options_and_workspaces(clock, config, Options::from_config(config)) @@ -4304,6 +4322,13 @@ impl Layout { let new_tile_render_loc = ws_geo.loc + tile_offset.upscale(zoom); tile.animate_move_from((tile_render_loc - new_tile_render_loc).downscale(zoom)); + + // Interactive move into floating barely animates (it doesn't really move after + // being dropped), so setting it as moving between workspaces would just cause it to + // awkwardly sit unclipped for a moment before the animation runs out. + if !matches!(position, InsertPosition::Floating) { + tile.set_anim_y_between_workspaces(); + } } MonitorSet::NoOutputs { workspaces, .. } => { if workspaces.is_empty() { diff --git a/src/layout/monitor.rs b/src/layout/monitor.rs index 306ebdfc..de21dc7a 100644 --- a/src/layout/monitor.rs +++ b/src/layout/monitor.rs @@ -20,6 +20,7 @@ use super::workspace::{ use super::{compute_overview_zoom, ActivateWindow, HitType, LayoutElement, Options}; use crate::animation::{Animation, Clock}; use crate::input::swipe_tracker::SwipeTracker; +use crate::layout::RenderLayer; use crate::niri_render_elements; use crate::render_helpers::renderer::NiriRenderer; use crate::render_helpers::shadow::ShadowRenderElement; @@ -815,6 +816,7 @@ impl Monitor { } else { self.active_workspace_idx }; + let source_id = self.workspaces[source_workspace_idx].id(); let new_idx = min(idx, self.workspaces.len() - 1); if new_idx == source_workspace_idx { @@ -832,6 +834,11 @@ impl Monitor { }; let window = window.clone(); + let mut old_render_pos = workspace + .tiles_with_render_positions() + .find_map(|(tile, offset, _visible)| (tile.window().id() == &window).then_some(offset)) + .unwrap(); + let transaction = Transaction::new(); let removed = workspace.remove_tile(&window, transaction); @@ -855,6 +862,31 @@ impl Monitor { if self.workspace_switch.is_none() { self.clean_up_workspaces(); } + + let new_idx = self.idx_of_ws(new_id).unwrap(); + + // Animate vertical movement between workspaces. + // + // Recompute the source idx in case some workspace was removed during clean-up. If the + // source workspace itself was removed, don't bother animating this since the removal is + // instant anyway. + if let Some(source_workspace_idx) = self.idx_of_ws(source_id) { + old_render_pos.y += + self.workspace_size_with_gap(1.).h * (source_workspace_idx as f64 - new_idx as f64); + } + + let (tile, new_render_pos) = self.workspaces[new_idx] + .tiles_with_render_positions_mut(false) + .find(|(tile, _)| tile.window().id() == &window) + .unwrap(); + // If the view is following the tile, match the animation. + let config = if activate { + self.options.animations.workspace_switch.0 + } else { + self.options.animations.window_movement.0 + }; + tile.animate_move_from_with_config(old_render_pos - new_render_pos, config); + tile.set_anim_y_between_workspaces(); } pub fn move_column_to_workspace_up(&mut self, activate: bool) { @@ -886,11 +918,38 @@ impl Monitor { return; } - let Some(column) = workspace.remove_active_column() else { + let Some(id) = workspace.scrolling().active_column().map(Column::id) else { return; }; + let mut old_render_pos = workspace + .scrolling() + .columns_with_render_positions() + .find_map(|(col, pos)| (col.id() == id).then_some(pos)) + .unwrap(); + let column = workspace.remove_active_column().unwrap(); + + // Animate vertical movement between workspaces. + old_render_pos.y += + self.workspace_size_with_gap(1.).h * (source_workspace_idx as f64 - new_idx as f64); + + let new_id = self.workspaces[new_idx].id(); self.add_column(new_idx, column, activate); + + let new_idx = self.idx_of_ws(new_id).unwrap(); + let (column, new_render_pos) = self.workspaces[new_idx] + .scrolling_mut() + .columns_with_render_positions_mut() + .find(|(col, _pos)| col.id() == id) + .unwrap(); + // If the view is following the tile, match the animation. + let config = if activate { + self.options.animations.workspace_switch.0 + } else { + self.options.animations.window_movement.0 + }; + column.animate_move_from_with_config(old_render_pos - new_render_pos, config); + column.set_anim_y_between_workspaces(); } pub fn switch_workspace_up(&mut self) { @@ -1014,8 +1073,12 @@ impl Monitor { .as_ref() .and_then(|hint| hint.workspace.existing_id()); + for ws in &mut self.workspaces { + ws.update_render_elements(is_active, RenderLayer::MovingBetweenWorkspaces); + } + for (ws, geo) in self.workspaces_with_render_geo_mut(true) { - ws.update_render_elements(is_active); + ws.update_render_elements(is_active, RenderLayer::Normal); if Some(ws.id()) == insert_hint_ws_id { insert_hint_ws_geo = Some(geo); @@ -1421,15 +1484,22 @@ impl Monitor { }) } - pub fn workspaces_with_render_geo( + pub fn workspaces_with_render_geo_cull( &self, + cull: bool, ) -> impl Iterator, Rectangle)> { let output_geo = Rectangle::from_size(self.view_size); let geo = self.workspaces_render_geo(); zip(self.workspaces.iter(), geo) // Cull out workspaces outside the output. - .filter(move |(_ws, geo)| geo.intersection(output_geo).is_some()) + .filter(move |(_ws, geo)| !cull || geo.intersection(output_geo).is_some()) + } + + pub fn workspaces_with_render_geo( + &self, + ) -> impl Iterator, Rectangle)> { + self.workspaces_with_render_geo_cull(true) } pub fn workspaces_with_render_geo_idx( @@ -1599,28 +1669,6 @@ impl Monitor { // Ceil the height in physical pixels. let height = (self.view_size.h * scale).ceil() as i32; - // Crop the elements to prevent them overflowing, currently visible during a workspace - // switch. - // - // HACK: crop to infinite bounds at least horizontally where we - // know there's no workspace joining or monitor bounds, otherwise - // it will cut pixel shaders and mess up the coordinate space. - // There's also a damage tracking bug which causes glitched - // rendering for maximized GTK windows. - // - // FIXME: use proper bounds after fixing the Crop element. - let crop_bounds = if self.workspace_switch.is_some() || self.overview_progress.is_some() { - Rectangle::new( - Point::from((-i32::MAX / 2, 0)), - Size::from((i32::MAX, height)), - ) - } else { - Rectangle::new( - Point::from((-i32::MAX / 2, -i32::MAX / 2)), - Size::from((i32::MAX, i32::MAX)), - ) - }; - let zoom = self.overview_zoom(); let insert_hint_render_loc = self @@ -1639,32 +1687,110 @@ impl Monitor { ) }; - for (ws, geo) in self.workspaces_with_render_geo() { - // Macro instead of closure because ws and insert hint have different elem types. - macro_rules! push { - () => {{ - &mut |elem| { - let elem = CropRenderElement::from_element(elem, scale, crop_bounds); - if let Some(elem) = elem { - let elem = MonitorInnerRenderElement::from(elem); - push(scale_relocate(geo, elem)); - } - } - }}; - } - - let xray_pos = XrayPos::new(geo.loc, zoom); + // Draw in passes for correct Z ordering during window movement between workspaces: + // - floating windows moving between workspaces + // - normal floating windows + // - scrolling windows moving between workspaces + // - normal scrolling windows + for pass in 0..4 { + // Don't cull when drawing windows moving between workspaces so that windows moving to + // workspaces off-screen will still render. + let cull = matches!(pass, 1 | 3); + + // Crop the elements to prevent them overflowing, currently visible during a workspace + // switch. + // + // HACK: crop to infinite bounds at least horizontally where we + // know there's no workspace joining or monitor bounds, otherwise + // it will cut pixel shaders and mess up the coordinate space. + // There's also a damage tracking bug which causes glitched + // rendering for maximized GTK windows. + // + // FIXME: use proper bounds after fixing the Crop element. + // + // Also, check cull here to avoid cropping windows moving between workspaces. + // + // FIXME: for cull=true, it might be better visually to crop to a workspace-high region + // anchored to the window/column as it moves between workspaces, to prevent overflowing + // windows from appearing and disappearing. + let crop_bounds = + if cull && (self.workspace_switch.is_some() || self.overview_progress.is_some()) { + Rectangle::new( + Point::from((-i32::MAX / 2, 0)), + Size::from((i32::MAX, height)), + ) + } else { + Rectangle::new( + Point::from((-i32::MAX / 2, -i32::MAX / 2)), + Size::from((i32::MAX, i32::MAX)), + ) + }; - ws.render_floating(ctx.r(), xray_pos, focus_ring, push!()); + for (ws, geo) in self.workspaces_with_render_geo_cull(cull) { + // Macro instead of closure because ws and insert hint have different elem types. + macro_rules! push { + () => {{ + &mut |elem| { + let elem = CropRenderElement::from_element(elem, scale, crop_bounds); + if let Some(elem) = elem { + let elem = MonitorInnerRenderElement::from(elem); + push(scale_relocate(geo, elem)); + } + } + }}; + } - if let Some(loc) = insert_hint_render_loc { - if loc.workspace == InsertWorkspace::Existing(ws.id()) { - self.insert_hint_element - .render(ctx.renderer, loc.location, push!()); + let xray_pos = XrayPos::new(geo.loc, zoom); + + match pass { + 0 => { + ws.render_floating( + ctx.r(), + xray_pos, + focus_ring, + RenderLayer::MovingBetweenWorkspaces, + push!(), + ); + } + 1 => { + ws.render_floating( + ctx.r(), + xray_pos, + focus_ring, + RenderLayer::Normal, + push!(), + ); + + if let Some(loc) = insert_hint_render_loc { + if loc.workspace == InsertWorkspace::Existing(ws.id()) { + self.insert_hint_element.render( + ctx.renderer, + loc.location, + push!(), + ); + } + } + } + 2 => { + ws.render_scrolling( + ctx.r(), + xray_pos, + focus_ring, + RenderLayer::MovingBetweenWorkspaces, + push!(), + ); + } + _ => { + ws.render_scrolling( + ctx.r(), + xray_pos, + focus_ring, + RenderLayer::Normal, + push!(), + ); + } } } - - ws.render_scrolling(ctx.r(), xray_pos, focus_ring, push!()); } } diff --git a/src/layout/scrolling.rs b/src/layout/scrolling.rs index d2305cae..84b8749a 100644 --- a/src/layout/scrolling.rs +++ b/src/layout/scrolling.rs @@ -18,7 +18,7 @@ use super::workspace::{InteractiveResize, ResolvedSize}; use super::{ConfigureIntent, HitType, InteractiveResizeData, LayoutElement, Options, RemovedTile}; use crate::animation::{Animation, Clock}; use crate::input::swipe_tracker::SwipeTracker; -use crate::layout::SizingMode; +use crate::layout::{RenderLayer, SizingMode}; use crate::niri_render_elements; use crate::render_helpers::renderer::NiriRenderer; use crate::render_helpers::xray::XrayPos; @@ -306,6 +306,10 @@ pub enum ScrollDirection { struct MoveAnimation { anim: Animation, from: f64, + /// Whether this animation is for moving the tile between workspaces. + /// + /// Controls whether the tile is rendered uncropped and above others. + is_between_workspaces: bool, } impl ScrollingSpace { @@ -422,11 +426,16 @@ impl ScrollingSpace { || !self.closing_windows.is_empty() } - pub fn update_render_elements(&mut self, is_active: bool) { + pub fn update_render_elements(&mut self, is_active: bool, layer: RenderLayer) { let view_pos = Point::from((self.view_pos(), 0.)); let view_size = self.view_size; let active_idx = self.active_column_idx; for (col_idx, (col, col_x)) in self.columns_mut().enumerate() { + // Skip columns belonging to a different render layer. + if layer.is_normal() == col.is_moving_between_workspaces() { + continue; + } + let is_active = is_active && col_idx == active_idx; let col_off = Point::from((col_x, 0.)); let col_pos = view_pos - col_off - col.render_offset(); @@ -2938,15 +2947,18 @@ impl ScrollingSpace { mut ctx: RenderCtx, xray_pos: XrayPos, focus_ring: bool, + layer: RenderLayer, push: &mut dyn FnMut(ScrollingSpaceRenderElement), ) { let scale = Scale::from(self.scale); // Draw the closing windows on top of the other windows. - let view_rect = Rectangle::new(Point::from((self.view_pos(), 0.)), self.view_size); - for closing in self.closing_windows.iter().rev() { - let elem = closing.render(ctx.as_gles(), view_rect, scale); - push(elem.into()); + if layer.is_normal() { + let view_rect = Rectangle::new(Point::from((self.view_pos(), 0.)), self.view_size); + for closing in self.closing_windows.iter().rev() { + let elem = closing.render(ctx.as_gles(), view_rect, scale); + push(elem.into()); + } } if self.columns.is_empty() { @@ -2957,6 +2969,12 @@ impl ScrollingSpace { // This matches self.tiles_with_render_positions(). for (col, col_pos) in self.columns_with_render_positions() { + // Skip columns belonging to a different render layer. + if layer.is_normal() == col.is_moving_between_workspaces() { + first = false; + continue; + } + // Draw the tab indicator on top. { let pos = col_pos.to_physical_precise_round(scale).to_logical(scale); @@ -4133,6 +4151,34 @@ impl Column { || self.tiles.iter().any(Tile::are_transitions_ongoing) } + pub fn is_moving_between_workspaces(&self) -> bool { + self.move_y_animation + .as_ref() + .is_some_and(|anim| anim.is_between_workspaces) + || self + .move_x_animation + .as_ref() + .is_some_and(|anim| anim.is_between_workspaces) + // When moving a window between workspaces into the scrolling layout, it will be + // immediately put into a new column, however the Y move animation and the + // moving-between-workspaces flag will be set on the tile rather than on that new + // column. Since the scrolling layout rendering checks moving between workspaces + // per-column rather than per-tile, we need to include the tiles here. + // + // This is not always visually correct: for example, interactive-moving a tile into an + // otherwise stationary column will now cause that entire column to draw unculled. I'm + // not sure there's a good solution overall for all edge cases here. Consider that the + // column tab indicator needs to draw on top of the tiles, but in this counterexample + // above, the column is stationary, so the single moving tile would instead need to draw + // on top of the tab indicator. + // + // I'm going with this simple check for now that should look ok in most cases. + || self + .tiles + .iter() + .any(|tile| tile.is_moving_between_workspaces()) + } + pub fn update_render_elements(&mut self, is_active: bool, view_rect: Rectangle) { let active_idx = self.active_tile_idx; for (tile_idx, (tile, tile_off)) in self.tiles_mut().enumerate() { @@ -4227,15 +4273,16 @@ impl Column { from_x_offset: f64, config: niri_config::Animation, ) { - let current_offset = self - .move_x_animation - .as_ref() - .map_or(0., |move_| move_.from * move_.anim.value()); + let (current_offset, current_between) = + self.move_x_animation.as_ref().map_or((0., false), |move_| { + (move_.from * move_.anim.value(), move_.is_between_workspaces) + }); let anim = Animation::new(self.clock.clone(), 1., 0., 0., config); self.move_x_animation = Some(MoveAnimation { anim, from: from_x_offset + current_offset, + is_between_workspaces: current_between, }); } @@ -4251,15 +4298,16 @@ impl Column { from_y_offset: f64, config: niri_config::Animation, ) { - let current_offset = self - .move_y_animation - .as_ref() - .map_or(0., |move_| move_.from * move_.anim.value()); + let (current_offset, current_between) = + self.move_y_animation.as_ref().map_or((0., false), |move_| { + (move_.from * move_.anim.value(), move_.is_between_workspaces) + }); let anim = Animation::new(self.clock.clone(), 1., 0., 0., config); self.move_y_animation = Some(MoveAnimation { anim, from: from_y_offset + current_offset, + is_between_workspaces: current_between, }); } @@ -4274,6 +4322,12 @@ impl Column { } } + pub fn set_anim_y_between_workspaces(&mut self) { + if let Some(anim) = &mut self.move_y_animation { + anim.is_between_workspaces = true; + } + } + /// Returns whether this column is currently fullscreen. /// /// As in, if it contains one currently-fullscreen tile, or in tabbed mode, if it contains at diff --git a/src/layout/tile.rs b/src/layout/tile.rs index 49fa2692..db8ce678 100644 --- a/src/layout/tile.rs +++ b/src/layout/tile.rs @@ -160,6 +160,10 @@ struct ResizeAnimation { struct MoveAnimation { anim: Animation, from: f64, + /// Whether this animation is for moving the tile between workspaces. + /// + /// Controls whether the tile is rendered uncropped and above others. + is_between_workspaces: bool, } #[derive(Debug)] @@ -456,6 +460,16 @@ impl Tile { .is_some_and(|alpha| !alpha.anim.is_done()) } + pub fn is_moving_between_workspaces(&self) -> bool { + self.move_y_animation + .as_ref() + .is_some_and(|anim| anim.is_between_workspaces) + || self + .move_x_animation + .as_ref() + .is_some_and(|anim| anim.is_between_workspaces) + } + pub fn update_render_elements(&mut self, is_active: bool, view_rect: Rectangle) { let rules = self.window.rules(); let animated_tile_size = self.animated_tile_size(); @@ -593,7 +607,11 @@ impl Tile { let current_offset = self.render_offset().x; // Preserve the previous config if ongoing. - let anim = self.move_x_animation.take().map(|move_| move_.anim); + let move_ = self.move_x_animation.take(); + let current_between = move_ + .as_ref() + .is_some_and(|move_| move_.is_between_workspaces); + let anim = move_.map(|move_| move_.anim); let anim = anim .map(|anim| anim.restarted(1., 0., 0.)) .unwrap_or_else(|| Animation::new(self.clock.clone(), 1., 0., 0., config)); @@ -601,6 +619,7 @@ impl Tile { self.move_x_animation = Some(MoveAnimation { anim, from: from + current_offset, + is_between_workspaces: current_between, }); } @@ -612,7 +631,11 @@ impl Tile { let current_offset = self.render_offset().y; // Preserve the previous config if ongoing. - let anim = self.move_y_animation.take().map(|move_| move_.anim); + let move_ = self.move_y_animation.take(); + let current_between = move_ + .as_ref() + .is_some_and(|move_| move_.is_between_workspaces); + let anim = move_.map(|move_| move_.anim); let anim = anim .map(|anim| anim.restarted(1., 0., 0.)) .unwrap_or_else(|| Animation::new(self.clock.clone(), 1., 0., 0., config)); @@ -620,6 +643,7 @@ impl Tile { self.move_y_animation = Some(MoveAnimation { anim, from: from + current_offset, + is_between_workspaces: current_between, }); } @@ -639,6 +663,12 @@ impl Tile { self.move_y_animation = None; } + pub fn set_anim_y_between_workspaces(&mut self) { + if let Some(anim) = &mut self.move_y_animation { + anim.is_between_workspaces = true; + } + } + pub fn animate_alpha(&mut self, from: f64, to: f64, config: niri_config::Animation) { let from = from.clamp(0., 1.); let to = to.clamp(0., 1.); diff --git a/src/layout/workspace.rs b/src/layout/workspace.rs index ae06be6f..af10629f 100644 --- a/src/layout/workspace.rs +++ b/src/layout/workspace.rs @@ -28,6 +28,7 @@ use super::{ RemovedTile, SizeFrac, }; use crate::animation::Clock; +use crate::layout::RenderLayer; use crate::niri_render_elements; use crate::render_helpers::renderer::NiriRenderer; use crate::render_helpers::shadow::ShadowRenderElement; @@ -375,21 +376,26 @@ impl Workspace { self.scrolling.are_transitions_ongoing() || self.floating.are_transitions_ongoing() } - pub fn update_render_elements(&mut self, is_active: bool) { + pub fn update_render_elements(&mut self, is_active: bool, layer: RenderLayer) { self.scrolling - .update_render_elements(is_active && !self.floating_is_active.get()); + .update_render_elements(is_active && !self.floating_is_active.get(), layer); let view_rect = Rectangle::from_size(self.view_size); - self.floating - .update_render_elements(is_active && self.floating_is_active.get(), view_rect); - - self.shadow.update_render_elements( - self.view_size, - true, - CornerRadius::default(), - self.scale.fractional_scale(), - 1., + self.floating.update_render_elements( + is_active && self.floating_is_active.get(), + view_rect, + layer, ); + + if layer.is_normal() { + self.shadow.update_render_elements( + self.view_size, + true, + CornerRadius::default(), + self.scale.fractional_scale(), + 1., + ); + } } pub fn update_config(&mut self, base_options: Rc) { @@ -1613,11 +1619,12 @@ impl Workspace { ctx: RenderCtx, xray_pos: XrayPos, focus_ring: bool, + layer: RenderLayer, push: &mut dyn FnMut(WorkspaceRenderElement), ) { let scrolling_focus_ring = focus_ring && !self.floating_is_active(); self.scrolling - .render(ctx, xray_pos, scrolling_focus_ring, &mut |elem| { + .render(ctx, xray_pos, scrolling_focus_ring, layer, &mut |elem| { push(elem.into()) }); } @@ -1627,18 +1634,23 @@ impl Workspace { ctx: RenderCtx, xray_pos: XrayPos, focus_ring: bool, + layer: RenderLayer, push: &mut dyn FnMut(WorkspaceRenderElement), ) { - if !self.is_floating_visible() { + if !self.is_floating_visible() && layer.is_normal() { return; } let view_rect = Rectangle::from_size(self.view_size); let floating_focus_ring = focus_ring && self.floating_is_active(); - self.floating - .render(ctx, xray_pos, view_rect, floating_focus_ring, &mut |elem| { - push(elem.into()) - }); + self.floating.render( + ctx, + xray_pos, + view_rect, + floating_focus_ring, + layer, + &mut |elem| push(elem.into()), + ); } pub fn render_shadow( @@ -1964,6 +1976,10 @@ impl Workspace { &self.scrolling } + pub fn scrolling_mut(&mut self) -> &mut ScrollingSpace { + &mut self.scrolling + } + pub fn floating(&self) -> &FloatingSpace { &self.floating }