From 88116b9fb1f93d6175a58a36c6fdd1fb8b240a3f Mon Sep 17 00:00:00 2001 From: Ivan Molodetskikh Date: Tue, 24 Dec 2024 11:34:20 +0300 Subject: Preserve tile when moving across monitors --- src/layout/mod.rs | 66 ++++++++++++++++-------------------------------------- src/layout/tile.rs | 4 ---- 2 files changed, 19 insertions(+), 51 deletions(-) (limited to 'src/layout') diff --git a/src/layout/mod.rs b/src/layout/mod.rs index 2ed08ba8..07877914 100644 --- a/src/layout/mod.rs +++ b/src/layout/mod.rs @@ -794,40 +794,6 @@ impl Layout { } } - // TODO: pos - pub fn add_window_by_idx( - &mut self, - monitor_idx: usize, - workspace_idx: usize, - window: W, - activate: bool, - width: ColumnWidth, - is_full_width: bool, - is_floating: bool, - ) { - let MonitorSet::Normal { - monitors, - active_monitor_idx, - .. - } = &mut self.monitor_set - else { - panic!() - }; - - monitors[monitor_idx].add_window( - workspace_idx, - window, - activate, - width, - is_full_width, - is_floating, - ); - - if activate { - *active_monitor_idx = monitor_idx; - } - } - /// Adds a new window to the layout on a specific workspace. pub fn add_window_to_named_workspace( &mut self, @@ -2839,7 +2805,7 @@ impl Layout { let ws = &mut mon.workspaces[ws_idx]; let transaction = Transaction::new(); - let removed = if let Some(window) = window { + let mut removed = if let Some(window) = window { ws.remove_tile(window, transaction) } else if let Some(removed) = ws.remove_active_tile(transaction) { removed @@ -2847,19 +2813,25 @@ impl Layout { return; }; - self.add_window_by_idx( - new_idx, - workspace_idx, - removed.tile.into_window(), - activate, - removed.width, - removed.is_full_width, - removed.is_floating, - ); + removed.tile.stop_move_animations(); + + let mon = &mut monitors[new_idx]; + if removed.is_floating { + mon.add_floating_tile(workspace_idx, removed.tile, activate); + } else { + mon.add_tile( + workspace_idx, + None, + removed.tile, + activate, + removed.width, + removed.is_full_width, + ); + } + if activate { + *active_monitor_idx = new_idx; + } - let MonitorSet::Normal { monitors, .. } = &mut self.monitor_set else { - unreachable!() - }; let mon = &mut monitors[mon_idx]; if mon.workspace_switch.is_none() { monitors[mon_idx].clean_up_workspaces(); diff --git a/src/layout/tile.rs b/src/layout/tile.rs index 586b950a..21b8f52c 100644 --- a/src/layout/tile.rs +++ b/src/layout/tile.rs @@ -408,10 +408,6 @@ impl Tile { &mut self.window } - pub fn into_window(self) -> W { - self.window - } - pub fn is_fullscreen(&self) -> bool { self.is_fullscreen } -- cgit