forge
Explore
Log in

Don't you dare go Hollow

layout: Match view animation when moving between workspaces

Browse files at this commit

97c96a13829ec74c83e976c2ea34e7cc717b02ecIvan MolodetskikhParent: 782f459
Quite ugly having to pass the anim config everywhere...
src/layout/mod.rsmodified+6 -1
@@ -932,7 +932,7 @@ impl<W: LayoutElement> Layout<W> {
932 panic!()932 panic!()
933 };933 };
934 934
935- monitors[monitor_idx].add_column(workspace_idx, column, activate);935+ monitors[monitor_idx].add_column(workspace_idx, column, activate, None);
936 936
937 if activate {937 if activate {
938 *active_monitor_idx = monitor_idx;938 *active_monitor_idx = monitor_idx;
@@ -1110,6 +1110,7 @@ impl<W: LayoutElement> Layout<W> {
1110 scrolling_width,1110 scrolling_width,
1111 is_full_width,1111 is_full_width,
1112 is_floating,1112 is_floating,
1113+ None,
1113 );1114 );
1114 1115
1115 // Set the default height for scrolling windows.1116 // Set the default height for scrolling windows.
@@ -3381,6 +3382,7 @@ impl<W: LayoutElement> Layout<W> {
3381 removed.width,3382 removed.width,
3382 removed.is_full_width,3383 removed.is_full_width,
3383 removed.is_floating,3384 removed.is_floating,
3385+ None,
3384 );3386 );
3385 if activate.map_smart(|| false) {3387 if activate.map_smart(|| false) {
3386 *active_monitor_idx = new_idx;3388 *active_monitor_idx = new_idx;
@@ -4252,6 +4254,7 @@ impl<W: LayoutElement> Layout<W> {
4252 move_.width,4254 move_.width,
4253 move_.is_full_width,4255 move_.is_full_width,
4254 false,4256 false,
4257+ None,
4255 );4258 );
4256 }4259 }
4257 InsertPosition::InColumn(column_idx, tile_idx) => {4260 InsertPosition::InColumn(column_idx, tile_idx) => {
@@ -4306,6 +4309,7 @@ impl<W: LayoutElement> Layout<W> {
4306 move_.width,4309 move_.width,
4307 move_.is_full_width,4310 move_.is_full_width,
4308 true,4311 true,
4312+ None,
4309 );4313 );
4310 }4314 }
4311 }4315 }
@@ -4347,6 +4351,7 @@ impl<W: LayoutElement> Layout<W> {
4347 move_.width,4351 move_.width,
4348 move_.is_full_width,4352 move_.is_full_width,
4349 move_.is_floating,4353 move_.is_floating,
4354+ None,
4350 );4355 );
4351 }4356 }
4352 }4357 }
src/layout/monitor.rsmodified+35 -16
@@ -540,13 +540,20 @@ impl<W: LayoutElement> Monitor<W> {
540 width,540 width,
541 is_full_width,541 is_full_width,
542 is_floating,542 is_floating,
543+ None,
543 );544 );
544 }545 }
545 546
546- pub fn add_column(&mut self, mut workspace_idx: usize, column: Column<W>, activate: bool) {547+ pub fn add_column(
548+ &mut self,
549+ mut workspace_idx: usize,
550+ column: Column<W>,
551+ activate: bool,
552+ anim: Option<niri_config::Animation>,
553+ ) {
547 let workspace = &mut self.workspaces[workspace_idx];554 let workspace = &mut self.workspaces[workspace_idx];
548 555
549- workspace.add_column(column, activate);556+ workspace.add_column(column, activate, anim);
550 557
551 // After adding a new window, workspace becomes this output's own.558 // After adding a new window, workspace becomes this output's own.
552 if workspace.name().is_none() {559 if workspace.name().is_none() {
@@ -577,12 +584,21 @@ impl<W: LayoutElement> Monitor<W> {
577 width: ColumnWidth,584 width: ColumnWidth,
578 is_full_width: bool,585 is_full_width: bool,
579 is_floating: bool,586 is_floating: bool,
587+ anim: Option<niri_config::Animation>,
580 ) {588 ) {
581 let (mut workspace_idx, target) = self.resolve_add_window_target(target);589 let (mut workspace_idx, target) = self.resolve_add_window_target(target);
582 590
583 let workspace = &mut self.workspaces[workspace_idx];591 let workspace = &mut self.workspaces[workspace_idx];
584 592
585- workspace.add_tile(tile, target, activate, width, is_full_width, is_floating);593+ workspace.add_tile(
594+ tile,
595+ target,
596+ activate,
597+ width,
598+ is_full_width,
599+ is_floating,
600+ anim,
601+ );
586 602
587 // After adding a new window, workspace becomes this output's own.603 // After adding a new window, workspace becomes this output's own.
588 if workspace.name().is_none() {604 if workspace.name().is_none() {
@@ -842,6 +858,13 @@ impl<W: LayoutElement> Monitor<W> {
842 let transaction = Transaction::new();858 let transaction = Transaction::new();
843 let removed = workspace.remove_tile(&window, transaction);859 let removed = workspace.remove_tile(&window, transaction);
844 860
861+ // If the view is following the tile, match the animation.
862+ let config = if activate {
863+ self.options.animations.workspace_switch.0
864+ } else {
865+ self.options.animations.window_movement.0
866+ };
867+
845 self.add_tile(868 self.add_tile(
846 removed.tile,869 removed.tile,
847 MonitorAddWindowTarget::Workspace {870 MonitorAddWindowTarget::Workspace {
@@ -857,6 +880,7 @@ impl<W: LayoutElement> Monitor<W> {
857 removed.width,880 removed.width,
858 removed.is_full_width,881 removed.is_full_width,
859 removed.is_floating,882 removed.is_floating,
883+ Some(config),
860 );884 );
861 885
862 if self.workspace_switch.is_none() {886 if self.workspace_switch.is_none() {
@@ -879,12 +903,6 @@ impl<W: LayoutElement> Monitor<W> {
879 .tiles_with_render_positions_mut(false)903 .tiles_with_render_positions_mut(false)
880 .find(|(tile, _)| tile.window().id() == &window)904 .find(|(tile, _)| tile.window().id() == &window)
881 .unwrap();905 .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);906 tile.animate_move_from_with_config(old_render_pos - new_render_pos, config);
889 tile.set_anim_y_between_workspaces();907 tile.set_anim_y_between_workspaces();
890 }908 }
@@ -933,8 +951,15 @@ impl<W: LayoutElement> Monitor<W> {
933 old_render_pos.y +=951 old_render_pos.y +=
934 self.workspace_size_with_gap(1.).h * (source_workspace_idx as f64 - new_idx as f64);952 self.workspace_size_with_gap(1.).h * (source_workspace_idx as f64 - new_idx as f64);
935 953
954+ // If the view is following the column, match the animation.
955+ let config = if activate {
956+ self.options.animations.workspace_switch.0
957+ } else {
958+ self.options.animations.window_movement.0
959+ };
960+
936 let new_id = self.workspaces[new_idx].id();961 let new_id = self.workspaces[new_idx].id();
937- self.add_column(new_idx, column, activate);962+ self.add_column(new_idx, column, activate, Some(config));
938 963
939 let new_idx = self.idx_of_ws(new_id).unwrap();964 let new_idx = self.idx_of_ws(new_id).unwrap();
940 let (column, new_render_pos) = self.workspaces[new_idx]965 let (column, new_render_pos) = self.workspaces[new_idx]
@@ -942,12 +967,6 @@ impl<W: LayoutElement> Monitor<W> {
942 .columns_with_render_positions_mut()967 .columns_with_render_positions_mut()
943 .find(|(col, _pos)| col.id() == id)968 .find(|(col, _pos)| col.id() == id)
944 .unwrap();969 .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);970 column.animate_move_from_with_config(old_render_pos - new_render_pos, config);
952 column.set_anim_y_between_workspaces();971 column.set_anim_y_between_workspaces();
953 }972 }
src/layout/scrolling.rsmodified+4 -3
@@ -907,7 +907,7 @@ impl<W: LayoutElement> ScrollingSpace<W> {
907 activate: bool,907 activate: bool,
908 width: ColumnWidth,908 width: ColumnWidth,
909 is_full_width: bool,909 is_full_width: bool,
910- anim_config: Option<niri_config::Animation>,910+ anim: Option<niri_config::Animation>,
911 ) {911 ) {
912 let column = Column::new_with_tile(912 let column = Column::new_with_tile(
913 tile,913 tile,
@@ -919,7 +919,7 @@ impl<W: LayoutElement> ScrollingSpace<W> {
919 is_full_width,919 is_full_width,
920 );920 );
921 921
922- self.add_column(col_idx, column, activate, anim_config);922+ self.add_column(col_idx, column, activate, anim);
923 }923 }
924 924
925 pub fn add_tile_to_column(925 pub fn add_tile_to_column(
@@ -984,6 +984,7 @@ impl<W: LayoutElement> ScrollingSpace<W> {
984 activate: bool,984 activate: bool,
985 width: ColumnWidth,985 width: ColumnWidth,
986 is_full_width: bool,986 is_full_width: bool,
987+ anim: Option<niri_config::Animation>,
987 ) {988 ) {
988 let right_of_idx = self989 let right_of_idx = self
989 .columns990 .columns
@@ -992,7 +993,7 @@ impl<W: LayoutElement> ScrollingSpace<W> {
992 .unwrap();993 .unwrap();
993 let col_idx = right_of_idx + 1;994 let col_idx = right_of_idx + 1;
994 995
995- self.add_tile(Some(col_idx), tile, activate, width, is_full_width, None);996+ self.add_tile(Some(col_idx), tile, activate, width, is_full_width, anim);
996 }997 }
997 998
998 pub fn add_column(999 pub fn add_column(
src/layout/workspace.rsmodified+20 -7
@@ -604,6 +604,7 @@ impl<W: LayoutElement> Workspace<W> {
604 )604 )
605 }605 }
606 606
607+ #[allow(clippy::too_many_arguments)]
607 pub fn add_tile(608 pub fn add_tile(
608 &mut self,609 &mut self,
609 mut tile: Tile<W>,610 mut tile: Tile<W>,
@@ -612,6 +613,7 @@ impl<W: LayoutElement> Workspace<W> {
612 width: ColumnWidth,613 width: ColumnWidth,
613 is_full_width: bool,614 is_full_width: bool,
614 is_floating: bool,615 is_floating: bool,
616+ anim: Option<niri_config::Animation>,
615 ) {617 ) {
616 self.enter_output_for_window(tile.window());618 self.enter_output_for_window(tile.window());
617 tile.restore_to_floating = is_floating;619 tile.restore_to_floating = is_floating;
@@ -631,7 +633,7 @@ impl<W: LayoutElement> Workspace<W> {
631 }633 }
632 } else {634 } else {
633 self.scrolling635 self.scrolling
634- .add_tile(None, tile, activate, width, is_full_width, None);636+ .add_tile(None, tile, activate, width, is_full_width, anim);
635 637
636 if activate {638 if activate {
637 self.floating_is_active = FloatingActive::No;639 self.floating_is_active = FloatingActive::No;
@@ -641,7 +643,7 @@ impl<W: LayoutElement> Workspace<W> {
641 WorkspaceAddWindowTarget::NewColumnAt(col_idx) => {643 WorkspaceAddWindowTarget::NewColumnAt(col_idx) => {
642 let activate = activate.map_smart(|| false);644 let activate = activate.map_smart(|| false);
643 self.scrolling645 self.scrolling
644- .add_tile(Some(col_idx), tile, activate, width, is_full_width, None);646+ .add_tile(Some(col_idx), tile, activate, width, is_full_width, anim);
645 647
646 if activate {648 if activate {
647 self.floating_is_active = FloatingActive::No;649 self.floating_is_active = FloatingActive::No;
@@ -681,14 +683,20 @@ impl<W: LayoutElement> Workspace<W> {
681 }683 }
682 } else if floating_has_window {684 } else if floating_has_window {
683 self.scrolling685 self.scrolling
684- .add_tile(None, tile, activate, width, is_full_width, None);686+ .add_tile(None, tile, activate, width, is_full_width, anim);
685 687
686 if activate {688 if activate {
687 self.floating_is_active = FloatingActive::No;689 self.floating_is_active = FloatingActive::No;
688 }690 }
689 } else {691 } else {
690- self.scrolling692+ self.scrolling.add_tile_right_of(
691- .add_tile_right_of(next_to, tile, activate, width, is_full_width);693+ next_to,
694+ tile,
695+ activate,
696+ width,
697+ is_full_width,
698+ anim,
699+ );
692 700
693 if activate {701 if activate {
694 self.floating_is_active = FloatingActive::No;702 self.floating_is_active = FloatingActive::No;
@@ -714,12 +722,17 @@ impl<W: LayoutElement> Workspace<W> {
714 }722 }
715 }723 }
716 724
717- pub fn add_column(&mut self, column: Column<W>, activate: bool) {725+ pub fn add_column(
726+ &mut self,
727+ column: Column<W>,
728+ activate: bool,
729+ anim: Option<niri_config::Animation>,
730+ ) {
718 for (tile, _) in column.tiles() {731 for (tile, _) in column.tiles() {
719 self.enter_output_for_window(tile.window());732 self.enter_output_for_window(tile.window());
720 }733 }
721 734
722- self.scrolling.add_column(None, column, activate, None);735+ self.scrolling.add_column(None, column, activate, anim);
723 736
724 if activate {737 if activate {
725 self.floating_is_active = FloatingActive::No;738 self.floating_is_active = FloatingActive::No;