diff options
| author | Ivan Molodetskikh <yalterz@gmail.com> | 2024-12-30 08:48:05 +0300 |
|---|---|---|
| committer | Ivan Molodetskikh <yalterz@gmail.com> | 2024-12-30 20:12:37 +0300 |
| commit | 8409107a5bb04980ea196a5d7095d5c34f6b2e4e (patch) | |
| tree | 18a3fbcc3cab75a080f9f1d9c1ef2f06e55df237 /src/layout/mod.rs | |
| parent | 9089c3fb0224a7f8d425a02fa299f6a5ea607b17 (diff) | |
| download | niri-8409107a5bb04980ea196a5d7095d5c34f6b2e4e.tar.gz niri-8409107a5bb04980ea196a5d7095d5c34f6b2e4e.tar.bz2 niri-8409107a5bb04980ea196a5d7095d5c34f6b2e4e.zip | |
Implement default-window-height for scrolling windows
Diffstat (limited to 'src/layout/mod.rs')
| -rw-r--r-- | src/layout/mod.rs | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/src/layout/mod.rs b/src/layout/mod.rs index 2e05392d..97d3d1e1 100644 --- a/src/layout/mod.rs +++ b/src/layout/mod.rs @@ -839,16 +839,23 @@ impl<W: LayoutElement> Layout<W> { /// Adds a new window to the layout. /// /// Returns an output that the window was added to, if there were any outputs. + #[allow(clippy::too_many_arguments)] pub fn add_window( &mut self, window: W, target: AddWindowTarget<W>, width: Option<ColumnWidth>, + height: Option<PresetSize>, is_full_width: bool, is_floating: bool, activate: ActivateWindow, ) -> Option<&Output> { let resolved_width = self.resolve_default_width(&window, width, is_floating); + let resolved_height = height.map(|h| match h { + PresetSize::Proportion(prop) => SizeChange::SetProportion(prop * 100.), + PresetSize::Fixed(fixed) => SizeChange::SetFixed(fixed), + }); + let id = window.id().clone(); match &mut self.monitor_set { MonitorSet::Normal { @@ -927,6 +934,18 @@ impl<W: LayoutElement> Layout<W> { *active_monitor_idx = mon_idx; } + // Set the default height for scrolling windows. + if !is_floating { + if let Some(change) = resolved_height { + let ws = mon + .workspaces + .iter_mut() + .find(|ws| ws.has_window(&id)) + .unwrap(); + ws.set_window_height(Some(&id), change); + } + } + Some(&mon.output) } MonitorSet::NoOutputs { workspaces } => { @@ -983,6 +1002,13 @@ impl<W: LayoutElement> Layout<W> { is_floating, ); + // Set the default height for scrolling windows. + if !is_floating { + if let Some(change) = resolved_height { + ws.set_window_height(Some(&id), change); + } + } + None } } @@ -4693,6 +4719,7 @@ mod tests { win, AddWindowTarget::Auto, None, + None, false, params.is_floating, ActivateWindow::default(), @@ -4760,6 +4787,7 @@ mod tests { win, AddWindowTarget::NextTo(&next_to_id), None, + None, false, params.is_floating, ActivateWindow::default(), @@ -4832,6 +4860,7 @@ mod tests { win, AddWindowTarget::Workspace(ws_id), None, + None, false, params.is_floating, ActivateWindow::default(), |
