diff options
Diffstat (limited to 'src')
85 files changed, 163 insertions, 118 deletions
diff --git a/src/handlers/compositor.rs b/src/handlers/compositor.rs index c0dc9428..058f8375 100644 --- a/src/handlers/compositor.rs +++ b/src/handlers/compositor.rs @@ -100,6 +100,7 @@ impl CompositorHandler for State { if let InitialConfigureState::Configured { rules, width, + floating_width: _, is_full_width, output, workspace_name, diff --git a/src/handlers/xdg_shell.rs b/src/handlers/xdg_shell.rs index a3559542..779612b6 100644 --- a/src/handlers/xdg_shell.rs +++ b/src/handlers/xdg_shell.rs @@ -494,6 +494,7 @@ impl XdgShellHandler for State { InitialConfigureState::Configured { rules, width, + floating_width, is_full_width, output, workspace_name, @@ -548,12 +549,14 @@ impl XdgShellHandler for State { state.states.unset(xdg_toplevel::State::Fullscreen); }); - let configure_width = if *is_full_width { + let is_floating = rules.compute_open_floating(&toplevel); + let configure_width = if is_floating { + *floating_width + } else if *is_full_width { Some(ColumnWidth::Proportion(1.)) } else { *width }; - let is_floating = rules.compute_open_floating(&toplevel); ws.configure_new_window( &unmapped.window, configure_width, @@ -836,6 +839,7 @@ impl State { let mon = mon.map(|(mon, _)| mon); let mut width = None; + let mut floating_width = None; let is_full_width = rules.open_maximized.unwrap_or(false); let is_floating = rules.compute_open_floating(toplevel); @@ -859,9 +863,12 @@ impl State { }); } - width = ws.resolve_default_width(rules.default_width, is_floating); + width = ws.resolve_default_width(rules.default_width, false); + floating_width = ws.resolve_default_width(rules.default_width, true); - let configure_width = if is_full_width { + let configure_width = if is_floating { + floating_width + } else if is_full_width { Some(ColumnWidth::Proportion(1.)) } else { width @@ -884,6 +891,7 @@ impl State { *state = InitialConfigureState::Configured { rules, width, + floating_width, is_full_width, output, workspace_name: ws.and_then(|w| w.name().cloned()), diff --git a/src/layout/floating.rs b/src/layout/floating.rs index 3633ad18..08a74b37 100644 --- a/src/layout/floating.rs +++ b/src/layout/floating.rs @@ -1,3 +1,4 @@ +use std::cmp::max; use std::iter::zip; use std::rc::Rc; @@ -1097,6 +1098,36 @@ impl<W: LayoutElement> FloatingSpace<W> { } } + pub fn resolve_width(&self, width: ColumnWidth) -> ResolvedSize { + width.resolve_no_gaps(&self.options, self.working_area.size.w) + } + + pub fn new_window_size( + &self, + width: Option<ColumnWidth>, + rules: &ResolvedWindowRules, + ) -> Size<i32, Logical> { + let border = rules.border.resolve_against(self.options.border); + + let width = if let Some(width) = width { + let width = match self.resolve_width(width) { + ResolvedSize::Tile(mut size) => { + if !border.off { + size -= border.width.0 * 2.; + } + size + } + ResolvedSize::Window(size) => size, + }; + + max(1, width.floor() as i32) + } else { + 0 + }; + + Size::from((width, 0)) + } + #[cfg(test)] pub fn view_size(&self) -> Size<f64, Logical> { self.view_size diff --git a/src/layout/workspace.rs b/src/layout/workspace.rs index a9ba091b..516e02fd 100644 --- a/src/layout/workspace.rs +++ b/src/layout/workspace.rs @@ -723,7 +723,7 @@ impl<W: LayoutElement> Workspace<W> { (min_size, max_size): (Size<i32, Logical>, Size<i32, Logical>), ) -> Size<i32, Logical> { let mut size = if is_floating { - Size::from((0, 0)) + self.floating.new_window_size(width, rules) } else { self.scrolling.new_window_size(width, rules) }; diff --git a/src/tests/snapshots/niri__tests__window_opening__check_target_size@fsF-ofT-dwF1000-b-wfsAN.snap b/src/tests/snapshots/niri__tests__window_opening__check_target_size@fsF-ofT-dwF1000-b-wfsAN.snap index 3f0a76eb..c76bd4f5 100644 --- a/src/tests/snapshots/niri__tests__window_opening__check_target_size@fsF-ofT-dwF1000-b-wfsAN.snap +++ b/src/tests/snapshots/niri__tests__window_opening__check_target_size@fsF-ofT-dwF1000-b-wfsAN.snap @@ -5,7 +5,7 @@ expression: snapshot snapshot_kind: text --- initial configure: -size: 0 × 0, bounds: 1272 × 712, states: [] +size: 1000 × 0, bounds: 1272 × 712, states: [] post-map configures: size: 1280 × 720, bounds: 1240 × 680, states: [Fullscreen] diff --git a/src/tests/snapshots/niri__tests__window_opening__check_target_size@fsF-ofT-dwF1000-b-wfsAU.snap b/src/tests/snapshots/niri__tests__window_opening__check_target_size@fsF-ofT-dwF1000-b-wfsAU.snap index 05322b41..d1d9c77c 100644 --- a/src/tests/snapshots/niri__tests__window_opening__check_target_size@fsF-ofT-dwF1000-b-wfsAU.snap +++ b/src/tests/snapshots/niri__tests__window_opening__check_target_size@fsF-ofT-dwF1000-b-wfsAU.snap @@ -5,8 +5,8 @@ expression: snapshot snapshot_kind: text --- initial configure: -size: 0 × 0, bounds: 1272 × 712, states: [] +size: 1000 × 0, bounds: 1272 × 712, states: [] post-map configures: -size: 0 × 0, bounds: 1272 × 712, states: [] -size: 1 × 1, bounds: 1272 × 712, states: [Activated] +size: 1000 × 0, bounds: 1272 × 712, states: [] +size: 1000 × 1, bounds: 1272 × 712, states: [Activated] diff --git a/src/tests/snapshots/niri__tests__window_opening__check_target_size@fsF-ofT-dwF1000-b-wfsBN.snap b/src/tests/snapshots/niri__tests__window_opening__check_target_size@fsF-ofT-dwF1000-b-wfsBN.snap index 928dba69..e7904296 100644 --- a/src/tests/snapshots/niri__tests__window_opening__check_target_size@fsF-ofT-dwF1000-b-wfsBN.snap +++ b/src/tests/snapshots/niri__tests__window_opening__check_target_size@fsF-ofT-dwF1000-b-wfsBN.snap @@ -5,7 +5,7 @@ expression: snapshot snapshot_kind: text --- initial configure: -size: 0 × 0, bounds: 1272 × 712, states: [] +size: 1000 × 0, bounds: 1272 × 712, states: [] post-map configures: size: 1 × 1, bounds: 1272 × 712, states: [Activated] diff --git a/src/tests/snapshots/niri__tests__window_opening__check_target_size@fsF-ofT-dwF1000-b-wfsBU.snap b/src/tests/snapshots/niri__tests__window_opening__check_target_size@fsF-ofT-dwF1000-b-wfsBU.snap index abe63343..a1022aee 100644 --- a/src/tests/snapshots/niri__tests__window_opening__check_target_size@fsF-ofT-dwF1000-b-wfsBU.snap +++ b/src/tests/snapshots/niri__tests__window_opening__check_target_size@fsF-ofT-dwF1000-b-wfsBU.snap @@ -5,7 +5,7 @@ expression: snapshot snapshot_kind: text --- initial configure: -size: 0 × 0, bounds: 1272 × 712, states: [] +size: 1000 × 0, bounds: 1272 × 712, states: [] post-map configures: size: 1 × 1, bounds: 1272 × 712, states: [Activated] diff --git a/src/tests/snapshots/niri__tests__window_opening__check_target_size@fsF-ofT-dwF1000-b.snap b/src/tests/snapshots/niri__tests__window_opening__check_target_size@fsF-ofT-dwF1000-b.snap index 1074b92a..8d37ee51 100644 --- a/src/tests/snapshots/niri__tests__window_opening__check_target_size@fsF-ofT-dwF1000-b.snap +++ b/src/tests/snapshots/niri__tests__window_opening__check_target_size@fsF-ofT-dwF1000-b.snap @@ -5,7 +5,7 @@ expression: snapshot snapshot_kind: text --- initial configure: |
