diff options
| author | Ivan Molodetskikh <yalterz@gmail.com> | 2024-03-19 15:20:03 +0400 |
|---|---|---|
| committer | Ivan Molodetskikh <yalterz@gmail.com> | 2024-03-19 18:29:13 +0400 |
| commit | c61361de3ca4484387f39b067eadc612908560eb (patch) | |
| tree | 0fc6f30df529c3ac4f7151e314e4d9548bc934bf /src/layout | |
| parent | 3963f537a4182dbcd8e1e2f262ee105473facc56 (diff) | |
| download | niri-c61361de3ca4484387f39b067eadc612908560eb.tar.gz niri-c61361de3ca4484387f39b067eadc612908560eb.tar.bz2 niri-c61361de3ca4484387f39b067eadc612908560eb.zip | |
Implement window rule reloading and min/max size rules
Diffstat (limited to 'src/layout')
| -rw-r--r-- | src/layout/mod.rs | 58 |
1 files changed, 41 insertions, 17 deletions
diff --git a/src/layout/mod.rs b/src/layout/mod.rs index 86ce5c85..c2c4bf4e 100644 --- a/src/layout/mod.rs +++ b/src/layout/mod.rs @@ -643,13 +643,30 @@ impl<W: LayoutElement> Layout<W> { } } - pub fn find_window_mut(&mut self, wl_surface: &WlSurface) -> Option<&mut W> { + pub fn find_window_and_output(&self, wl_surface: &WlSurface) -> Option<(&W, &Output)> { + if let MonitorSet::Normal { monitors, .. } = &self.monitor_set { + for mon in monitors { + for ws in &mon.workspaces { + if let Some(window) = ws.find_wl_surface(wl_surface) { + return Some((window, &mon.output)); + } + } + } + } + + None + } + + pub fn find_window_and_output_mut( + &mut self, + wl_surface: &WlSurface, + ) -> Option<(&mut W, Option<&Output>)> { match &mut self.monitor_set { MonitorSet::Normal { monitors, .. } => { for mon in monitors { for ws in &mut mon.workspaces { if let Some(window) = ws.find_wl_surface_mut(wl_surface) { - return Some(window); + return Some((window, Some(&mon.output))); } } } @@ -657,21 +674,7 @@ impl<W: LayoutElement> Layout<W> { MonitorSet::NoOutputs { workspaces } => { for ws in workspaces { if let Some(window) = ws.find_wl_surface_mut(wl_surface) { - return Some(window); - } - } - } - } - - None - } - - pub fn find_window_and_output(&self, wl_surface: &WlSurface) -> Option<(&W, &Output)> { - if let MonitorSet::Normal { monitors, .. } = &self.monitor_set { - for mon in monitors { - for ws in &mon.workspaces { - if let Some(window) = ws.find_wl_surface(wl_surface) { - return Some((window, &mon.output)); + return Some((window, None)); } } } @@ -851,6 +854,27 @@ impl<W: LayoutElement> Layout<W> { } } + pub fn with_windows_mut(&mut self, mut f: impl FnMut(&mut W, Option<&Output>)) { + match &mut self.monitor_set { + MonitorSet::Normal { monitors, .. } => { + for mon in monitors { + for ws in &mut mon.workspaces { + for win in ws.windows_mut() { + f(win, Some(&mon.output)); + } + } + } + } + MonitorSet::NoOutputs { workspaces } => { + for ws in workspaces { + for win in ws.windows_mut() { + f(win, None); + } + } + } + } + } + fn active_monitor(&mut self) -> Option<&mut Monitor<W>> { let MonitorSet::Normal { monitors, |
