diff options
| author | Ivan Molodetskikh <yalterz@gmail.com> | 2024-12-24 11:34:20 +0300 |
|---|---|---|
| committer | Ivan Molodetskikh <yalterz@gmail.com> | 2024-12-30 20:12:37 +0300 |
| commit | 88116b9fb1f93d6175a58a36c6fdd1fb8b240a3f (patch) | |
| tree | 325198501a1aab226f5d5e3b5bc2fc96cee1a1c7 /src/layout | |
| parent | 53e1c58cc53c3868c236cc8877816ed4aab5b7b0 (diff) | |
| download | niri-88116b9fb1f93d6175a58a36c6fdd1fb8b240a3f.tar.gz niri-88116b9fb1f93d6175a58a36c6fdd1fb8b240a3f.tar.bz2 niri-88116b9fb1f93d6175a58a36c6fdd1fb8b240a3f.zip | |
Preserve tile when moving across monitors
Diffstat (limited to 'src/layout')
| -rw-r--r-- | src/layout/mod.rs | 66 | ||||
| -rw-r--r-- | src/layout/tile.rs | 4 |
2 files changed, 19 insertions, 51 deletions
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<W: LayoutElement> Layout<W> { } } - // 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<W: LayoutElement> Layout<W> { 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<W: LayoutElement> Layout<W> { 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<W: LayoutElement> Tile<W> { &mut self.window } - pub fn into_window(self) -> W { - self.window - } - pub fn is_fullscreen(&self) -> bool { self.is_fullscreen } |
