diff options
Diffstat (limited to 'src/layout')
| -rw-r--r-- | src/layout/floating.rs | 23 | ||||
| -rw-r--r-- | src/layout/workspace.rs | 23 |
2 files changed, 42 insertions, 4 deletions
diff --git a/src/layout/floating.rs b/src/layout/floating.rs index 08a74b37..a04c9b94 100644 --- a/src/layout/floating.rs +++ b/src/layout/floating.rs @@ -1102,9 +1102,14 @@ impl<W: LayoutElement> FloatingSpace<W> { width.resolve_no_gaps(&self.options, self.working_area.size.w) } + pub fn resolve_height(&self, height: PresetSize) -> ResolvedSize { + resolve_preset_size(height, self.working_area.size.h) + } + pub fn new_window_size( &self, width: Option<ColumnWidth>, + height: Option<PresetSize>, rules: &ResolvedWindowRules, ) -> Size<i32, Logical> { let border = rules.border.resolve_against(self.options.border); @@ -1125,7 +1130,23 @@ impl<W: LayoutElement> FloatingSpace<W> { 0 }; - Size::from((width, 0)) + let height = if let Some(height) = height { + let height = match self.resolve_height(height) { + ResolvedSize::Tile(mut size) => { + if !border.off { + size -= border.width.0 * 2.; + } + size + } + ResolvedSize::Window(size) => size, + }; + + max(1, height.floor() as i32) + } else { + 0 + }; + + Size::from((width, height)) } #[cfg(test)] diff --git a/src/layout/workspace.rs b/src/layout/workspace.rs index 516e02fd..92900ff3 100644 --- a/src/layout/workspace.rs +++ b/src/layout/workspace.rs @@ -2,7 +2,7 @@ use std::cmp::max; use std::rc::Rc; use std::time::Duration; -use niri_config::{OutputName, Workspace as WorkspaceConfig}; +use niri_config::{OutputName, PresetSize, Workspace as WorkspaceConfig}; use niri_ipc::SizeChange; use smithay::backend::renderer::gles::GlesRenderer; use smithay::desktop::{layer_map_for_output, Window}; @@ -715,15 +715,30 @@ impl<W: LayoutElement> Workspace<W> { } } + pub fn resolve_default_height( + &self, + default_height: Option<Option<PresetSize>>, + is_floating: bool, + ) -> Option<PresetSize> { + match default_height { + Some(Some(height)) => Some(height), + Some(None) => None, + None if is_floating => None, + // We don't have a global default at the moment. + None => None, + } + } + pub fn new_window_size( &self, width: Option<ColumnWidth>, + height: Option<PresetSize>, is_floating: bool, rules: &ResolvedWindowRules, (min_size, max_size): (Size<i32, Logical>, Size<i32, Logical>), ) -> Size<i32, Logical> { let mut size = if is_floating { - self.floating.new_window_size(width, rules) + self.floating.new_window_size(width, height, rules) } else { self.scrolling.new_window_size(width, rules) }; @@ -749,6 +764,7 @@ impl<W: LayoutElement> Workspace<W> { &self, window: &Window, width: Option<ColumnWidth>, + height: Option<PresetSize>, is_floating: bool, rules: &ResolvedWindowRules, ) { @@ -766,7 +782,8 @@ impl<W: LayoutElement> Workspace<W> { if state.states.contains(xdg_toplevel::State::Fullscreen) { state.size = Some(self.view_size.to_i32_round()); } else { - let size = self.new_window_size(width, is_floating, rules, (min_size, max_size)); + let size = + self.new_window_size(width, height, is_floating, rules, (min_size, max_size)); state.size = Some(size); } |
