forge
Explore
Log in

Don't you dare go Hollow

layout: Animate column/tile movement between workspaces

Browse files at this commit

782f459010e8463a354d97f2fde21d65dbe6a613Ivan MolodetskikhParent: ded793d
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.rsmodified+23 -4
@@ -16,6 +16,7 @@ use super::{
1616 ConfigureIntent, InteractiveResizeData, LayoutElement, Options, RemovedTile, SizeFrac,
1717 };
1818 use crate::animation::{Animation, Clock};
19+use crate::layout::RenderLayer;
1920 use crate::niri_render_elements;
2021 use crate::render_helpers::renderer::NiriRenderer;
2122 use crate::render_helpers::xray::XrayPos;
@@ -265,9 +266,19 @@ impl<W: LayoutElement> FloatingSpace<W> {
265266 self.tiles.iter().any(Tile::are_transitions_ongoing) || !self.closing_windows.is_empty()
266267 }
267268
268- pub fn update_render_elements(&mut self, is_active: bool, view_rect: Rectangle<f64, Logical>) {
269+ pub fn update_render_elements(
270+ &mut self,
271+ is_active: bool,
272+ view_rect: Rectangle<f64, Logical>,
273+ layer: RenderLayer,
274+ ) {
269275 let active = self.active_window_id.clone();
270276 for (tile, offset) in self.tiles_with_offsets_mut() {
277+ // Skip tiles belonging to a different render layer.
278+ if layer.is_normal() == tile.is_moving_between_workspaces() {
279+ continue;
280+ }
281+
271282 let id = tile.window().id();
272283 let is_active = is_active && Some(id) == active.as_ref();
273284
@@ -1057,6 +1068,7 @@ impl<W: LayoutElement> FloatingSpace<W> {
10571068 xray_pos: XrayPos,
10581069 view_rect: Rectangle<f64, Logical>,
10591070 focus_ring: bool,
1071+ layer: RenderLayer,
10601072 push: &mut dyn FnMut(FloatingSpaceRenderElement<R>),
10611073 ) {
10621074 let scale = Scale::from(self.scale);
@@ -1064,13 +1076,20 @@ impl<W: LayoutElement> FloatingSpace<W> {
10641076 // Draw the closing windows on top of the other windows.
10651077 //
10661078 // FIXME: I guess this should rather preserve the stacking order when the window is closed.
1067- for closing in self.closing_windows.iter().rev() {
1068- let elem = closing.render(ctx.as_gles(), view_rect, scale);
1069- push(elem.into());
1079+ if layer.is_normal() {
1080+ for closing in self.closing_windows.iter().rev() {
1081+ let elem = closing.render(ctx.as_gles(), view_rect, scale);
1082+ push(elem.into());
1083+ }
10701084 }
10711085
10721086 let active = self.active_window_id.clone();
10731087 for (tile, tile_pos) in self.tiles_with_render_positions() {
1088+ // Skip tiles belonging to a different render layer.
1089+ if layer.is_normal() == tile.is_moving_between_workspaces() {
1090+ continue;
1091+ }
1092+
10741093 // For the active tile, draw the focus ring.
10751094 let focus_ring = focus_ring && Some(tile.window().id()) == active.as_ref();
10761095
src/layout/mod.rsmodified+25 -0
@@ -558,6 +558,14 @@ struct OverviewGesture {
558558 value: f64,
559559 }
560560
561+/// Layer of windows to render.
562+#[derive(Clone, Copy)]
563+pub enum RenderLayer {
564+ Normal,
565+ /// Windows currently moving between workspaces.
566+ MovingBetweenWorkspaces,
567+}
568+
561569 impl SizingMode {
562570 #[must_use]
563571 pub fn is_normal(&self) -> bool {
@@ -687,6 +695,16 @@ impl OverviewProgress {
687695 }
688696 }
689697
698+impl RenderLayer {
699+ /// Returns `true` if the render layer is [`Normal`].
700+ ///
701+ /// [`Normal`]: RenderLayer::Normal
702+ #[must_use]
703+ pub fn is_normal(&self) -> bool {
704+ matches!(self, Self::Normal)
705+ }
706+}
707+
690708 impl<W: LayoutElement> Layout<W> {
691709 pub fn new(clock: Clock, config: &Config) -> Self {
692710 Self::with_options_and_workspaces(clock, config, Options::from_config(config))
@@ -4304,6 +4322,13 @@ impl<W: LayoutElement> Layout<W> {
43044322 let new_tile_render_loc = ws_geo.loc + tile_offset.upscale(zoom);
43054323
43064324 tile.animate_move_from((tile_render_loc - new_tile_render_loc).downscale(zoom));
4325+
4326+ // Interactive move into floating barely animates (it doesn't really move after
4327+ // being dropped), so setting it as moving between workspaces would just cause it to
4328+ // awkwardly sit unclipped for a moment before the animation runs out.
4329+ if !matches!(position, InsertPosition::Floating) {
4330+ tile.set_anim_y_between_workspaces();
4331+ }
43074332 }
43084333 MonitorSet::NoOutputs { workspaces, .. } => {
43094334 if workspaces.is_empty() {
src/layout/monitor.rsmodified+174 -48
@@ -20,6 +20,7 @@ use super::workspace::{
2020 use super::{compute_overview_zoom, ActivateWindow, HitType, LayoutElement, Options};
2121 use crate::animation::{Animation, Clock};
2222 use crate::input::swipe_tracker::SwipeTracker;
23+use crate::layout::RenderLayer;
2324 use crate::niri_render_elements;
2425 use crate::render_helpers::renderer::NiriRenderer;
2526 use crate::render_helpers::shadow::ShadowRenderElement;
@@ -815,6 +816,7 @@ impl<W: LayoutElement> Monitor<W> {
815816 } else {
816817 self.active_workspace_idx
817818 };
819+ let source_id = self.workspaces[source_workspace_idx].id();
818820
819821 let new_idx = min(idx, self.workspaces.len() - 1);
820822 if new_idx == source_workspace_idx {
@@ -832,6 +834,11 @@ impl<W: LayoutElement> Monitor<W> {
832834 };
833835 let window = window.clone();
834836
837+ let mut old_render_pos = workspace
838+ .tiles_with_render_positions()
839+ .find_map(|(tile, offset, _visible)| (tile.window().id() == &window).then_some(offset))
840+ .unwrap();
841+
835842 let transaction = Transaction::new();
836843 let removed = workspace.remove_tile(&window, transaction);
837844
@@ -855,6 +862,31 @@ impl<W: LayoutElement> Monitor<W> {
855862 if self.workspace_switch.is_none() {
856863 self.clean_up_workspaces();
857864 }
865+
866+ let new_idx = self.idx_of_ws(new_id).unwrap();
867+
868+ // Animate vertical movement between workspaces.
869+ //
870+ // Recompute the source idx in case some workspace was removed during clean-up. If the
871+ // source workspace itself was removed, don't bother animating this since the removal is
872+ // instant anyway.
873+ if let Some(source_workspace_idx) = self.idx_of_ws(source_id) {
874+ old_render_pos.y +=
875+ self.workspace_size_with_gap(1.).h * (source_workspace_idx as f64 - new_idx as f64);
876+ }
877+
878+ let (tile, new_render_pos) = self.workspaces[new_idx]
879+ .tiles_with_render_positions_mut(false)
880+ .find(|(tile, _)| tile.window().id() == &window)
881+ .unwrap();
882+ // If the view is following the tile, match the animation.
883+ let config = if activate {
884+ self.options.animations.workspace_switch.0
885+ } else {
886+ self.options.animations.window_movement.0
887+ };
888+ tile.animate_move_from_with_config(old_render_pos - new_render_pos, config);
889+ tile.set_anim_y_between_workspaces();
858890 }
859891
860892 pub fn move_column_to_workspace_up(&mut self, activate: bool) {
@@ -886,11 +918,38 @@ impl<W: LayoutElement> Monitor<W> {
886918 return;
887919 }
888920
889- let Some(column) = workspace.remove_active_column() else {
921+ let Some(id) = workspace.scrolling().active_column().map(Column::id) else {
890922 return;
891923 };
924+ let mut old_render_pos = workspace
925+ .scrolling()
926+ .columns_with_render_positions()
927+ .find_map(|(col, pos)| (col.id() == id).then_some(pos))
928+ .unwrap();
892929
930+ let column = workspace.remove_active_column().unwrap();
931+
932+ // Animate vertical movement between workspaces.
933+ old_render_pos.y +=
934+ self.workspace_size_with_gap(1.).h * (source_workspace_idx as f64 - new_idx as f64);
935+
936+ let new_id = self.workspaces[new_idx].id();
893937 self.add_column(new_idx, column, activate);
938+
939+ let new_idx = self.idx_of_ws(new_id).unwrap();
940+ let (column, new_render_pos) = self.workspaces[new_idx]
941+ .scrolling_mut()
942+ .columns_with_render_positions_mut()
943+ .find(|(col, _pos)| col.id() == id)
944+ .unwrap();
945+ // If the view is following the tile, match the animation.
946+ let config = if activate {
947+ self.options.animations.workspace_switch.0
948+ } else {
949+ self.options.animations.window_movement.0
950+ };
951+ column.animate_move_from_with_config(old_render_pos - new_render_pos, config);
952+ column.set_anim_y_between_workspaces();
894953 }
895954
896955 pub fn switch_workspace_up(&mut self) {
@@ -1014,8 +1073,12 @@ impl<W: LayoutElement> Monitor<W> {
10141073 .as_ref()
10151074 .and_then(|hint| hint.workspace.existing_id());
10161075
1076+ for ws in &mut self.workspaces {
1077+ ws.update_render_elements(is_active, RenderLayer::MovingBetweenWorkspaces);
1078+ }
1079+
10171080 for (ws, geo) in self.workspaces_with_render_geo_mut(true) {
1018- ws.update_render_elements(is_active);
1081+ ws.update_render_elements(is_active, RenderLayer::Normal);
10191082
10201083 if Some(ws.id()) == insert_hint_ws_id {
10211084 insert_hint_ws_geo = Some(geo);
@@ -1421,15 +1484,22 @@ impl<W: LayoutElement> Monitor<W> {
14211484 })
14221485 }
14231486
1424- pub fn workspaces_with_render_geo(
1487+ pub fn workspaces_with_render_geo_cull(
14251488 &self,
1489+ cull: bool,
14261490 ) -> impl Iterator<Item = (&Workspace<W>, Rectangle<f64, Logical>)> {
14271491 let output_geo = Rectangle::from_size(self.view_size);
14281492
14291493 let geo = self.workspaces_render_geo();
14301494 zip(self.workspaces.iter(), geo)
14311495 // Cull out workspaces outside the output.
1432- .filter(move |(_ws, geo)| geo.intersection(output_geo).is_some())
1496+ .filter(move |(_ws, geo)| !cull || geo.intersection(output_geo).is_some())
1497+ }
1498+
1499+ pub fn workspaces_with_render_geo(
1500+ &self,
1501+ ) -> impl Iterator<Item = (&Workspace<W>, Rectangle<f64, Logical>)> {
1502+ self.workspaces_with_render_geo_cull(true)
14331503 }
14341504
14351505 pub fn workspaces_with_render_geo_idx(
@@ -1599,28 +1669,6 @@ impl<W: LayoutElement> Monitor<W> {
15991669 // Ceil the height in physical pixels.
16001670 let height = (self.view_size.h * scale).ceil() as i32;
16011671
1602- // Crop the elements to prevent them overflowing, currently visible during a workspace
1603- // switch.
1604- //
1605- // HACK: crop to infinite bounds at least horizontally where we
1606- // know there's no workspace joining or monitor bounds, otherwise
1607- // it will cut pixel shaders and mess up the coordinate space.
1608- // There's also a damage tracking bug which causes glitched
1609- // rendering for maximized GTK windows.
1610- //
1611- // FIXME: use proper bounds after fixing the Crop element.
1612- let crop_bounds = if self.workspace_switch.is_some() || self.overview_progress.is_some() {
1613- Rectangle::new(
1614- Point::from((-i32::MAX / 2, 0)),
1615- Size::from((i32::MAX, height)),
1616- )
1617- } else {
1618- Rectangle::new(
1619- Point::from((-i32::MAX / 2, -i32::MAX / 2)),
1620- Size::from((i32::MAX, i32::MAX)),
1621- )
1622- };
1623-
16241672 let zoom = self.overview_zoom();
16251673
16261674 let insert_hint_render_loc = self
@@ -1639,32 +1687,110 @@ impl<W: LayoutElement> Monitor<W> {
16391687 )
16401688 };
16411689
1642- for (ws, geo) in self.workspaces_with_render_geo() {
1643- // Macro instead of closure because ws and insert hint have different elem types.
1644- macro_rules! push {
1645- () => {{
1646- &mut |elem| {
1647- let elem = CropRenderElement::from_element(elem, scale, crop_bounds);
1648- if let Some(elem) = elem {
1649- let elem = MonitorInnerRenderElement::from(elem);
1650- push(scale_relocate(geo, elem));
1651- }
1652- }
1653- }};
1654- }
1655-
1656- let xray_pos = XrayPos::new(geo.loc, zoom);
1690+ // Draw in passes for correct Z ordering during window movement between workspaces:
1691+ // - floating windows moving between workspaces
1692+ // - normal floating windows
1693+ // - scrolling windows moving between workspaces
1694+ // - normal scrolling windows
1695+ for pass in 0..4 {
1696+ // Don't cull when drawing windows moving between workspaces so that windows moving to
1697+ // workspaces off-screen will still render.
1698+ let cull = matches!(pass, 1 | 3);
1699+
1700+ // Crop the elements to prevent them overflowing, currently visible during a workspace
1701+ // switch.
1702+ //
1703+ // HACK: crop to infinite bounds at least horizontally where we
1704+ // know there's no workspace joining or monitor bounds, otherwise
1705+ // it will cut pixel shaders and mess up the coordinate space.
1706+ // There's also a damage tracking bug which causes glitched
1707+ // rendering for maximized GTK windows.
1708+ //
1709+ // FIXME: use proper bounds after fixing the Crop element.
1710+ //
1711+ // Also, check cull here to avoid cropping windows moving between workspaces.
1712+ //
1713+ // FIXME: for cull=true, it might be better visually to crop to a workspace-high region
1714+ // anchored to the window/column as it moves between workspaces, to prevent overflowing
1715+ // windows from appearing and disappearing.
1716+ let crop_bounds =
1717+ if cull && (self.workspace_switch.is_some() || self.overview_progress.is_some()) {
1718+ Rectangle::new(
1719+ Point::from((-i32::MAX / 2, 0)),
1720+ Size::from((i32::MAX, height)),
1721+ )
1722+ } else {
1723+ Rectangle::new(
1724+ Point::from((-i32::MAX / 2, -i32::MAX / 2)),
1725+ Size::from((i32::MAX, i32::MAX)),
1726+ )
1727+ };
16571728
1658- ws.render_floating(ctx.r(), xray_pos, focus_ring, push!());
1729+ for (ws, geo) in self.workspaces_with_render_geo_cull(cull) {
1730+ // Macro instead of closure because ws and insert hint have different elem types.
1731+ macro_rules! push {
1732+ () => {{
1733+ &mut |elem| {
1734+ let elem = CropRenderElement::from_element(elem, scale, crop_bounds);
1735+ if let Some(elem) = elem {
1736+ let elem = MonitorInnerRenderElement::from(elem);
1737+ push(scale_relocate(geo, elem));
1738+ }
1739+ }
1740+ }};
1741+ }
16591742
1660- if let Some(loc) = insert_hint_render_loc {
1661- if loc.workspace == InsertWorkspace::Existing(ws.id()) {
1662- self.insert_hint_element
1663- .render(ctx.renderer, loc.location, push!());
1743+ let xray_pos = XrayPos::new(geo.loc, zoom);
1744+
1745+ match pass {
1746+ 0 => {
1747+ ws.render_floating(
1748+ ctx.r(),
1749+ xray_pos,
1750+ focus_ring,
1751+ RenderLayer::MovingBetweenWorkspaces,
1752+ push!(),
1753+ );
1754+ }
1755+ 1 => {
1756+ ws.render_floating(
1757+ ctx.r(),
1758+ xray_pos,
1759+ focus_ring,
1760+ RenderLayer::Normal,
1761+ push!(),
1762+ );
1763+
1764+ if let Some(loc) = insert_hint_render_loc {
1765+ if loc.workspace == InsertWorkspace::Existing(ws.id()) {
1766+ self.insert_hint_element.render(
1767+ ctx.renderer,
1768+ loc.location,
1769+ push!(),
1770+ );
1771+ }
1772+ }
1773+ }
1774+ 2 => {
1775+ ws.render_scrolling(
1776+ ctx.r(),
1777+ xray_pos,
1778+ focus_ring,
1779+ RenderLayer::MovingBetweenWorkspaces,
1780+ push!(),
1781+ );
1782+ }
1783+ _ => {
1784+ ws.render_scrolling(
1785+ ctx.r(),
1786+ xray_pos,
1787+ focus_ring,
1788+ RenderLayer::Normal,
1789+ push!(),
1790+ );
1791+ }
16641792 }
16651793 }
1666-
1667- ws.render_scrolling(ctx.r(), xray_pos, focus_ring, push!());
16681794 }
16691795 }
16701796
src/layout/scrolling.rsmodified+68 -14
@@ -18,7 +18,7 @@ use super::workspace::{InteractiveResize, ResolvedSize};
1818 use super::{ConfigureIntent, HitType, InteractiveResizeData, LayoutElement, Options, RemovedTile};
1919 use crate::animation::{Animation, Clock};
2020 use crate::input::swipe_tracker::SwipeTracker;
21-use crate::layout::SizingMode;
21+use crate::layout::{RenderLayer, SizingMode};
2222 use crate::niri_render_elements;
2323 use crate::render_helpers::renderer::NiriRenderer;
2424 use crate::render_helpers::xray::XrayPos;
@@ -306,6 +306,10 @@ pub enum ScrollDirection {
306306 struct MoveAnimation {
307307 anim: Animation,
308308 from: f64,
309+ /// Whether this animation is for moving the tile between workspaces.
310+ ///
311+ /// Controls whether the tile is rendered uncropped and above others.
312+ is_between_workspaces: bool,
309313 }
310314
311315 impl<W: LayoutElement> ScrollingSpace<W> {
@@ -422,11 +426,16 @@ impl<W: LayoutElement> ScrollingSpace<W> {
422426 || !self.closing_windows.is_empty()
423427 }
424428
425- pub fn update_render_elements(&mut self, is_active: bool) {
429+ pub fn update_render_elements(&mut self, is_active: bool, layer: RenderLayer) {
426430 let view_pos = Point::from((self.view_pos(), 0.));
427431 let view_size = self.view_size;
428432 let active_idx = self.active_column_idx;
429433 for (col_idx, (col, col_x)) in self.columns_mut().enumerate() {
434+ // Skip columns belonging to a different render layer.
435+ if layer.is_normal() == col.is_moving_between_workspaces() {
436+ continue;
437+ }
438+
430439 let is_active = is_active && col_idx == active_idx;
431440 let col_off = Point::from((col_x, 0.));
432441 let col_pos = view_pos - col_off - col.render_offset();
@@ -2938,15 +2947,18 @@ impl<W: LayoutElement> ScrollingSpace<W> {
29382947 mut ctx: RenderCtx<R>,
29392948 xray_pos: XrayPos,
29402949 focus_ring: bool,
2950+ layer: RenderLayer,
29412951 push: &mut dyn FnMut(ScrollingSpaceRenderElement<R>),
29422952 ) {
29432953 let scale = Scale::from(self.scale);
29442954
29452955 // Draw the closing windows on top of the other windows.
2946- let view_rect = Rectangle::new(Point::from((self.view_pos(), 0.)), self.view_size);
2947- for closing in self.closing_windows.iter().rev() {
2948- let elem = closing.render(ctx.as_gles(), view_rect, scale);
2949- push(elem.into());
2956+ if layer.is_normal() {
2957+ let view_rect = Rectangle::new(Point::from((self.view_pos(), 0.)), self.view_size);
2958+ for closing in self.closing_windows.iter().rev() {
2959+ let elem = closing.render(ctx.as_gles(), view_rect, scale);
2960+ push(elem.into());
2961+ }
29502962 }
29512963
29522964 if self.columns.is_empty() {
@@ -2957,6 +2969,12 @@ impl<W: LayoutElement> ScrollingSpace<W> {
29572969
29582970 // This matches self.tiles_with_render_positions().
29592971 for (col, col_pos) in self.columns_with_render_positions() {
2972+ // Skip columns belonging to a different render layer.
2973+ if layer.is_normal() == col.is_moving_between_workspaces() {
2974+ first = false;
2975+ continue;
2976+ }
2977+
29602978 // Draw the tab indicator on top.
29612979 {
29622980 let pos = col_pos.to_physical_precise_round(scale).to_logical(scale);
@@ -4133,6 +4151,34 @@ impl<W: LayoutElement> Column<W> {
41334151 || self.tiles.iter().any(Tile::are_transitions_ongoing)
41344152 }
41354153
4154+ pub fn is_moving_between_workspaces(&self) -> bool {
4155+ self.move_y_animation
4156+ .as_ref()
4157+ .is_some_and(|anim| anim.is_between_workspaces)
4158+ || self
4159+ .move_x_animation
4160+ .as_ref()
4161+ .is_some_and(|anim| anim.is_between_workspaces)
4162+ // When moving a window between workspaces into the scrolling layout, it will be
4163+ // immediately put into a new column, however the Y move animation and the
4164+ // moving-between-workspaces flag will be set on the tile rather than on that new
4165+ // column. Since the scrolling layout rendering checks moving between workspaces
4166+ // per-column rather than per-tile, we need to include the tiles here.
4167+ //
4168+ // This is not always visually correct: for example, interactive-moving a tile into an
4169+ // otherwise stationary column will now cause that entire column to draw unculled. I'm
4170+ // not sure there's a good solution overall for all edge cases here. Consider that the
4171+ // column tab indicator needs to draw on top of the tiles, but in this counterexample
4172+ // above, the column is stationary, so the single moving tile would instead need to draw
4173+ // on top of the tab indicator.
4174+ //
4175+ // I'm going with this simple check for now that should look ok in most cases.
4176+ || self
4177+ .tiles
4178+ .iter()
4179+ .any(|tile| tile.is_moving_between_workspaces())
4180+ }
4181+
41364182 pub fn update_render_elements(&mut self, is_active: bool, view_rect: Rectangle<f64, Logical>) {
41374183 let active_idx = self.active_tile_idx;
41384184 for (tile_idx, (tile, tile_off)) in self.tiles_mut().enumerate() {
@@ -4227,15 +4273,16 @@ impl<W: LayoutElement> Column<W> {
42274273 from_x_offset: f64,
42284274 config: niri_config::Animation,
42294275 ) {
4230- let current_offset = self
4231- .move_x_animation
4232- .as_ref()
4233- .map_or(0., |move_| move_.from * move_.anim.value());
4276+ let (current_offset, current_between) =
4277+ self.move_x_animation.as_ref().map_or((0., false), |move_| {
4278+ (move_.from * move_.anim.value(), move_.is_between_workspaces)
4279+ });
42344280
42354281 let anim = Animation::new(self.clock.clone(), 1., 0., 0., config);
42364282 self.move_x_animation = Some(MoveAnimation {
42374283 anim,
42384284 from: from_x_offset + current_offset,
4285+ is_between_workspaces: current_between,
42394286 });
42404287 }
42414288
@@ -4251,15 +4298,16 @@ impl<W: LayoutElement> Column<W> {
42514298 from_y_offset: f64,
42524299 config: niri_config::Animation,
42534300 ) {
4254- let current_offset = self
4255- .move_y_animation
4256- .as_ref()
4257- .map_or(0., |move_| move_.from * move_.anim.value());
4301+ let (current_offset, current_between) =
4302+ self.move_y_animation.as_ref().map_or((0., false), |move_| {
4303+ (move_.from * move_.anim.value(), move_.is_between_workspaces)
4304+ });
42584305
42594306 let anim = Animation::new(self.clock.clone(), 1., 0., 0., config);
42604307 self.move_y_animation = Some(MoveAnimation {
42614308 anim,
42624309 from: from_y_offset + current_offset,
4310+ is_between_workspaces: current_between,
42634311 });
42644312 }
42654313
@@ -4274,6 +4322,12 @@ impl<W: LayoutElement> Column<W> {
42744322 }
42754323 }
42764324
4325+ pub fn set_anim_y_between_workspaces(&mut self) {
4326+ if let Some(anim) = &mut self.move_y_animation {
4327+ anim.is_between_workspaces = true;
4328+ }
4329+ }
4330+
42774331 /// Returns whether this column is currently fullscreen.
42784332 ///
42794333 /// As in, if it contains one currently-fullscreen tile, or in tabbed mode, if it contains at
src/layout/tile.rsmodified+32 -2
@@ -160,6 +160,10 @@ struct ResizeAnimation {
160160 struct MoveAnimation {
161161 anim: Animation,
162162 from: f64,
163+ /// Whether this animation is for moving the tile between workspaces.
164+ ///
165+ /// Controls whether the tile is rendered uncropped and above others.
166+ is_between_workspaces: bool,
163167 }
164168
165169 #[derive(Debug)]
@@ -456,6 +460,16 @@ impl<W: LayoutElement> Tile<W> {
456460 .is_some_and(|alpha| !alpha.anim.is_done())
457461 }
458462
463+ pub fn is_moving_between_workspaces(&self) -> bool {
464+ self.move_y_animation
465+ .as_ref()
466+ .is_some_and(|anim| anim.is_between_workspaces)
467+ || self
468+ .move_x_animation
469+ .as_ref()
470+ .is_some_and(|anim| anim.is_between_workspaces)
471+ }
472+
459473 pub fn update_render_elements(&mut self, is_active: bool, view_rect: Rectangle<f64, Logical>) {
460474 let rules = self.window.rules();
461475 let animated_tile_size = self.animated_tile_size();
@@ -593,7 +607,11 @@ impl<W: LayoutElement> Tile<W> {
593607 let current_offset = self.render_offset().x;
594608
595609 // Preserve the previous config if ongoing.
596- let anim = self.move_x_animation.take().map(|move_| move_.anim);
610+ let move_ = self.move_x_animation.take();
611+ let current_between = move_
612+ .as_ref()
613+ .is_some_and(|move_| move_.is_between_workspaces);
614+ let anim = move_.map(|move_| move_.anim);
597615 let anim = anim
598616 .map(|anim| anim.restarted(1., 0., 0.))
599617 .unwrap_or_else(|| Animation::new(self.clock.clone(), 1., 0., 0., config));
@@ -601,6 +619,7 @@ impl<W: LayoutElement> Tile<W> {
601619 self.move_x_animation = Some(MoveAnimation {
602620 anim,
603621 from: from + current_offset,
622+ is_between_workspaces: current_between,
604623 });
605624 }
606625
@@ -612,7 +631,11 @@ impl<W: LayoutElement> Tile<W> {
612631 let current_offset = self.render_offset().y;
613632
614633 // Preserve the previous config if ongoing.
615- let anim = self.move_y_animation.take().map(|move_| move_.anim);
634+ let move_ = self.move_y_animation.take();
635+ let current_between = move_
636+ .as_ref()
637+ .is_some_and(|move_| move_.is_between_workspaces);
638+ let anim = move_.map(|move_| move_.anim);
616639 let anim = anim
617640 .map(|anim| anim.restarted(1., 0., 0.))
618641 .unwrap_or_else(|| Animation::new(self.clock.clone(), 1., 0., 0., config));
@@ -620,6 +643,7 @@ impl<W: LayoutElement> Tile<W> {
620643 self.move_y_animation = Some(MoveAnimation {
621644 anim,
622645 from: from + current_offset,
646+ is_between_workspaces: current_between,
623647 });
624648 }
625649
@@ -639,6 +663,12 @@ impl<W: LayoutElement> Tile<W> {
639663 self.move_y_animation = None;
640664 }
641665
666+ pub fn set_anim_y_between_workspaces(&mut self) {
667+ if let Some(anim) = &mut self.move_y_animation {
668+ anim.is_between_workspaces = true;
669+ }
670+ }
671+
642672 pub fn animate_alpha(&mut self, from: f64, to: f64, config: niri_config::Animation) {
643673 let from = from.clamp(0., 1.);
644674 let to = to.clamp(0., 1.);
src/layout/workspace.rsmodified+33 -17
@@ -28,6 +28,7 @@ use super::{
2828 RemovedTile, SizeFrac,
2929 };
3030 use crate::animation::Clock;
31+use crate::layout::RenderLayer;
3132 use crate::niri_render_elements;
3233 use crate::render_helpers::renderer::NiriRenderer;
3334 use crate::render_helpers::shadow::ShadowRenderElement;
@@ -375,21 +376,26 @@ impl<W: LayoutElement> Workspace<W> {
375376 self.scrolling.are_transitions_ongoing() || self.floating.are_transitions_ongoing()
376377 }
377378
378- pub fn update_render_elements(&mut self, is_active: bool) {
379+ pub fn update_render_elements(&mut self, is_active: bool, layer: RenderLayer) {
379380 self.scrolling
380- .update_render_elements(is_active && !self.floating_is_active.get());
381+ .update_render_elements(is_active && !self.floating_is_active.get(), layer);
381382
382383 let view_rect = Rectangle::from_size(self.view_size);
383- self.floating
384- .update_render_elements(is_active && self.floating_is_active.get(), view_rect);
385-
386- self.shadow.update_render_elements(
387- self.view_size,
388- true,
389- CornerRadius::default(),
390- self.scale.fractional_scale(),
391- 1.,
384+ self.floating.update_render_elements(
385+ is_active && self.floating_is_active.get(),
386+ view_rect,
387+ layer,
392388 );
389+
390+ if layer.is_normal() {
391+ self.shadow.update_render_elements(
392+ self.view_size,
393+ true,
394+ CornerRadius::default(),
395+ self.scale.fractional_scale(),
396+ 1.,
397+ );
398+ }
393399 }
394400
395401 pub fn update_config(&mut self, base_options: Rc<Options>) {
@@ -1613,11 +1619,12 @@ impl<W: LayoutElement> Workspace<W> {
16131619 ctx: RenderCtx<R>,
16141620 xray_pos: XrayPos,
16151621 focus_ring: bool,
1622+ layer: RenderLayer,
16161623 push: &mut dyn FnMut(WorkspaceRenderElement<R>),
16171624 ) {
16181625 let scrolling_focus_ring = focus_ring && !self.floating_is_active();
16191626 self.scrolling
1620- .render(ctx, xray_pos, scrolling_focus_ring, &mut |elem| {
1627+ .render(ctx, xray_pos, scrolling_focus_ring, layer, &mut |elem| {
16211628 push(elem.into())
16221629 });
16231630 }
@@ -1627,18 +1634,23 @@ impl<W: LayoutElement> Workspace<W> {
16271634 ctx: RenderCtx<R>,
16281635 xray_pos: XrayPos,
16291636 focus_ring: bool,
1637+ layer: RenderLayer,
16301638 push: &mut dyn FnMut(WorkspaceRenderElement<R>),
16311639 ) {
1632- if !self.is_floating_visible() {
1640+ if !self.is_floating_visible() && layer.is_normal() {
16331641 return;
16341642 }
16351643
16361644 let view_rect = Rectangle::from_size(self.view_size);
16371645 let floating_focus_ring = focus_ring && self.floating_is_active();
1638- self.floating
1639- .render(ctx, xray_pos, view_rect, floating_focus_ring, &mut |elem| {
1640- push(elem.into())
1641- });
1646+ self.floating.render(
1647+ ctx,
1648+ xray_pos,
1649+ view_rect,
1650+ floating_focus_ring,
1651+ layer,
1652+ &mut |elem| push(elem.into()),
1653+ );
16421654 }
16431655
16441656 pub fn render_shadow<R: NiriRenderer>(
@@ -1964,6 +1976,10 @@ impl<W: LayoutElement> Workspace<W> {
19641976 &self.scrolling
19651977 }
19661978
1979+ pub fn scrolling_mut(&mut self) -> &mut ScrollingSpace<W> {
1980+ &mut self.scrolling
1981+ }
1982+
19671983 pub fn floating(&self) -> &FloatingSpace<W> {
19681984 &self.floating
19691985 }