diff options
| author | Ivan Molodetskikh <yalterz@gmail.com> | 2023-08-16 08:03:20 +0400 |
|---|---|---|
| committer | Ivan Molodetskikh <yalterz@gmail.com> | 2023-08-16 08:03:20 +0400 |
| commit | d96daf68a7d1b843b5231e2c416349214c5629d2 (patch) | |
| tree | 6188bf97bc2aee9455d5148bce5427c942caa278 /src/layout.rs | |
| parent | 81e8e6e7ce9e933298366141ed00905e7dfd725e (diff) | |
| download | niri-d96daf68a7d1b843b5231e2c416349214c5629d2.tar.gz niri-d96daf68a7d1b843b5231e2c416349214c5629d2.tar.bz2 niri-d96daf68a7d1b843b5231e2c416349214c5629d2.zip | |
Add binds to move between monitors
Diffstat (limited to 'src/layout.rs')
| -rw-r--r-- | src/layout.rs | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/src/layout.rs b/src/layout.rs index 7dc89c3d..8dba3eed 100644 --- a/src/layout.rs +++ b/src/layout.rs @@ -776,6 +776,48 @@ impl<W: LayoutElement> MonitorSet<W> { }; monitor.toggle_full_width(); } + + pub fn focus_output(&mut self, output: &Output) { + if let MonitorSet::Normal { + monitors, + active_monitor_idx, + .. + } = self + { + for (idx, mon) in monitors.iter().enumerate() { + if &mon.output == output { + *active_monitor_idx = idx; + return; + } + } + } + } + + pub fn move_to_output(&mut self, output: &Output) { + if let MonitorSet::Normal { + monitors, + active_monitor_idx, + .. + } = self + { + let new_idx = monitors + .iter() + .position(|mon| &mon.output == output) + .unwrap(); + + let current = &mut monitors[*active_monitor_idx]; + let ws = current.active_workspace(); + if !ws.has_windows() { + return; + } + let column = &ws.columns[ws.active_column_idx]; + let window = column.windows[column.active_window_idx].clone(); + ws.remove_window(&window); + + let workspace_idx = monitors[new_idx].active_workspace_idx; + self.add_window(new_idx, workspace_idx, window, true); + } + } } impl MonitorSet<Window> { |
