layout: Store Layout directly in Options
Browse files at this commit4c524b47196badd281bc159bef3137cf16f963e5Parent: 1fa9dd311 changed files +279 -274
- niri-visual-tests/src/cases/layout.rs +15 -12
- niri-visual-tests/src/cases/tile.rs +11 -8
- src/layout/floating.rs +11 -9
- src/layout/mod.rs +25 -105
- src/layout/monitor.rs +16 -14
- src/layout/scrolling.rs +78 -71
- src/layout/tests.rs +87 -34
- src/layout/tests/animations.rs +4 -1
- src/layout/tests/fullscreen.rs +6 -3
- src/layout/tile.rs +19 -11
- src/layout/workspace.rs +7 -6
niri-visual-tests/src/cases/layout.rsmodified+15 -12
| @@ -52,20 +52,23 @@ impl Layout { | |||
| 52 | }); | 52 | }); |
| 53 | 53 | ||
| 54 | let options = Options { | 54 | let options = Options { |
| 55 | - focus_ring: niri_config::FocusRing { | 55 | + layout: niri_config::Layout { |
| 56 | - off: true, | 56 | + focus_ring: niri_config::FocusRing { |
| 57 | + off: true, | ||
| 58 | + ..Default::default() | ||
| 59 | + }, | ||
| 60 | + border: niri_config::Border { | ||
| 61 | + off: false, | ||
| 62 | + width: 4., | ||
| 63 | + active_color: Color::from_rgba8_unpremul(255, 163, 72, 255), | ||
| 64 | + inactive_color: Color::from_rgba8_unpremul(50, 50, 50, 255), | ||
| 65 | + urgent_color: Color::from_rgba8_unpremul(155, 0, 0, 255), | ||
| 66 | + active_gradient: None, | ||
| 67 | + inactive_gradient: None, | ||
| 68 | + urgent_gradient: None, | ||
| 69 | + }, | ||
| 57 | ..Default::default() | 70 | ..Default::default() |
| 58 | }, | 71 | }, |
| 59 | - border: niri_config::Border { | ||
| 60 | - off: false, | ||
| 61 | - width: 4., | ||
| 62 | - active_color: Color::from_rgba8_unpremul(255, 163, 72, 255), | ||
| 63 | - inactive_color: Color::from_rgba8_unpremul(50, 50, 50, 255), | ||
| 64 | - urgent_color: Color::from_rgba8_unpremul(155, 0, 0, 255), | ||
| 65 | - active_gradient: None, | ||
| 66 | - inactive_gradient: None, | ||
| 67 | - urgent_gradient: None, | ||
| 68 | - }, | ||
| 69 | ..Default::default() | 72 | ..Default::default() |
| 70 | }; | 73 | }; |
| 71 | let mut layout = niri::layout::Layout::with_options(clock.clone(), options); | 74 | let mut layout = niri::layout::Layout::with_options(clock.clone(), options); |
niri-visual-tests/src/cases/tile.rsmodified+11 -8
| @@ -58,14 +58,17 @@ impl Tile { | |||
| 58 | let Args { size, clock } = args; | 58 | let Args { size, clock } = args; |
| 59 | 59 | ||
| 60 | let options = Options { | 60 | let options = Options { |
| 61 | - focus_ring: niri_config::FocusRing { | 61 | + layout: niri_config::Layout { |
| 62 | - off: true, | 62 | + focus_ring: niri_config::FocusRing { |
| 63 | - ..Default::default() | 63 | + off: true, |
| 64 | - }, | 64 | + ..Default::default() |
| 65 | - border: niri_config::Border { | 65 | + }, |
| 66 | - off: false, | 66 | + border: niri_config::Border { |
| 67 | - width: 32., | 67 | + off: false, |
| 68 | - active_color: Color::from_rgba8_unpremul(255, 163, 72, 255), | 68 | + width: 32., |
| 69 | + active_color: Color::from_rgba8_unpremul(255, 163, 72, 255), | ||
| 70 | + ..Default::default() | ||
| 71 | + }, | ||
| 69 | ..Default::default() | 72 | ..Default::default() |
| 70 | }, | 73 | }, |
| 71 | ..Default::default() | 74 | ..Default::default() |
src/layout/floating.rsmodified+11 -9
| @@ -340,7 +340,7 @@ impl<W: LayoutElement> FloatingSpace<W> { | |||
| 340 | } | 340 | } |
| 341 | 341 | ||
| 342 | pub fn new_window_toplevel_bounds(&self, rules: &ResolvedWindowRules) -> Size<i32, Logical> { | 342 | pub fn new_window_toplevel_bounds(&self, rules: &ResolvedWindowRules) -> Size<i32, Logical> { |
| 343 | - let border_config = self.options.border.merged_with(&rules.border); | 343 | + let border_config = self.options.layout.border.merged_with(&rules.border); |
| 344 | compute_toplevel_bounds(border_config, self.working_area.size) | 344 | compute_toplevel_bounds(border_config, self.working_area.size) |
| 345 | } | 345 | } |
| 346 | 346 | ||
| @@ -633,7 +633,7 @@ impl<W: LayoutElement> FloatingSpace<W> { | |||
| 633 | 633 | ||
| 634 | let available_size = self.working_area.size.w; | 634 | let available_size = self.working_area.size.w; |
| 635 | 635 | ||
| 636 | - let len = self.options.preset_column_widths.len(); | 636 | + let len = self.options.layout.preset_column_widths.len(); |
| 637 | let tile = &mut self.tiles[idx]; | 637 | let tile = &mut self.tiles[idx]; |
| 638 | let preset_idx = if let Some(idx) = tile.floating_preset_width_idx { | 638 | let preset_idx = if let Some(idx) = tile.floating_preset_width_idx { |
| 639 | (idx + if forwards { 1 } else { len - 1 }) % len | 639 | (idx + if forwards { 1 } else { len - 1 }) % len |
| @@ -643,6 +643,7 @@ impl<W: LayoutElement> FloatingSpace<W> { | |||
| 643 | 643 | ||
| 644 | let mut it = self | 644 | let mut it = self |
| 645 | .options | 645 | .options |
| 646 | + .layout | ||
| 646 | .preset_column_widths | 647 | .preset_column_widths |
| 647 | .iter() | 648 | .iter() |
| 648 | .map(|preset| resolve_preset_size(*preset, available_size)); | 649 | .map(|preset| resolve_preset_size(*preset, available_size)); |
| @@ -668,7 +669,7 @@ impl<W: LayoutElement> FloatingSpace<W> { | |||
| 668 | } | 669 | } |
| 669 | }; | 670 | }; |
| 670 | 671 | ||
| 671 | - let preset = self.options.preset_column_widths[preset_idx]; | 672 | + let preset = self.options.layout.preset_column_widths[preset_idx]; |
| 672 | self.set_window_width(Some(&id), SizeChange::from(preset), true); | 673 | self.set_window_width(Some(&id), SizeChange::from(preset), true); |
| 673 | 674 | ||
| 674 | self.tiles[idx].floating_preset_width_idx = Some(preset_idx); | 675 | self.tiles[idx].floating_preset_width_idx = Some(preset_idx); |
| @@ -693,7 +694,7 @@ impl<W: LayoutElement> FloatingSpace<W> { | |||
| 693 | 694 | ||
| 694 | let available_size = self.working_area.size.h; | 695 | let available_size = self.working_area.size.h; |
| 695 | 696 | ||
| 696 | - let len = self.options.preset_window_heights.len(); | 697 | + let len = self.options.layout.preset_window_heights.len(); |
| 697 | let tile = &mut self.tiles[idx]; | 698 | let tile = &mut self.tiles[idx]; |
| 698 | let preset_idx = if let Some(idx) = tile.floating_preset_height_idx { | 699 | let preset_idx = if let Some(idx) = tile.floating_preset_height_idx { |
| 699 | (idx + if forwards { 1 } else { len - 1 }) % len | 700 | (idx + if forwards { 1 } else { len - 1 }) % len |
| @@ -703,6 +704,7 @@ impl<W: LayoutElement> FloatingSpace<W> { | |||
| 703 | 704 | ||
| 704 | let mut it = self | 705 | let mut it = self |
| 705 | .options | 706 | .options |
| 707 | + .layout | ||
| 706 | .preset_window_heights | 708 | .preset_window_heights |
| 707 | .iter() | 709 | .iter() |
| 708 | .map(|preset| resolve_preset_size(*preset, available_size)); | 710 | .map(|preset| resolve_preset_size(*preset, available_size)); |
| @@ -728,7 +730,7 @@ impl<W: LayoutElement> FloatingSpace<W> { | |||
| 728 | } | 730 | } |
| 729 | }; | 731 | }; |
| 730 | 732 | ||
| 731 | - let preset = self.options.preset_window_heights[preset_idx]; | 733 | + let preset = self.options.layout.preset_window_heights[preset_idx]; |
| 732 | self.set_window_height(Some(&id), SizeChange::from(preset), true); | 734 | self.set_window_height(Some(&id), SizeChange::from(preset), true); |
| 733 | 735 | ||
| 734 | let tile = &mut self.tiles[idx]; | 736 | let tile = &mut self.tiles[idx]; |
| @@ -1156,7 +1158,7 @@ impl<W: LayoutElement> FloatingSpace<W> { | |||
| 1156 | .map(|resize| resize.data); | 1158 | .map(|resize| resize.data); |
| 1157 | win.set_interactive_resize(resize_data); | 1159 | win.set_interactive_resize(resize_data); |
| 1158 | 1160 | ||
| 1159 | - let border_config = self.options.border.merged_with(&win.rules().border); | 1161 | + let border_config = self.options.layout.border.merged_with(&win.rules().border); |
| 1160 | let bounds = compute_toplevel_bounds(border_config, self.working_area.size); | 1162 | let bounds = compute_toplevel_bounds(border_config, self.working_area.size); |
| 1161 | win.set_bounds(bounds); | 1163 | win.set_bounds(bounds); |
| 1162 | 1164 | ||
| @@ -1220,7 +1222,7 @@ impl<W: LayoutElement> FloatingSpace<W> { | |||
| 1220 | height: Option<PresetSize>, | 1222 | height: Option<PresetSize>, |
| 1221 | rules: &ResolvedWindowRules, | 1223 | rules: &ResolvedWindowRules, |
| 1222 | ) -> Size<i32, Logical> { | 1224 | ) -> Size<i32, Logical> { |
| 1223 | - let border = self.options.border.merged_with(&rules.border); | 1225 | + let border = self.options.layout.border.merged_with(&rules.border); |
| 1224 | 1226 | ||
| 1225 | let resolve = |size: Option<PresetSize>, working_area_size: f64| { | 1227 | let resolve = |size: Option<PresetSize>, working_area_size: f64| { |
| 1226 | if let Some(size) = size { | 1228 | if let Some(size) = size { |
| @@ -1317,10 +1319,10 @@ impl<W: LayoutElement> FloatingSpace<W> { | |||
| 1317 | tile.verify_invariants(); | 1319 | tile.verify_invariants(); |
| 1318 | 1320 | ||
| 1319 | if let Some(idx) = tile.floating_preset_width_idx { | 1321 | if let Some(idx) = tile.floating_preset_width_idx { |
| 1320 | - assert!(idx < self.options.preset_column_widths.len()); | 1322 | + assert!(idx < self.options.layout.preset_column_widths.len()); |
| 1321 | } | 1323 | } |
| 1322 | if let Some(idx) = tile.floating_preset_height_idx { | 1324 | if let Some(idx) = tile.floating_preset_height_idx { |
| 1323 | - assert!(idx < self.options.preset_window_heights.len()); | 1325 | + assert!(idx < self.options.layout.preset_window_heights.len()); |
| 1324 | } | 1326 | } |
| 1325 | 1327 | ||
| 1326 | assert!( | 1328 | assert!( |
src/layout/mod.rsmodified+25 -105
| @@ -40,8 +40,7 @@ use std::time::Duration; | |||
| 40 | use monitor::{InsertHint, InsertPosition, InsertWorkspace, MonitorAddWindowTarget}; | 40 | use monitor::{InsertHint, InsertPosition, InsertWorkspace, MonitorAddWindowTarget}; |
| 41 | use niri_config::utils::MergeWith as _; | 41 | use niri_config::utils::MergeWith as _; |
| 42 | use niri_config::{ | 42 | use niri_config::{ |
| 43 | - CenterFocusedColumn, Config, CornerRadius, PresetSize, Struts, Workspace as WorkspaceConfig, | 43 | + Config, CornerRadius, PresetSize, Workspace as WorkspaceConfig, WorkspaceReference, |
| 44 | - WorkspaceReference, | ||
| 45 | }; | 44 | }; |
| 46 | use niri_ipc::{ColumnDisplay, PositionChange, SizeChange, WindowLayout}; | 45 | use niri_ipc::{ColumnDisplay, PositionChange, SizeChange, WindowLayout}; |
| 47 | use scrolling::{Column, ColumnWidth}; | 46 | use scrolling::{Column, ColumnWidth}; |
| @@ -334,27 +333,9 @@ enum MonitorSet<W: LayoutElement> { | |||
| 334 | }, | 333 | }, |
| 335 | } | 334 | } |
| 336 | 335 | ||
| 337 | -#[derive(Debug, Clone, PartialEq)] | 336 | +#[derive(Debug, Default, Clone, PartialEq)] |
| 338 | pub struct Options { | 337 | pub struct Options { |
| 339 | - /// Padding around windows in logical pixels. | 338 | + pub layout: niri_config::Layout, |
| 340 | - pub gaps: f64, | ||
| 341 | - /// Extra padding around the working area in logical pixels. | ||
| 342 | - pub struts: Struts, | ||
| 343 | - pub focus_ring: niri_config::FocusRing, | ||
| 344 | - pub border: niri_config::Border, | ||
| 345 | - pub shadow: niri_config::Shadow, | ||
| 346 | - pub tab_indicator: niri_config::TabIndicator, | ||
| 347 | - pub insert_hint: niri_config::InsertHint, | ||
| 348 | - pub center_focused_column: CenterFocusedColumn, | ||
| 349 | - pub always_center_single_column: bool, | ||
| 350 | - pub empty_workspace_above_first: bool, | ||
| 351 | - pub default_column_display: ColumnDisplay, | ||
| 352 | - /// Column or window widths that `toggle_width()` switches between. | ||
| 353 | - pub preset_column_widths: Vec<PresetSize>, | ||
| 354 | - /// Initial width for new columns. | ||
| 355 | - pub default_column_width: Option<PresetSize>, | ||
| 356 | - /// Window height that `toggle_window_height()` switches between. | ||
| 357 | - pub preset_window_heights: Vec<PresetSize>, | ||
| 358 | pub animations: niri_config::Animations, | 339 | pub animations: niri_config::Animations, |
| 359 | pub gestures: niri_config::Gestures, | 340 | pub gestures: niri_config::Gestures, |
| 360 | pub overview: niri_config::Overview, | 341 | pub overview: niri_config::Overview, |
| @@ -364,41 +345,6 @@ pub struct Options { | |||
| 364 | pub deactivate_unfocused_windows: bool, | 345 | pub deactivate_unfocused_windows: bool, |
| 365 | } | 346 | } |
| 366 | 347 | ||
| 367 | -impl Default for Options { | ||
| 368 | - fn default() -> Self { | ||
| 369 | - Self { | ||
| 370 | - gaps: 16., | ||
| 371 | - struts: Default::default(), | ||
| 372 | - focus_ring: Default::default(), | ||
| 373 | - border: Default::default(), | ||
| 374 | - shadow: Default::default(), | ||
| 375 | - tab_indicator: Default::default(), | ||
| 376 | - insert_hint: Default::default(), | ||
| 377 | - center_focused_column: Default::default(), | ||
| 378 | - always_center_single_column: false, | ||
| 379 | - empty_workspace_above_first: false, | ||
| 380 | - default_column_display: ColumnDisplay::Normal, | ||
| 381 | - preset_column_widths: vec![ | ||
| 382 | - PresetSize::Proportion(1. / 3.), | ||
| 383 | - PresetSize::Proportion(0.5), | ||
| 384 | - PresetSize::Proportion(2. / 3.), | ||
| 385 | - ], | ||
| 386 | - default_column_width: None, | ||
| 387 | - animations: Default::default(), | ||
| 388 | - gestures: Default::default(), | ||
| 389 | - overview: Default::default(), | ||
| 390 | - disable_resize_throttling: false, | ||
| 391 | - disable_transactions: false, | ||
| 392 | - preset_window_heights: vec![ | ||
| 393 | - PresetSize::Proportion(1. / 3.), | ||
| 394 | - PresetSize::Proportion(0.5), | ||
| 395 | - PresetSize::Proportion(2. / 3.), | ||
| 396 | - ], | ||
| 397 | - deactivate_unfocused_windows: false, | ||
| 398 | - } | ||
| 399 | - } | ||
| 400 | -} | ||
| 401 | - | ||
| 402 | #[allow(clippy::large_enum_variant)] | 348 | #[allow(clippy::large_enum_variant)] |
| 403 | #[derive(Debug)] | 349 | #[derive(Debug)] |
| 404 | enum InteractiveMoveState<W: LayoutElement> { | 350 | enum InteractiveMoveState<W: LayoutElement> { |
| @@ -620,49 +566,23 @@ impl HitType { | |||
| 620 | 566 | ||
| 621 | impl Options { | 567 | impl Options { |
| 622 | fn from_config(config: &Config) -> Self { | 568 | fn from_config(config: &Config) -> Self { |
| 623 | - let layout = config.resolve_layout(); | ||
| 624 | - | ||
| 625 | - let preset_column_widths = if layout.preset_column_widths.is_empty() { | ||
| 626 | - Options::default().preset_column_widths | ||
| 627 | - } else { | ||
| 628 | - layout.preset_column_widths.clone() | ||
| 629 | - }; | ||
| 630 | - let preset_window_heights = if layout.preset_window_heights.is_empty() { | ||
| 631 | - Options::default().preset_window_heights | ||
| 632 | - } else { | ||
| 633 | - layout.preset_window_heights.clone() | ||
| 634 | - }; | ||
| 635 | - | ||
| 636 | Self { | 569 | Self { |
| 637 | - gaps: layout.gaps, | 570 | + layout: config.resolve_layout(), |
| 638 | - struts: layout.struts, | ||
| 639 | - focus_ring: layout.focus_ring, | ||
| 640 | - border: layout.border, | ||
| 641 | - shadow: layout.shadow, | ||
| 642 | - tab_indicator: layout.tab_indicator, | ||
| 643 | - insert_hint: layout.insert_hint, | ||
| 644 | - center_focused_column: layout.center_focused_column, | ||
| 645 | - always_center_single_column: layout.always_center_single_column, | ||
| 646 | - empty_workspace_above_first: layout.empty_workspace_above_first, | ||
| 647 | - default_column_display: layout.default_column_display, | ||
| 648 | - preset_column_widths, | ||
| 649 | - default_column_width: layout.default_column_width, | ||
| 650 | animations: config.animations.clone(), | 571 | animations: config.animations.clone(), |
| 651 | gestures: config.gestures, | 572 | gestures: config.gestures, |
| 652 | overview: config.overview, | 573 | overview: config.overview, |
| 653 | disable_resize_throttling: config.debug.disable_resize_throttling, | 574 | disable_resize_throttling: config.debug.disable_resize_throttling, |
| 654 | disable_transactions: config.debug.disable_transactions, | 575 | disable_transactions: config.debug.disable_transactions, |
| 655 | deactivate_unfocused_windows: config.debug.deactivate_unfocused_windows, | 576 | deactivate_unfocused_windows: config.debug.deactivate_unfocused_windows, |
| 656 | - preset_window_heights, | ||
| 657 | } | 577 | } |
| 658 | } | 578 | } |
| 659 | 579 | ||
| 660 | fn adjusted_for_scale(mut self, scale: f64) -> Self { | 580 | fn adjusted_for_scale(mut self, scale: f64) -> Self { |
| 661 | let round = |logical: f64| round_logical_in_physical_max1(scale, logical); | 581 | let round = |logical: f64| round_logical_in_physical_max1(scale, logical); |
| 662 | 582 | ||
| 663 | - self.gaps = round(self.gaps); | 583 | + self.layout.gaps = round(self.layout.gaps); |
| 664 | - self.focus_ring.width = round(self.focus_ring.width); | 584 | + self.layout.focus_ring.width = round(self.layout.focus_ring.width); |
| 665 | - self.border.width = round(self.border.width); | 585 | + self.layout.border.width = round(self.layout.border.width); |
| 666 | 586 | ||
| 667 | self | 587 | self |
| 668 | } | 588 | } |
| @@ -775,7 +695,7 @@ impl<W: LayoutElement> Layout<W> { | |||
| 775 | // workspaces set up across multiple monitors. Without this check, the | 695 | // workspaces set up across multiple monitors. Without this check, the |
| 776 | // first monitor to connect can end up with the first empty workspace | 696 | // first monitor to connect can end up with the first empty workspace |
| 777 | // focused instead of the first named workspace. | 697 | // focused instead of the first named workspace. |
| 778 | - && !(self.options.empty_workspace_above_first | 698 | + && !(self.options.layout.empty_workspace_above_first |
| 779 | && primary.active_workspace_idx == 1) | 699 | && primary.active_workspace_idx == 1) |
| 780 | { | 700 | { |
| 781 | primary.active_workspace_idx = | 701 | primary.active_workspace_idx = |
| @@ -790,7 +710,7 @@ impl<W: LayoutElement> Layout<W> { | |||
| 790 | // takes care of this. | 710 | // takes care of this. |
| 791 | 711 | ||
| 792 | if stopped_primary_ws_switch | 712 | if stopped_primary_ws_switch |
| 793 | - || (primary.options.empty_workspace_above_first | 713 | + || (primary.options.layout.empty_workspace_above_first |
| 794 | && primary.workspaces.len() == 2) | 714 | && primary.workspaces.len() == 2) |
| 795 | { | 715 | { |
| 796 | primary.clean_up_workspaces(); | 716 | primary.clean_up_workspaces(); |
| @@ -810,7 +730,7 @@ impl<W: LayoutElement> Layout<W> { | |||
| 810 | self.options.clone(), | 730 | self.options.clone(), |
| 811 | )); | 731 | )); |
| 812 | 732 | ||
| 813 | - if self.options.empty_workspace_above_first && workspaces.len() > 1 { | 733 | + if self.options.layout.empty_workspace_above_first && workspaces.len() > 1 { |
| 814 | workspaces.insert( | 734 | workspaces.insert( |
| 815 | 0, | 735 | 0, |
| 816 | Workspace::new(output.clone(), self.clock.clone(), self.options.clone()), | 736 | Workspace::new(output.clone(), self.clock.clone(), self.options.clone()), |
| @@ -844,7 +764,7 @@ impl<W: LayoutElement> Layout<W> { | |||
| 844 | )); | 764 | )); |
| 845 | 765 | ||
| 846 | let mut active_workspace_idx = 0; | 766 | let mut active_workspace_idx = 0; |
| 847 | - if self.options.empty_workspace_above_first && workspaces.len() > 1 { | 767 | + if self.options.layout.empty_workspace_above_first && workspaces.len() > 1 { |
| 848 | workspaces.insert( | 768 | workspaces.insert( |
| 849 | 0, | 769 | 0, |
| 850 | Workspace::new(output.clone(), self.clock.clone(), self.options.clone()), | 770 | Workspace::new(output.clone(), self.clock.clone(), self.options.clone()), |
| @@ -944,7 +864,7 @@ impl<W: LayoutElement> Layout<W> { | |||
| 944 | 864 | ||
| 945 | // If empty_workspace_above_first is set and the first workspace is now no | 865 | // If empty_workspace_above_first is set and the first workspace is now no |
| 946 | // longer empty, add a new empty workspace on top. | 866 | // longer empty, add a new empty workspace on top. |
| 947 | - if primary.options.empty_workspace_above_first | 867 | + if primary.options.layout.empty_workspace_above_first |
| 948 | && primary.workspaces[0].has_windows_or_name() | 868 | && primary.workspaces[0].has_windows_or_name() |
| 949 | { | 869 | { |
| 950 | primary.add_workspace_top(); | 870 | primary.add_workspace_top(); |
| @@ -1242,7 +1162,7 @@ impl<W: LayoutElement> Layout<W> { | |||
| 1242 | 1162 | ||
| 1243 | // Special case handling when empty_workspace_above_first is set and all | 1163 | // Special case handling when empty_workspace_above_first is set and all |
| 1244 | // workspaces are empty. | 1164 | // workspaces are empty. |
| 1245 | - if mon.options.empty_workspace_above_first | 1165 | + if mon.options.layout.empty_workspace_above_first |
| 1246 | && mon.workspaces.len() == 2 | 1166 | && mon.workspaces.len() == 2 |
| 1247 | && mon.workspace_switch.is_none() | 1167 | && mon.workspace_switch.is_none() |
| 1248 | { | 1168 | { |
| @@ -2637,7 +2557,7 @@ impl<W: LayoutElement> Layout<W> { | |||
| 2637 | !monitor.workspaces.last().unwrap().has_windows(), | 2557 | !monitor.workspaces.last().unwrap().has_windows(), |
| 2638 | "monitor must have an empty workspace in the end" | 2558 | "monitor must have an empty workspace in the end" |
| 2639 | ); | 2559 | ); |
| 2640 | - if monitor.options.empty_workspace_above_first { | 2560 | + if monitor.options.layout.empty_workspace_above_first { |
| 2641 | assert!( | 2561 | assert!( |
| 2642 | !monitor.workspaces.first().unwrap().has_windows(), | 2562 | !monitor.workspaces.first().unwrap().has_windows(), |
| 2643 | "first workspace must be empty when empty_workspace_above_first is set" | 2563 | "first workspace must be empty when empty_workspace_above_first is set" |
| @@ -2648,14 +2568,14 @@ impl<W: LayoutElement> Layout<W> { | |||
| 2648 | monitor.workspaces.last().unwrap().name.is_none(), | 2568 | monitor.workspaces.last().unwrap().name.is_none(), |
| 2649 | "monitor must have an unnamed workspace in the end" | 2569 | "monitor must have an unnamed workspace in the end" |
| 2650 | ); | 2570 | ); |
| 2651 | - if monitor.options.empty_workspace_above_first { | 2571 | + if monitor.options.layout.empty_workspace_above_first { |
| 2652 | assert!( | 2572 | assert!( |
| 2653 | monitor.workspaces.first().unwrap().name.is_none(), | 2573 | monitor.workspaces.first().unwrap().name.is_none(), |
| 2654 | "first workspace must be unnamed when empty_workspace_above_first is set" | 2574 | "first workspace must be unnamed when empty_workspace_above_first is set" |
| 2655 | ) | 2575 | ) |
| 2656 | } | 2576 | } |
| 2657 | 2577 | ||
| 2658 | - if monitor.options.empty_workspace_above_first { | 2578 | + if monitor.options.layout.empty_workspace_above_first { |
| 2659 | assert!( | 2579 | assert!( |
| 2660 | monitor.workspaces.len() != 2, | 2580 | monitor.workspaces.len() != 2, |
| 2661 | "if empty_workspace_above_first is set there must be just 1 or 3+ workspaces" | 2581 | "if empty_workspace_above_first is set there must be just 1 or 3+ workspaces" |
| @@ -2665,7 +2585,7 @@ impl<W: LayoutElement> Layout<W> { | |||
| 2665 | // If there's no workspace switch in progress, there can't be any non-last non-active | 2585 | // If there's no workspace switch in progress, there can't be any non-last non-active |
| 2666 | // empty workspaces. If empty_workspace_above_first is set then the first workspace | 2586 | // empty workspaces. If empty_workspace_above_first is set then the first workspace |
| 2667 | // will be empty too. | 2587 | // will be empty too. |
| 2668 | - let pre_skip = if monitor.options.empty_workspace_above_first { | 2588 | + let pre_skip = if monitor.options.layout.empty_workspace_above_first { |
| 2669 | 1 | 2589 | 1 |
| 2670 | } else { | 2590 | } else { |
| 2671 | 0 | 2591 | 0 |
| @@ -3107,7 +3027,7 @@ impl<W: LayoutElement> Layout<W> { | |||
| 3107 | let mon = &mut monitors[mon_idx]; | 3027 | let mon = &mut monitors[mon_idx]; |
| 3108 | 3028 | ||
| 3109 | let mut insert_idx = 0; | 3029 | let mut insert_idx = 0; |
| 3110 | - if mon.options.empty_workspace_above_first { | 3030 | + if mon.options.layout.empty_workspace_above_first { |
| 3111 | // need to insert new empty workspace on top | 3031 | // need to insert new empty workspace on top |
| 3112 | mon.add_workspace_top(); | 3032 | mon.add_workspace_top(); |
| 3113 | insert_idx += 1; | 3033 | insert_idx += 1; |
| @@ -3622,7 +3542,7 @@ impl<W: LayoutElement> Layout<W> { | |||
| 3622 | // Insert a new empty workspace. | 3542 | // Insert a new empty workspace. |
| 3623 | current.add_workspace_bottom(); | 3543 | current.add_workspace_bottom(); |
| 3624 | } | 3544 | } |
| 3625 | - if current.options.empty_workspace_above_first && current.active_workspace_idx == 0 { | 3545 | + if current.options.layout.empty_workspace_above_first && current.active_workspace_idx == 0 { |
| 3626 | current.add_workspace_top(); | 3546 | current.add_workspace_top(); |
| 3627 | } | 3547 | } |
| 3628 | 3548 | ||
| @@ -3642,7 +3562,7 @@ impl<W: LayoutElement> Layout<W> { | |||
| 3642 | 3562 | ||
| 3643 | target.previous_workspace_id = Some(target.workspaces[target.active_workspace_idx].id()); | 3563 | target.previous_workspace_id = Some(target.workspaces[target.active_workspace_idx].id()); |
| 3644 | 3564 | ||
| 3645 | - if target.options.empty_workspace_above_first && target.workspaces.len() == 1 { | 3565 | + if target.options.layout.empty_workspace_above_first && target.workspaces.len() == 1 { |
| 3646 | // Insert a new empty workspace on top to prepare for insertion of new workspace. | 3566 | // Insert a new empty workspace on top to prepare for insertion of new workspace. |
| 3647 | target.add_workspace_top(); | 3567 | target.add_workspace_top(); |
| 3648 | } | 3568 | } |
| @@ -3711,7 +3631,7 @@ impl<W: LayoutElement> Layout<W> { | |||
| 3711 | 3631 | ||
| 3712 | let mut ws = current.workspaces.remove(old_idx); | 3632 | let mut ws = current.workspaces.remove(old_idx); |
| 3713 | 3633 | ||
| 3714 | - if current.options.empty_workspace_above_first && old_idx == 0 { | 3634 | + if current.options.layout.empty_workspace_above_first && old_idx == 0 { |
| 3715 | current.add_workspace_top(); | 3635 | current.add_workspace_top(); |
| 3716 | } | 3636 | } |
| 3717 | 3637 | ||
| @@ -3728,7 +3648,7 @@ impl<W: LayoutElement> Layout<W> { | |||
| 3728 | 3648 | ||
| 3729 | target.previous_workspace_id = Some(target.workspaces[target.active_workspace_idx].id()); | 3649 | target.previous_workspace_id = Some(target.workspaces[target.active_workspace_idx].id()); |
| 3730 | 3650 | ||
| 3731 | - if target.options.empty_workspace_above_first && target.workspaces.len() == 1 { | 3651 | + if target.options.layout.empty_workspace_above_first && target.workspaces.len() == 1 { |
| 3732 | // Insert a new empty workspace on top to prepare for insertion of new workspace. | 3652 | // Insert a new empty workspace on top to prepare for insertion of new workspace. |
| 3733 | target.add_workspace_top(); | 3653 | target.add_workspace_top(); |
| 3734 | } | 3654 | } |
| @@ -4480,7 +4400,7 @@ impl<W: LayoutElement> Layout<W> { | |||
| 4480 | .position(|ws| ws.id() == ws_id) | 4400 | .position(|ws| ws.id() == ws_id) |
| 4481 | .unwrap(), | 4401 | .unwrap(), |
| 4482 | InsertWorkspace::NewAt(ws_idx) => { | 4402 | InsertWorkspace::NewAt(ws_idx) => { |
| 4483 | - if self.options.empty_workspace_above_first && ws_idx == 0 { | 4403 | + if self.options.layout.empty_workspace_above_first && ws_idx == 0 { |
| 4484 | // Reuse the top empty workspace. | 4404 | // Reuse the top empty workspace. |
| 4485 | 0 | 4405 | 0 |
| 4486 | } else if mon.workspaces.len() - 1 <= ws_idx { | 4406 | } else if mon.workspaces.len() - 1 <= ws_idx { |
| @@ -4813,7 +4733,7 @@ impl<W: LayoutElement> Layout<W> { | |||
| 4813 | } = &mut self.monitor_set | 4733 | } = &mut self.monitor_set |
| 4814 | { | 4734 | { |
| 4815 | let monitor = &mut monitors[*active_monitor_idx]; | 4735 | let monitor = &mut monitors[*active_monitor_idx]; |
| 4816 | - if self.options.empty_workspace_above_first | 4736 | + if self.options.layout.empty_workspace_above_first |
| 4817 | && monitor | 4737 | && monitor |
| 4818 | .workspaces | 4738 | .workspaces |
| 4819 | .first() | 4739 | .first() |
| @@ -5242,7 +5162,7 @@ impl<W: LayoutElement> Layout<W> { | |||
| 5242 | 5162 | ||
| 5243 | // Add border width since ColumnWidth includes borders. | 5163 | // Add border width since ColumnWidth includes borders. |
| 5244 | let rules = window.rules(); | 5164 | let rules = window.rules(); |
| 5245 | - let border = self.options.border.merged_with(&rules.border); | 5165 | + let border = self.options.layout.border.merged_with(&rules.border); |
| 5246 | if !border.off { | 5166 | if !border.off { |
| 5247 | fixed += border.width * 2.; | 5167 | fixed += border.width * 2.; |
| 5248 | } | 5168 | } |
src/layout/monitor.rsmodified+16 -14
| @@ -293,7 +293,7 @@ impl<W: LayoutElement> Monitor<W> { | |||
| 293 | active_workspace_idx: 0, | 293 | active_workspace_idx: 0, |
| 294 | previous_workspace_id: None, | 294 | previous_workspace_id: None, |
| 295 | insert_hint: None, | 295 | insert_hint: None, |
| 296 | - insert_hint_element: InsertHintElement::new(options.insert_hint), | 296 | + insert_hint_element: InsertHintElement::new(options.layout.insert_hint), |
| 297 | insert_hint_render_loc: None, | 297 | insert_hint_render_loc: None, |
| 298 | overview_open: false, | 298 | overview_open: false, |
| 299 | overview_progress: None, | 299 | overview_progress: None, |
| @@ -463,7 +463,7 @@ impl<W: LayoutElement> Monitor<W> { | |||
| 463 | if workspace_idx == self.workspaces.len() - 1 { | 463 | if workspace_idx == self.workspaces.len() - 1 { |
| 464 | self.add_workspace_bottom(); | 464 | self.add_workspace_bottom(); |
| 465 | } | 465 | } |
| 466 | - if self.options.empty_workspace_above_first && workspace_idx == 0 { | 466 | + if self.options.layout.empty_workspace_above_first && workspace_idx == 0 { |
| 467 | self.add_workspace_top(); | 467 | self.add_workspace_top(); |
| 468 | workspace_idx += 1; | 468 | workspace_idx += 1; |
| 469 | } | 469 | } |
| @@ -522,7 +522,7 @@ impl<W: LayoutElement> Monitor<W> { | |||
| 522 | self.add_workspace_bottom(); | 522 | self.add_workspace_bottom(); |
| 523 | } | 523 | } |
| 524 | 524 | ||
| 525 | - if self.options.empty_workspace_above_first && workspace_idx == 0 { | 525 | + if self.options.layout.empty_workspace_above_first && workspace_idx == 0 { |
| 526 | self.add_workspace_top(); | 526 | self.add_workspace_top(); |
| 527 | workspace_idx += 1; | 527 | workspace_idx += 1; |
| 528 | } | 528 | } |
| @@ -562,7 +562,7 @@ impl<W: LayoutElement> Monitor<W> { | |||
| 562 | pub fn clean_up_workspaces(&mut self) { | 562 | pub fn clean_up_workspaces(&mut self) { |
| 563 | assert!(self.workspace_switch.is_none()); | 563 | assert!(self.workspace_switch.is_none()); |
| 564 | 564 | ||
| 565 | - let range_start = if self.options.empty_workspace_above_first { | 565 | + let range_start = if self.options.layout.empty_workspace_above_first { |
| 566 | 1 | 566 | 1 |
| 567 | } else { | 567 | } else { |
| 568 | 0 | 568 | 0 |
| @@ -582,7 +582,7 @@ impl<W: LayoutElement> Monitor<W> { | |||
| 582 | 582 | ||
| 583 | // Special case handling when empty_workspace_above_first is set and all workspaces | 583 | // Special case handling when empty_workspace_above_first is set and all workspaces |
| 584 | // are empty. | 584 | // are empty. |
| 585 | - if self.options.empty_workspace_above_first && self.workspaces.len() == 2 { | 585 | + if self.options.layout.empty_workspace_above_first && self.workspaces.len() == 2 { |
| 586 | assert!(!self.workspaces[0].has_windows_or_name()); | 586 | assert!(!self.workspaces[0].has_windows_or_name()); |
| 587 | assert!(!self.workspaces[1].has_windows_or_name()); | 587 | assert!(!self.workspaces[1].has_windows_or_name()); |
| 588 | self.workspaces.remove(1); | 588 | self.workspaces.remove(1); |
| @@ -1023,10 +1023,11 @@ impl<W: LayoutElement> Monitor<W> { | |||
| 1023 | } | 1023 | } |
| 1024 | 1024 | ||
| 1025 | pub fn update_config(&mut self, options: Rc<Options>) { | 1025 | pub fn update_config(&mut self, options: Rc<Options>) { |
| 1026 | - if self.options.empty_workspace_above_first != options.empty_workspace_above_first | 1026 | + if self.options.layout.empty_workspace_above_first |
| 1027 | + != options.layout.empty_workspace_above_first | ||
| 1027 | && self.workspaces.len() > 1 | 1028 | && self.workspaces.len() > 1 |
| 1028 | { | 1029 | { |
| 1029 | - if options.empty_workspace_above_first { | 1030 | + if options.layout.empty_workspace_above_first { |
| 1030 | self.add_workspace_top(); | 1031 | self.add_workspace_top(); |
| 1031 | } else if self.workspace_switch.is_none() && self.active_workspace_idx != 0 { | 1032 | } else if self.workspace_switch.is_none() && self.active_workspace_idx != 0 { |
| 1032 | self.workspaces.remove(0); | 1033 | self.workspaces.remove(0); |
| @@ -1038,7 +1039,8 @@ impl<W: LayoutElement> Monitor<W> { | |||
| 1038 | ws.update_config(options.clone()); | 1039 | ws.update_config(options.clone()); |
| 1039 | } | 1040 | } |
| 1040 | 1041 | ||
| 1041 | - self.insert_hint_element.update_config(options.insert_hint); | 1042 | + self.insert_hint_element |
| 1043 | + .update_config(options.layout.insert_hint); | ||
| 1042 | 1044 | ||
| 1043 | self.options = options; | 1045 | self.options = options; |
| 1044 | } | 1046 | } |
| @@ -1074,7 +1076,7 @@ impl<W: LayoutElement> Monitor<W> { | |||
| 1074 | self.add_workspace_bottom(); | 1076 | self.add_workspace_bottom(); |
| 1075 | } | 1077 | } |
| 1076 | 1078 | ||
| 1077 | - if self.options.empty_workspace_above_first && self.active_workspace_idx == 0 { | 1079 | + if self.options.layout.empty_workspace_above_first && self.active_workspace_idx == 0 { |
| 1078 | self.add_workspace_top(); | 1080 | self.add_workspace_top(); |
| 1079 | new_idx += 1; | 1081 | new_idx += 1; |
| 1080 | } | 1082 | } |
| @@ -1100,7 +1102,7 @@ impl<W: LayoutElement> Monitor<W> { | |||
| 1100 | self.add_workspace_bottom(); | 1102 | self.add_workspace_bottom(); |
| 1101 | } | 1103 | } |
| 1102 | 1104 | ||
| 1103 | - if self.options.empty_workspace_above_first && new_idx == 0 { | 1105 | + if self.options.layout.empty_workspace_above_first && new_idx == 0 { |
| 1104 | self.add_workspace_top(); | 1106 | self.add_workspace_top(); |
| 1105 | new_idx += 1; | 1107 | new_idx += 1; |
| 1106 | } | 1108 | } |
| @@ -1132,7 +1134,7 @@ impl<W: LayoutElement> Monitor<W> { | |||
| 1132 | self.add_workspace_bottom(); | 1134 | self.add_workspace_bottom(); |
| 1133 | } | 1135 | } |
| 1134 | 1136 | ||
| 1135 | - if self.options.empty_workspace_above_first && old_idx == 0 { | 1137 | + if self.options.layout.empty_workspace_above_first && old_idx == 0 { |
| 1136 | self.add_workspace_top(); | 1138 | self.add_workspace_top(); |
| 1137 | new_idx += 1; | 1139 | new_idx += 1; |
| 1138 | } | 1140 | } |
| @@ -1142,7 +1144,7 @@ impl<W: LayoutElement> Monitor<W> { | |||
| 1142 | self.add_workspace_bottom(); | 1144 | self.add_workspace_bottom(); |
| 1143 | } | 1145 | } |
| 1144 | 1146 | ||
| 1145 | - if self.options.empty_workspace_above_first && new_idx == 0 { | 1147 | + if self.options.layout.empty_workspace_above_first && new_idx == 0 { |
| 1146 | self.add_workspace_top(); | 1148 | self.add_workspace_top(); |
| 1147 | new_idx += 1; | 1149 | new_idx += 1; |
| 1148 | } | 1150 | } |
| @@ -1464,7 +1466,7 @@ impl<W: LayoutElement> Monitor<W> { | |||
| 1464 | ) -> impl Iterator<Item = MonitorRenderElement<R>> { | 1466 | ) -> impl Iterator<Item = MonitorRenderElement<R>> { |
| 1465 | let mut rv = None; | 1467 | let mut rv = None; |
| 1466 | 1468 | ||
| 1467 | - if !self.options.insert_hint.off { | 1469 | + if !self.options.layout.insert_hint.off { |
| 1468 | if let Some(render_loc) = self.insert_hint_render_loc { | 1470 | if let Some(render_loc) = self.insert_hint_render_loc { |
| 1469 | if let InsertWorkspace::NewAt(_) = render_loc.workspace { | 1471 | if let InsertWorkspace::NewAt(_) = render_loc.workspace { |
| 1470 | let iter = self | 1472 | let iter = self |
| @@ -1525,7 +1527,7 @@ impl<W: LayoutElement> Monitor<W> { | |||
| 1525 | 1527 | ||
| 1526 | // Draw the insert hint. | 1528 | // Draw the insert hint. |
| 1527 | let mut insert_hint = None; | 1529 | let mut insert_hint = None; |
| 1528 | - if !self.options.insert_hint.off { | 1530 | + if !self.options.layout.insert_hint.off { |
| 1529 | if let Some(render_loc) = self.insert_hint_render_loc { | 1531 | if let Some(render_loc) = self.insert_hint_render_loc { |
| 1530 | if let InsertWorkspace::Existing(workspace_id) = render_loc.workspace { | 1532 | if let InsertWorkspace::Existing(workspace_id) = render_loc.workspace { |
| 1531 | insert_hint = Some(( | 1533 | insert_hint = Some(( |
src/layout/scrolling.rsmodified+78 -71
| @@ -276,7 +276,7 @@ impl<W: LayoutElement> ScrollingSpace<W> { | |||
| 276 | clock: Clock, | 276 | clock: Clock, |
| 277 | options: Rc<Options>, | 277 | options: Rc<Options>, |
| 278 | ) -> Self { | 278 | ) -> Self { |
| 279 | - let working_area = compute_working_area(parent_area, scale, options.struts); | 279 | + let working_area = compute_working_area(parent_area, scale, options.layout.struts); |
| 280 | 280 | ||
| 281 | Self { | 281 | Self { |
| 282 | columns: Vec::new(), | 282 | columns: Vec::new(), |
| @@ -303,7 +303,7 @@ impl<W: LayoutElement> ScrollingSpace<W> { | |||
| 303 | scale: f64, | 303 | scale: f64, |
| 304 | options: Rc<Options>, | 304 | options: Rc<Options>, |
| 305 | ) { | 305 | ) { |
| 306 | - let working_area = compute_working_area(parent_area, scale, options.struts); | 306 | + let working_area = compute_working_area(parent_area, scale, options.layout.struts); |
| 307 | 307 | ||
| 308 | for (column, data) in zip(&mut self.columns, &mut self.data) { | 308 | for (column, data) in zip(&mut self.columns, &mut self.data) { |
| 309 | column.update_config(view_size, working_area, scale, options.clone()); | 309 | column.update_config(view_size, working_area, scale, options.clone()); |
| @@ -444,14 +444,14 @@ impl<W: LayoutElement> ScrollingSpace<W> { | |||
| 444 | } | 444 | } |
| 445 | 445 | ||
| 446 | pub fn new_window_toplevel_bounds(&self, rules: &ResolvedWindowRules) -> Size<i32, Logical> { | 446 | pub fn new_window_toplevel_bounds(&self, rules: &ResolvedWindowRules) -> Size<i32, Logical> { |
| 447 | - let border_config = self.options.border.merged_with(&rules.border); | 447 | + let border_config = self.options.layout.border.merged_with(&rules.border); |
| 448 | 448 | ||
| 449 | let display_mode = rules | 449 | let display_mode = rules |
| 450 | .default_column_display | 450 | .default_column_display |
| 451 | - .unwrap_or(self.options.default_column_display); | 451 | + .unwrap_or(self.options.layout.default_column_display); |
| 452 | let will_tab = display_mode == ColumnDisplay::Tabbed; | 452 | let will_tab = display_mode == ColumnDisplay::Tabbed; |
| 453 | let extra_size = if will_tab { | 453 | let extra_size = if will_tab { |
| 454 | - TabIndicator::new(self.options.tab_indicator).extra_size(1, self.scale) | 454 | + TabIndicator::new(self.options.layout.tab_indicator).extra_size(1, self.scale) |
| 455 | } else { | 455 | } else { |
| 456 | Size::from((0., 0.)) | 456 | Size::from((0., 0.)) |
| 457 | }; | 457 | }; |
| @@ -460,7 +460,7 @@ impl<W: LayoutElement> ScrollingSpace<W> { | |||
| 460 | border_config, | 460 | border_config, |
| 461 | self.working_area.size, | 461 | self.working_area.size, |
| 462 | extra_size, | 462 | extra_size, |
| 463 | - self.options.gaps, | 463 | + self.options.layout.gaps, |
| 464 | ) | 464 | ) |
| 465 | } | 465 | } |
| 466 | 466 | ||
| @@ -470,14 +470,14 @@ impl<W: LayoutElement> ScrollingSpace<W> { | |||
| 470 | height: Option<PresetSize>, | 470 | height: Option<PresetSize>, |
| 471 | rules: &ResolvedWindowRules, | 471 | rules: &ResolvedWindowRules, |
| 472 | ) -> Size<i32, Logical> { | 472 | ) -> Size<i32, Logical> { |
| 473 | - let border = self.options.border.merged_with(&rules.border); | 473 | + let border = self.options.layout.border.merged_with(&rules.border); |
| 474 | 474 | ||
| 475 | let display_mode = rules | 475 | let display_mode = rules |
| 476 | .default_column_display | 476 | .default_column_display |
| 477 | - .unwrap_or(self.options.default_column_display); | 477 | + .unwrap_or(self.options.layout.default_column_display); |
| 478 | let will_tab = display_mode == ColumnDisplay::Tabbed; | 478 | let will_tab = display_mode == ColumnDisplay::Tabbed; |
| 479 | let extra = if will_tab { | 479 | let extra = if will_tab { |
| 480 | - TabIndicator::new(self.options.tab_indicator).extra_size(1, self.scale) | 480 | + TabIndicator::new(self.options.layout.tab_indicator).extra_size(1, self.scale) |
| 481 | } else { | 481 | } else { |
| 482 | Size::from((0., 0.)) | 482 | Size::from((0., 0.)) |
| 483 | }; | 483 | }; |
| @@ -500,7 +500,7 @@ impl<W: LayoutElement> ScrollingSpace<W> { | |||
| 500 | 0 | 500 | 0 |
| 501 | }; | 501 | }; |
| 502 | 502 | ||
| 503 | - let mut full_height = self.working_area.size.h - self.options.gaps * 2.; | 503 | + let mut full_height = self.working_area.size.h - self.options.layout.gaps * 2.; |
| 504 | if !border.off { | 504 | if !border.off { |
| 505 | full_height -= border.width * 2.; | 505 | full_height -= border.width * 2.; |
| 506 | } | 506 | } |
| @@ -524,8 +524,8 @@ impl<W: LayoutElement> ScrollingSpace<W> { | |||
| 524 | } | 524 | } |
| 525 | 525 | ||
| 526 | pub fn is_centering_focused_column(&self) -> bool { | 526 | pub fn is_centering_focused_column(&self) -> bool { |
| 527 | - self.options.center_focused_column == CenterFocusedColumn::Always | 527 | + self.options.layout.center_focused_column == CenterFocusedColumn::Always |
| 528 | - || (self.options.always_center_single_column && self.columns.len() <= 1) | 528 | + || (self.options.layout.always_center_single_column && self.columns.len() <= 1) |
| 529 | } | 529 | } |
| 530 | 530 | ||
| 531 | fn compute_new_view_offset_fit( | 531 | fn compute_new_view_offset_fit( |
| @@ -546,7 +546,7 @@ impl<W: LayoutElement> ScrollingSpace<W> { | |||
| 546 | self.working_area.size.w, | 546 | self.working_area.size.w, |
| 547 | col_x, | 547 | col_x, |
| 548 | width, | 548 | width, |
| 549 | - self.options.gaps, | 549 | + self.options.layout.gaps, |
| 550 | ); | 550 | ); |
| 551 | 551 | ||
| 552 | // Non-fullscreen windows are always offset at least by the working area position. | 552 | // Non-fullscreen windows are always offset at least by the working area position. |
| @@ -606,7 +606,7 @@ impl<W: LayoutElement> ScrollingSpace<W> { | |||
| 606 | return self.compute_new_view_offset_for_column_centered(target_x, idx); | 606 | return self.compute_new_view_offset_for_column_centered(target_x, idx); |
| 607 | } | 607 | } |
| 608 | 608 | ||
| 609 | - match self.options.center_focused_column { | 609 | + match self.options.layout.center_focused_column { |
| 610 | CenterFocusedColumn::Always => { | 610 | CenterFocusedColumn::Always => { |
| 611 | self.compute_new_view_offset_for_column_centered(target_x, idx) | 611 | self.compute_new_view_offset_for_column_centered(target_x, idx) |
| 612 | } | 612 | } |
| @@ -639,7 +639,7 @@ impl<W: LayoutElement> ScrollingSpace<W> { | |||
| 639 | } else { | 639 | } else { |
| 640 | // Source is right from target. | 640 | // Source is right from target. |
| 641 | source_col_x - target_col_x + source_col_width | 641 | source_col_x - target_col_x + source_col_width |
| 642 | - } + self.options.gaps * 2.; | 642 | + } + self.options.layout.gaps * 2.; |
| 643 | 643 | ||
| 644 | // If it fits together, do a normal animation, otherwise center the new column. | 644 | // If it fits together, do a normal animation, otherwise center the new column. |
| 645 | if total_width <= self.working_area.size.w { | 645 | if total_width <= self.working_area.size.w { |
| @@ -783,8 +783,8 @@ impl<W: LayoutElement> ScrollingSpace<W> { | |||
| 783 | let x = pos.x + self.view_pos(); | 783 | let x = pos.x + self.view_pos(); |
| 784 | 784 | ||
| 785 | // Aim for the center of the gap. | 785 | // Aim for the center of the gap. |
| 786 | - let x = x + self.options.gaps / 2.; | 786 | + let x = x + self.options.layout.gaps / 2.; |
| 787 | - let y = pos.y + self.options.gaps / 2.; | 787 | + let y = pos.y + self.options.layout.gaps / 2.; |
| 788 | 788 | ||
| 789 | // Insert position is before the first column. | 789 | // Insert position is before the first column. |
| 790 | if x < 0. { | 790 | if x < 0. { |
| @@ -2224,7 +2224,7 @@ impl<W: LayoutElement> ScrollingSpace<W> { | |||
| 2224 | let mut leftmost_col_x = None; | 2224 | let mut leftmost_col_x = None; |
| 2225 | let mut active_col_x = None; | 2225 | let mut active_col_x = None; |
| 2226 | 2226 | ||
| 2227 | - let gap = self.options.gaps; | 2227 | + let gap = self.options.layout.gaps; |
| 2228 | let col_xs = self.column_xs(self.data.iter().copied()); | 2228 | let col_xs = self.column_xs(self.data.iter().copied()); |
| 2229 | for (idx, col_x) in col_xs.take(self.columns.len()).enumerate() { | 2229 | for (idx, col_x) in col_xs.take(self.columns.len()).enumerate() { |
| 2230 | if col_x < view_x + working_x + gap { | 2230 | if col_x < view_x + working_x + gap { |
| @@ -2274,7 +2274,7 @@ impl<W: LayoutElement> ScrollingSpace<W> { | |||
| 2274 | // HACK: pass a self.data iterator in manually as a workaround for the lack of method partial | 2274 | // HACK: pass a self.data iterator in manually as a workaround for the lack of method partial |
| 2275 | // borrowing. Note that this method's return value does not borrow the entire &Self! | 2275 | // borrowing. Note that this method's return value does not borrow the entire &Self! |
| 2276 | fn column_xs(&self, data: impl Iterator<Item = ColumnData>) -> impl Iterator<Item = f64> { | 2276 | fn column_xs(&self, data: impl Iterator<Item = ColumnData>) -> impl Iterator<Item = f64> { |
| 2277 | - let gaps = self.options.gaps; | 2277 | + let gaps = self.options.layout.gaps; |
| 2278 | let mut x = 0.; | 2278 | let mut x = 0.; |
| 2279 | 2279 | ||
| 2280 | // Chain with a dummy value to be able to get one past all columns' X. | 2280 | // Chain with a dummy value to be able to get one past all columns' X. |
| @@ -2408,25 +2408,29 @@ impl<W: LayoutElement> ScrollingSpace<W> { | |||
| 2408 | let mut hint_area = match position { | 2408 | let mut hint_area = match position { |
| 2409 | InsertPosition::NewColumn(column_index) => { | 2409 | InsertPosition::NewColumn(column_index) => { |
| 2410 | if column_index == 0 || column_index == self.columns.len() { | 2410 | if column_index == 0 || column_index == self.columns.len() { |
| 2411 | - let size = | 2411 | + let size = Size::from(( |
| 2412 | - Size::from((300., self.working_area.size.h - self.options.gaps * 2.)); | 2412 | + 300., |
| 2413 | + self.working_area.size.h - self.options.layout.gaps * 2., | ||
| 2414 | + )); | ||
| 2413 | let mut loc = Point::from(( | 2415 | let mut loc = Point::from(( |
| 2414 | self.column_x(column_index), | 2416 | self.column_x(column_index), |
| 2415 | - self.working_area.loc.y + self.options.gaps, | 2417 | + self.working_area.loc.y + self.options.layout.gaps, |
| 2416 | )); | 2418 | )); |
| 2417 | if column_index == 0 && !self.columns.is_empty() { | 2419 | if column_index == 0 && !self.columns.is_empty() { |
| 2418 | - loc.x -= size.w + self.options.gaps; | 2420 | + loc.x -= size.w + self.options.layout.gaps; |
| 2419 | } | 2421 | } |
| 2420 | Rectangle::new(loc, size) | 2422 | Rectangle::new(loc, size) |
| 2421 | } else if column_index > self.columns.len() { | 2423 | } else if column_index > self.columns.len() { |
| 2422 | error!("insert hint column index is out of range"); | 2424 | error!("insert hint column index is out of range"); |
| 2423 | return None; | 2425 | return None; |
| 2424 | } else { | 2426 | } else { |
| 2425 | - let size = | 2427 | + let size = Size::from(( |
| 2426 | - Size::from((300., self.working_area.size.h - self.options.gaps * 2.)); | 2428 | + 300., |
| 2429 | + self.working_area.size.h - self.options.layout.gaps * 2., | ||
| 2430 | + )); | ||
| 2427 | let loc = Point::from(( | 2431 | let loc = Point::from(( |
| 2428 | - self.column_x(column_index) - size.w / 2. - self.options.gaps / 2., | 2432 | + self.column_x(column_index) - size.w / 2. - self.options.layout.gaps / 2., |
| 2429 | - self.working_area.loc.y + self.options.gaps, | 2433 | + self.working_area.loc.y + self.options.layout.gaps, |
| 2430 | )); | 2434 | )); |
| 2431 | Rectangle::new(loc, size) | 2435 | Rectangle::new(loc, size) |
| 2432 | } | 2436 | } |
| @@ -2462,9 +2466,9 @@ impl<W: LayoutElement> ScrollingSpace<W> { | |||
| 2462 | if tile_index == 0 { | 2466 | if tile_index == 0 { |
| 2463 | (150., top) | 2467 | (150., top) |
| 2464 | } else if tile_index == col.tiles.len() { | 2468 | } else if tile_index == col.tiles.len() { |
| 2465 | - (150., top - self.options.gaps - 150.) | 2469 | + (150., top - self.options.layout.gaps - 150.) |
| 2466 | } else { | 2470 | } else { |
| 2467 | - (300., top - self.options.gaps / 2. - 150.) | 2471 | + (300., top - self.options.layout.gaps / 2. - 150.) |
| 2468 | } | 2472 | } |
| 2469 | }; | 2473 | }; |
| 2470 | 2474 | ||
| @@ -2716,7 +2720,7 @@ impl<W: LayoutElement> ScrollingSpace<W> { | |||
| 2716 | let mut active_col_x = None; | 2720 | let mut active_col_x = None; |
| 2717 | let mut counted_non_active_column = false; | 2721 | let mut counted_non_active_column = false; |
| 2718 | 2722 | ||
| 2719 | - let gap = self.options.gaps; | 2723 | + let gap = self.options.layout.gaps; |
| 2720 | let col_xs = self.column_xs(self.data.iter().copied()); | 2724 | let col_xs = self.column_xs(self.data.iter().copied()); |
| 2721 | for (idx, col_x) in col_xs.take(self.columns.len()).enumerate() { | 2725 | for (idx, col_x) in col_xs.take(self.columns.len()).enumerate() { |
| 2722 | if col_x < view_x + working_x + gap { | 2726 | if col_x < view_x + working_x + gap { |
| @@ -3051,7 +3055,7 @@ impl<W: LayoutElement> ScrollingSpace<W> { | |||
| 3051 | let (leftmost, rightmost) = if self.columns.is_empty() { | 3055 | let (leftmost, rightmost) = if self.columns.is_empty() { |
| 3052 | (0., 0.) | 3056 | (0., 0.) |
| 3053 | } else { | 3057 | } else { |
| 3054 | - let gaps = self.options.gaps; | 3058 | + let gaps = self.options.layout.gaps; |
| 3055 | 3059 | ||
| 3056 | let mut leftmost = -self.working_area.size.w; | 3060 | let mut leftmost = -self.working_area.size.w; |
| 3057 | 3061 | ||
| @@ -3147,17 +3151,17 @@ impl<W: LayoutElement> ScrollingSpace<W> { | |||
| 3147 | }; | 3151 | }; |
| 3148 | snapping_points.push(Snap { view_pos, col_idx }); | 3152 | snapping_points.push(Snap { view_pos, col_idx }); |
| 3149 | 3153 | ||
| 3150 | - col_x += col_w + self.options.gaps; | 3154 | + col_x += col_w + self.options.layout.gaps; |
| 3151 | } | 3155 | } |
| 3152 | } else { | 3156 | } else { |
| 3153 | let center_on_overflow = matches!( | 3157 | let center_on_overflow = matches!( |
| 3154 | - self.options.center_focused_column, | 3158 | + self.options.layout.center_focused_column, |
| 3155 | CenterFocusedColumn::OnOverflow | 3159 | CenterFocusedColumn::OnOverflow |
| 3156 | ); | 3160 | ); |
| 3157 | 3161 | ||
| 3158 | let view_width = self.view_size.w; | 3162 | let view_width = self.view_size.w; |
| 3159 | let working_area_width = self.working_area.size.w; | 3163 | let working_area_width = self.working_area.size.w; |
| 3160 | - let gaps = self.options.gaps; | 3164 | + let gaps = self.options.layout.gaps; |
| 3161 | 3165 | ||
| 3162 | let snap_points = | 3166 | let snap_points = |
| 3163 | |col_x, col: &Column<W>, prev_col_w: Option<f64>, next_col_w: Option<f64>| { | 3167 | |col_x, col: &Column<W>, prev_col_w: Option<f64>, next_col_w: Option<f64>| { |
| @@ -3297,8 +3301,8 @@ impl<W: LayoutElement> ScrollingSpace<W> { | |||
| 3297 | break; | 3301 | break; |
| 3298 | } | 3302 | } |
| 3299 | } else { | 3303 | } else { |
| 3300 | - let padding = | 3304 | + let padding = ((self.working_area.size.w - col_w) / 2.) |
| 3301 | - ((self.working_area.size.w - col_w) / 2.).clamp(0., self.options.gaps); | 3305 | + .clamp(0., self.options.layout.gaps); |
| 3302 | if target_snap.view_pos + left_strut + self.working_area.size.w | 3306 | if target_snap.view_pos + left_strut + self.working_area.size.w |
| 3303 | < col_x + col_w + padding | 3307 | < col_x + col_w + padding |
| 3304 | { | 3308 | { |
| @@ -3319,8 +3323,8 @@ impl<W: LayoutElement> ScrollingSpace<W> { | |||
| 3319 | break; | 3323 | break; |
| 3320 | } | 3324 | } |
| 3321 | } else { | 3325 | } else { |
| 3322 | - let padding = | 3326 | + let padding = ((self.working_area.size.w - col_w) / 2.) |
| 3323 | - ((self.working_area.size.w - col_w) / 2.).clamp(0., self.options.gaps); | 3327 | + .clamp(0., self.options.layout.gaps); |
| 3324 | if col_x - padding < target_snap.view_pos + left_strut { | 3328 | if col_x - padding < target_snap.view_pos + left_strut { |
| 3325 | break; | 3329 | break; |
| 3326 | } | 3330 | } |
| @@ -3548,12 +3552,12 @@ impl<W: LayoutElement> ScrollingSpace<W> { | |||
| 3548 | 3552 | ||
| 3549 | win.set_interactive_resize(col_resize_data); | 3553 | win.set_interactive_resize(col_resize_data); |
| 3550 | 3554 | ||
| 3551 | - let border_config = self.options.border.merged_with(&win.rules().border); | 3555 | + let border_config = self.options.layout.border.merged_with(&win.rules().border); |
| 3552 | let bounds = compute_toplevel_bounds( | 3556 | let bounds = compute_toplevel_bounds( |
| 3553 | border_config, | 3557 | border_config, |
| 3554 | self.working_area.size, | 3558 | self.working_area.size, |
| 3555 | extra_size, | 3559 | extra_size, |
| 3556 | - self.options.gaps, | 3560 | + self.options.layout.gaps, |
| 3557 | ); | 3561 | ); |
| 3558 | win.set_bounds(bounds); | 3562 | win.set_bounds(bounds); |
| 3559 | 3563 | ||
| @@ -3614,7 +3618,7 @@ impl<W: LayoutElement> ScrollingSpace<W> { | |||
| 3614 | assert_eq!(self.columns.len(), self.data.len()); | 3618 | assert_eq!(self.columns.len(), self.data.len()); |
| 3615 | assert_eq!( | 3619 | assert_eq!( |
| 3616 | self.working_area, | 3620 | self.working_area, |
| 3617 | - compute_working_area(self.parent_area, self.scale, self.options.struts) | 3621 | + compute_working_area(self.parent_area, self.scale, self.options.layout.struts) |
| 3618 | ); | 3622 | ); |
| 3619 | 3623 | ||
| 3620 | if !self.columns.is_empty() { | 3624 | if !self.columns.is_empty() { |
| @@ -3802,7 +3806,7 @@ impl<W: LayoutElement> Column<W> { | |||
| 3802 | .window() | 3806 | .window() |
| 3803 | .rules() | 3807 | .rules() |
| 3804 | .default_column_display | 3808 | .default_column_display |
| 3805 | - .unwrap_or(options.default_column_display); | 3809 | + .unwrap_or(options.layout.default_column_display); |
| 3806 | 3810 | ||
| 3807 | let mut rv = Self { | 3811 | let mut rv = Self { |
| 3808 | tiles: vec![], | 3812 | tiles: vec![], |
| @@ -3813,7 +3817,7 @@ impl<W: LayoutElement> Column<W> { | |||
| 3813 | is_full_width, | 3817 | is_full_width, |
| 3814 | is_pending_fullscreen: false, | 3818 | is_pending_fullscreen: false, |
| 3815 | display_mode, | 3819 | display_mode, |
| 3816 | - tab_indicator: TabIndicator::new(options.tab_indicator), | 3820 | + tab_indicator: TabIndicator::new(options.layout.tab_indicator), |
| 3817 | move_animation: None, | 3821 | move_animation: None, |
| 3818 | view_size, | 3822 | view_size, |
| 3819 | working_area, | 3823 | working_area, |
| @@ -3832,7 +3836,7 @@ impl<W: LayoutElement> Column<W> { | |||
| 3832 | 3836 | ||
| 3833 | // Animate the tab indicator for new columns. | 3837 | // Animate the tab indicator for new columns. |
| 3834 | if display_mode == ColumnDisplay::Tabbed | 3838 | if display_mode == ColumnDisplay::Tabbed |
| 3835 | - && !rv.options.tab_indicator.hide_when_single_tab | 3839 | + && !rv.options.layout.tab_indicator.hide_when_single_tab |
| 3836 | && !rv.is_fullscreen() | 3840 | && !rv.is_fullscreen() |
| 3837 | { | 3841 | { |
| 3838 | // Usually new columns are created together with window movement actions. For new | 3842 | // Usually new columns are created together with window movement actions. For new |
| @@ -3858,27 +3862,27 @@ impl<W: LayoutElement> Column<W> { | |||
| 3858 | } | 3862 | } |
| 3859 | 3863 | ||
| 3860 | // If preset widths changed, clear our stored preset index. | 3864 | // If preset widths changed, clear our stored preset index. |
| 3861 | - if self.options.preset_column_widths != options.preset_column_widths { | 3865 | + if self.options.layout.preset_column_widths != options.layout.preset_column_widths { |
| 3862 | self.preset_width_idx = None; | 3866 | self.preset_width_idx = None; |
| 3863 | } | 3867 | } |
| 3864 | 3868 | ||
| 3865 | // If preset heights changed, make our heights non-preset. | 3869 | // If preset heights changed, make our heights non-preset. |
| 3866 | - if self.options.preset_window_heights != options.preset_window_heights { | 3870 | + if self.options.layout.preset_window_heights != options.layout.preset_window_heights { |
| 3867 | self.convert_heights_to_auto(); | 3871 | self.convert_heights_to_auto(); |
| 3868 | update_sizes = true; | 3872 | update_sizes = true; |
| 3869 | } | 3873 | } |
| 3870 | 3874 | ||
| 3871 | - if self.options.gaps != options.gaps { | 3875 | + if self.options.layout.gaps != options.layout.gaps { |
| 3872 | update_sizes = true; | 3876 | update_sizes = true; |
| 3873 | } | 3877 | } |
| 3874 | 3878 | ||
| 3875 | - if self.options.border.off != options.border.off | 3879 | + if self.options.layout.border.off != options.layout.border.off |
| 3876 | - || self.options.border.width != options.border.width | 3880 | + || self.options.layout.border.width != options.layout.border.width |
| 3877 | { | 3881 | { |
| 3878 | update_sizes = true; | 3882 | update_sizes = true; |
| 3879 | } | 3883 | } |
| 3880 | 3884 | ||
| 3881 | - if self.options.tab_indicator != options.tab_indicator { | 3885 | + if self.options.layout.tab_indicator != options.layout.tab_indicator { |
| 3882 | update_sizes = true; | 3886 | update_sizes = true; |
| 3883 | } | 3887 | } |
| 3884 | 3888 | ||
| @@ -3887,7 +3891,8 @@ impl<W: LayoutElement> Column<W> { | |||
| 3887 | data.update(tile); | 3891 | data.update(tile); |
| 3888 | } | 3892 | } |
| 3889 | 3893 | ||
| 3890 | - self.tab_indicator.update_config(options.tab_indicator); | 3894 | + self.tab_indicator |
| 3895 | + .update_config(options.layout.tab_indicator); | ||
| 3891 | self.view_size = view_size; | 3896 | self.view_size = view_size; |
| 3892 | self.working_area = working_area; | 3897 | self.working_area = working_area; |
| 3893 | self.scale = scale; | 3898 | self.scale = scale; |
| @@ -4192,7 +4197,7 @@ impl<W: LayoutElement> Column<W> { | |||
| 4192 | 4197 | ||
| 4193 | fn resolve_column_width(&self, width: ColumnWidth) -> f64 { | 4198 | fn resolve_column_width(&self, width: ColumnWidth) -> f64 { |
| 4194 | let working_size = self.working_area.size; | 4199 | let working_size = self.working_area.size; |
| 4195 | - let gaps = self.options.gaps; | 4200 | + let gaps = self.options.layout.gaps; |
| 4196 | let extra = self.extra_size(); | 4201 | let extra = self.extra_size(); |
| 4197 | 4202 | ||
| 4198 | match width { | 4203 | match width { |
| @@ -4274,7 +4279,7 @@ impl<W: LayoutElement> Column<W> { | |||
| 4274 | 4279 | ||
| 4275 | let width = self.resolve_column_width(width); | 4280 | let width = self.resolve_column_width(width); |
| 4276 | let width = f64::max(f64::min(width, max_width), min_width); | 4281 | let width = f64::max(f64::min(width, max_width), min_width); |
| 4277 | - let max_tile_height = working_size.h - self.options.gaps * 2. - extra_size.h; | 4282 | + let max_tile_height = working_size.h - self.options.layout.gaps * 2. - extra_size.h; |
| 4278 | 4283 | ||
| 4279 | // If there are multiple windows in a column, clamp the non-auto window's height according | 4284 | // If there are multiple windows in a column, clamp the non-auto window's height according |
| 4280 | // to other windows' min sizes. | 4285 | // to other windows' min sizes. |
| @@ -4289,7 +4294,7 @@ impl<W: LayoutElement> Column<W> { | |||
| 4289 | .iter() | 4294 | .iter() |
| 4290 | .enumerate() | 4295 | .enumerate() |
| 4291 | .filter(|(idx, _)| *idx != non_auto_idx) | 4296 | .filter(|(idx, _)| *idx != non_auto_idx) |
| 4292 | - .map(|(_, min_size)| min_size.h + self.options.gaps) | 4297 | + .map(|(_, min_size)| min_size.h + self.options.layout.gaps) |
| 4293 | .sum::<f64>(); | 4298 | .sum::<f64>(); |
| 4294 | 4299 | ||
| 4295 | let tile = &self.tiles[non_auto_idx]; | 4300 | let tile = &self.tiles[non_auto_idx]; |
| @@ -4318,7 +4323,7 @@ impl<W: LayoutElement> Column<W> { | |||
| 4318 | WindowHeight::Fixed(tile.tile_height_for_window_height(window_height)) | 4323 | WindowHeight::Fixed(tile.tile_height_for_window_height(window_height)) |
| 4319 | } | 4324 | } |
| 4320 | WindowHeight::Preset(idx) => { | 4325 | WindowHeight::Preset(idx) => { |
| 4321 | - let preset = self.options.preset_window_heights[idx]; | 4326 | + let preset = self.options.layout.preset_window_heights[idx]; |
| 4322 | let window_height = match self.resolve_preset_height(preset) { | 4327 | let window_height = match self.resolve_preset_height(preset) { |
| 4323 | ResolvedSize::Tile(h) => tile.window_height_for_tile_height(h), | 4328 | ResolvedSize::Tile(h) => tile.window_height_for_tile_height(h), |
| 4324 | ResolvedSize::Window(h) => h, | 4329 | ResolvedSize::Window(h) => h, |
| @@ -4366,7 +4371,7 @@ impl<W: LayoutElement> Column<W> { | |||
| 4366 | // The following logic will apply individual min/max height, etc. | 4371 | // The following logic will apply individual min/max height, etc. |
| 4367 | } | 4372 | } |
| 4368 | 4373 | ||
| 4369 | - let gaps_left = self.options.gaps * (self.tiles.len() + 1) as f64; | 4374 | + let gaps_left = self.options.layout.gaps * (self.tiles.len() + 1) as f64; |
| 4370 | let mut height_left = working_size.h - gaps_left; | 4375 | let mut height_left = working_size.h - gaps_left; |
| 4371 | let mut auto_tiles_left = self.tiles.len(); | 4376 | let mut auto_tiles_left = self.tiles.len(); |
| 4372 | 4377 | ||
| @@ -4589,7 +4594,7 @@ impl<W: LayoutElement> Column<W> { | |||
| 4589 | self.preset_width_idx | 4594 | self.preset_width_idx |
| 4590 | }; | 4595 | }; |
| 4591 | 4596 | ||
| 4592 | - let len = self.options.preset_column_widths.len(); | 4597 | + let len = self.options.layout.preset_column_widths.len(); |
| 4593 | let preset_idx = if let Some(idx) = preset_idx { | 4598 | let preset_idx = if let Some(idx) = preset_idx { |
| 4594 | (idx + if forwards { 1 } else { len - 1 }) % len | 4599 | (idx + if forwards { 1 } else { len - 1 }) % len |
| 4595 | } else { | 4600 | } else { |
| @@ -4599,6 +4604,7 @@ impl<W: LayoutElement> Column<W> { | |||
| 4599 | 4604 | ||
| 4600 | let mut it = self | 4605 | let mut it = self |
| 4601 | .options | 4606 | .options |
| 4607 | + .layout | ||
| 4602 | .preset_column_widths | 4608 | .preset_column_widths |
| 4603 | .iter() | 4609 | .iter() |
| 4604 | .map(|preset| self.resolve_preset_width(*preset)); | 4610 | .map(|preset| self.resolve_preset_width(*preset)); |
| @@ -4624,7 +4630,7 @@ impl<W: LayoutElement> Column<W> { | |||
| 4624 | } | 4630 | } |
| 4625 | }; | 4631 | }; |
| 4626 | 4632 | ||
| 4627 | - let preset = self.options.preset_column_widths[preset_idx]; | 4633 | + let preset = self.options.layout.preset_column_widths[preset_idx]; |
| 4628 | self.set_column_width(SizeChange::from(preset), Some(tile_idx), true); | 4634 | self.set_column_width(SizeChange::from(preset), Some(tile_idx), true); |
| 4629 | 4635 | ||
| 4630 | self.preset_width_idx = Some(preset_idx); | 4636 | self.preset_width_idx = Some(preset_idx); |
| @@ -4672,11 +4678,11 @@ impl<W: LayoutElement> Column<W> { | |||
| 4672 | ColumnWidth::Proportion(proportion) | 4678 | ColumnWidth::Proportion(proportion) |
| 4673 | } | 4679 | } |
| 4674 | (ColumnWidth::Fixed(_), SizeChange::AdjustProportion(delta)) => { | 4680 | (ColumnWidth::Fixed(_), SizeChange::AdjustProportion(delta)) => { |
| 4675 | - let full = self.working_area.size.w - self.options.gaps; | 4681 | + let full = self.working_area.size.w - self.options.layout.gaps; |
| 4676 | let current = if full == 0. { | 4682 | let current = if full == 0. { |
| 4677 | 1. | 4683 | 1. |
| 4678 | } else { | 4684 | } else { |
| 4679 | - (current_px + self.options.gaps + self.extra_size().w) / full | 4685 | + (current_px + self.options.layout.gaps + self.extra_size().w) / full |
| 4680 | }; | 4686 | }; |
| 4681 | let proportion = (current + delta / 100.).clamp(0., MAX_F); | 4687 | let proportion = (current + delta / 100.).clamp(0., MAX_F); |
| 4682 | ColumnWidth::Proportion(proportion) | 4688 | ColumnWidth::Proportion(proportion) |
| @@ -4710,7 +4716,7 @@ impl<W: LayoutElement> Column<W> { | |||
| 4710 | let current_tile_px = tile.tile_height_for_window_height(current_window_px); | 4716 | let current_tile_px = tile.tile_height_for_window_height(current_window_px); |
| 4711 | 4717 | ||
| 4712 | let working_size = self.working_area.size.h; | 4718 | let working_size = self.working_area.size.h; |
| 4713 | - let gaps = self.options.gaps; | 4719 | + let gaps = self.options.layout.gaps; |
| 4714 | let extra_size = self.extra_size().h; | 4720 | let extra_size = self.extra_size().h; |
| 4715 | let full = working_size - gaps; | 4721 | let full = working_size - gaps; |
| 4716 | let current_prop = if full == 0. { | 4722 | let current_prop = if full == 0. { |
| @@ -4794,7 +4800,7 @@ impl<W: LayoutElement> Column<W> { | |||
| 4794 | self.convert_heights_to_auto(); | 4800 | self.convert_heights_to_auto(); |
| 4795 | } | 4801 | } |
| 4796 | 4802 | ||
| 4797 | - let len = self.options.preset_window_heights.len(); | 4803 | + let len = self.options.layout.preset_window_heights.len(); |
| 4798 | let preset_idx = match self.data[tile_idx].height { | 4804 | let preset_idx = match self.data[tile_idx].height { |
| 4799 | WindowHeight::Preset(idx) => (idx + if forwards { 1 } else { len - 1 }) % len, | 4805 | WindowHeight::Preset(idx) => (idx + if forwards { 1 } else { len - 1 }) % len, |
| 4800 | _ => { | 4806 | _ => { |
| @@ -4803,6 +4809,7 @@ impl<W: LayoutElement> Column<W> { | |||
| 4803 | 4809 | ||
| 4804 | let mut it = self | 4810 | let mut it = self |
| 4805 | .options | 4811 | .options |
| 4812 | + .layout | ||
| 4806 | .preset_window_heights | 4813 | .preset_window_heights |
| 4807 | .iter() | 4814 | .iter() |
| 4808 | .copied() | 4815 | .copied() |
| @@ -4933,7 +4940,7 @@ impl<W: LayoutElement> Column<W> { | |||
| 4933 | return origin; | 4940 | return origin; |
| 4934 | } | 4941 | } |
| 4935 | 4942 | ||
| 4936 | - origin.y += self.working_area.loc.y + self.options.gaps; | 4943 | + origin.y += self.working_area.loc.y + self.options.layout.gaps; |
| 4937 | 4944 | ||
| 4938 | if self.display_mode == ColumnDisplay::Tabbed { | 4945 | if self.display_mode == ColumnDisplay::Tabbed { |
| 4939 | origin += self | 4946 | origin += self |
| @@ -4953,8 +4960,8 @@ impl<W: LayoutElement> Column<W> { | |||
| 4953 | // FIXME: this should take into account always-center-single-column, which means that | 4960 | // FIXME: this should take into account always-center-single-column, which means that |
| 4954 | // Column should somehow know when it is being centered due to being the single column on | 4961 | // Column should somehow know when it is being centered due to being the single column on |
| 4955 | // the workspace or some other reason. | 4962 | // the workspace or some other reason. |
| 4956 | - let center = self.options.center_focused_column == CenterFocusedColumn::Always; | 4963 | + let center = self.options.layout.center_focused_column == CenterFocusedColumn::Always; |
| 4957 | - let gaps = self.options.gaps; | 4964 | + let gaps = self.options.layout.gaps; |
| 4958 | let tabbed = self.display_mode == ColumnDisplay::Tabbed; | 4965 | let tabbed = self.display_mode == ColumnDisplay::Tabbed; |
| 4959 | 4966 | ||
| 4960 | // Does not include extra size from the tab indicator. | 4967 | // Does not include extra size from the tab indicator. |
| @@ -5117,7 +5124,7 @@ impl<W: LayoutElement> Column<W> { | |||
| 5117 | } | 5124 | } |
| 5118 | 5125 | ||
| 5119 | if let Some(idx) = self.preset_width_idx { | 5126 | if let Some(idx) = self.preset_width_idx { |
| 5120 | - assert!(idx < self.options.preset_column_widths.len()); | 5127 | + assert!(idx < self.options.layout.preset_column_widths.len()); |
| 5121 | } | 5128 | } |
| 5122 | 5129 | ||
| 5123 | let is_tabbed = self.display_mode == ColumnDisplay::Tabbed; | 5130 | let is_tabbed = self.display_mode == ColumnDisplay::Tabbed; |
| @@ -5134,7 +5141,7 @@ impl<W: LayoutElement> Column<W> { | |||
| 5134 | 5141 | ||
| 5135 | let working_size = self.working_area.size; | 5142 | let working_size = self.working_area.size; |
| 5136 | let extra_size = self.extra_size(); | 5143 | let extra_size = self.extra_size(); |
| 5137 | - let gaps = self.options.gaps; | 5144 | + let gaps = self.options.layout.gaps; |
| 5138 | 5145 | ||
| 5139 | let mut found_fixed = false; | 5146 | let mut found_fixed = false; |
| 5140 | let mut total_height = 0.; | 5147 | let mut total_height = 0.; |
| @@ -5163,7 +5170,7 @@ impl<W: LayoutElement> Column<W> { | |||
| 5163 | } | 5170 | } |
| 5164 | 5171 | ||
| 5165 | if let WindowHeight::Preset(idx) = data.height { | 5172 | if let WindowHeight::Preset(idx) = data.height { |
| 5166 | - assert!(self.options.preset_window_heights.len() > idx); | 5173 | + assert!(self.options.layout.preset_window_heights.len() > idx); |
| 5167 | } | 5174 | } |
| 5168 | 5175 | ||
| 5169 | let requested_size = tile.window().requested_size().unwrap(); | 5176 | let requested_size = tile.window().requested_size().unwrap(); |
| @@ -5312,9 +5319,9 @@ fn resolve_preset_size( | |||
| 5312 | extra_size: f64, | 5319 | extra_size: f64, |
| 5313 | ) -> ResolvedSize { | 5320 | ) -> ResolvedSize { |
| 5314 | match preset { | 5321 | match preset { |
| 5315 | - PresetSize::Proportion(proportion) => { | 5322 | + PresetSize::Proportion(proportion) => ResolvedSize::Tile( |
| 5316 | - ResolvedSize::Tile((view_size - options.gaps) * proportion - options.gaps - extra_size) | 5323 | + (view_size - options.layout.gaps) * proportion - options.layout.gaps - extra_size, |
| 5317 | - } | 5324 | + ), |
| 5318 | PresetSize::Fixed(width) => ResolvedSize::Window(f64::from(width)), | 5325 | PresetSize::Fixed(width) => ResolvedSize::Window(f64::from(width)), |
| 5319 | } | 5326 | } |
| 5320 | } | 5327 | } |
src/layout/tests.rsmodified+87 -34
| @@ -2,7 +2,8 @@ use std::cell::{Cell, OnceCell, RefCell}; | |||
| 2 | 2 | ||
| 3 | use niri_config::workspace::WorkspaceName; | 3 | use niri_config::workspace::WorkspaceName; |
| 4 | use niri_config::{ | 4 | use niri_config::{ |
| 5 | - FloatOrInt, OutputName, TabIndicatorLength, TabIndicatorPosition, WorkspaceReference, | 5 | + CenterFocusedColumn, FloatOrInt, OutputName, Struts, TabIndicatorLength, TabIndicatorPosition, |
| 6 | + WorkspaceReference, | ||
| 6 | }; | 7 | }; |
| 7 | use proptest::prelude::*; | 8 | use proptest::prelude::*; |
| 8 | use proptest_derive::Arbitrary; | 9 | use proptest_derive::Arbitrary; |
| @@ -2066,8 +2067,8 @@ fn large_negative_height_change() { | |||
| 2066 | ]; | 2067 | ]; |
| 2067 | 2068 | ||
| 2068 | let mut options = Options::default(); | 2069 | let mut options = Options::default(); |
| 2069 | - options.border.off = false; | 2070 | + options.layout.border.off = false; |
| 2070 | - options.border.width = 1.; | 2071 | + options.layout.border.width = 1.; |
| 2071 | 2072 | ||
| 2072 | check_ops_with_options(options, ops); | 2073 | check_ops_with_options(options, ops); |
| 2073 | } | 2074 | } |
| @@ -2085,8 +2086,8 @@ fn large_max_size() { | |||
| 2085 | ]; | 2086 | ]; |
| 2086 | 2087 | ||
| 2087 | let mut options = Options::default(); | 2088 | let mut options = Options::default(); |
| 2088 | - options.border.off = false; | 2089 | + options.layout.border.off = false; |
| 2089 | - options.border.width = 1.; | 2090 | + options.layout.border.width = 1.; |
| 2090 | 2091 | ||
| 2091 | check_ops_with_options(options, ops); | 2092 | check_ops_with_options(options, ops); |
| 2092 | } | 2093 | } |
| @@ -2244,7 +2245,10 @@ fn open_right_of_on_different_workspace_ewaf() { | |||
| 2244 | ]; | 2245 | ]; |
| 2245 | 2246 | ||
| 2246 | let options = Options { | 2247 | let options = Options { |
| 2247 | - empty_workspace_above_first: true, | 2248 | + layout: niri_config::Layout { |
| 2249 | + empty_workspace_above_first: true, | ||
| 2250 | + ..Default::default() | ||
| 2251 | + }, | ||
| 2248 | ..Default::default() | 2252 | ..Default::default() |
| 2249 | }; | 2253 | }; |
| 2250 | let layout = check_ops_with_options(options, ops); | 2254 | let layout = check_ops_with_options(options, ops); |
| @@ -2306,11 +2310,7 @@ fn config_change_updates_cached_sizes() { | |||
| 2306 | } | 2310 | } |
| 2307 | .apply(&mut layout); | 2311 | .apply(&mut layout); |
| 2308 | 2312 | ||
| 2309 | - config | 2313 | + config.layout.border.as_mut().unwrap().width = Some(FloatOrInt(4.)); |
| 2310 | - .layout | ||
| 2311 | - .border | ||
| 2312 | - .get_or_insert_with(Default::default) | ||
| 2313 | - .width = Some(FloatOrInt(4.)); | ||
| 2314 | layout.update_config(&config); | 2314 | layout.update_config(&config); |
| 2315 | 2315 | ||
| 2316 | layout.verify_invariants(); | 2316 | layout.verify_invariants(); |
| @@ -2427,12 +2427,15 @@ fn fixed_height_takes_max_non_auto_into_account() { | |||
| 2427 | ]; | 2427 | ]; |
| 2428 | 2428 | ||
| 2429 | let options = Options { | 2429 | let options = Options { |
| 2430 | - border: niri_config::Border { | 2430 | + layout: niri_config::Layout { |
| 2431 | - off: false, | 2431 | + border: niri_config::Border { |
| 2432 | - width: 4., | 2432 | + off: false, |
| 2433 | + width: 4., | ||
| 2434 | + ..Default::default() | ||
| 2435 | + }, | ||
| 2436 | + gaps: 0., | ||
| 2433 | ..Default::default() | 2437 | ..Default::default() |
| 2434 | }, | 2438 | }, |
| 2435 | - gaps: 0., | ||
| 2436 | ..Default::default() | 2439 | ..Default::default() |
| 2437 | }; | 2440 | }; |
| 2438 | check_ops_with_options(options, ops); | 2441 | check_ops_with_options(options, ops); |
| @@ -2511,7 +2514,10 @@ fn interactive_move_onto_empty_output_ewaf() { | |||
| 2511 | ]; | 2514 | ]; |
| 2512 | 2515 | ||
| 2513 | let options = Options { | 2516 | let options = Options { |
| 2514 | - empty_workspace_above_first: true, | 2517 | + layout: niri_config::Layout { |
| 2518 | + empty_workspace_above_first: true, | ||
| 2519 | + ..Default::default() | ||
| 2520 | + }, | ||
| 2515 | ..Default::default() | 2521 | ..Default::default() |
| 2516 | }; | 2522 | }; |
| 2517 | check_ops_with_options(options, ops); | 2523 | check_ops_with_options(options, ops); |
| @@ -2572,7 +2578,10 @@ fn interactive_move_onto_first_empty_workspace() { | |||
| 2572 | Op::InteractiveMoveEnd { window: 1 }, | 2578 | Op::InteractiveMoveEnd { window: 1 }, |
| 2573 | ]; | 2579 | ]; |
| 2574 | let options = Options { | 2580 | let options = Options { |
| 2575 | - empty_workspace_above_first: true, | 2581 | + layout: niri_config::Layout { |
| 2582 | + empty_workspace_above_first: true, | ||
| 2583 | + ..Default::default() | ||
| 2584 | + }, | ||
| 2576 | ..Default::default() | 2585 | ..Default::default() |
| 2577 | }; | 2586 | }; |
| 2578 | check_ops_with_options(options, ops); | 2587 | check_ops_with_options(options, ops); |
| @@ -2653,7 +2662,10 @@ fn named_workspace_to_output_ewaf() { | |||
| 2653 | Op::AddOutput(2), | 2662 | Op::AddOutput(2), |
| 2654 | ]; | 2663 | ]; |
| 2655 | let options = Options { | 2664 | let options = Options { |
| 2656 | - empty_workspace_above_first: true, | 2665 | + layout: niri_config::Layout { |
| 2666 | + empty_workspace_above_first: true, | ||
| 2667 | + ..Default::default() | ||
| 2668 | + }, | ||
| 2657 | ..Default::default() | 2669 | ..Default::default() |
| 2658 | }; | 2670 | }; |
| 2659 | check_ops_with_options(options, ops); | 2671 | check_ops_with_options(options, ops); |
| @@ -2672,7 +2684,10 @@ fn move_window_to_empty_workspace_above_first() { | |||
| 2672 | Op::MoveWorkspaceDown, | 2684 | Op::MoveWorkspaceDown, |
| 2673 | ]; | 2685 | ]; |
| 2674 | let options = Options { | 2686 | let options = Options { |
| 2675 | - empty_workspace_above_first: true, | 2687 | + layout: niri_config::Layout { |
| 2688 | + empty_workspace_above_first: true, | ||
| 2689 | + ..Default::default() | ||
| 2690 | + }, | ||
| 2676 | ..Default::default() | 2691 | ..Default::default() |
| 2677 | }; | 2692 | }; |
| 2678 | check_ops_with_options(options, ops); | 2693 | check_ops_with_options(options, ops); |
| @@ -2689,7 +2704,10 @@ fn move_window_to_different_output() { | |||
| 2689 | Op::MoveWorkspaceToOutput(2), | 2704 | Op::MoveWorkspaceToOutput(2), |
| 2690 | ]; | 2705 | ]; |
| 2691 | let options = Options { | 2706 | let options = Options { |
| 2692 | - empty_workspace_above_first: true, | 2707 | + layout: niri_config::Layout { |
| 2708 | + empty_workspace_above_first: true, | ||
| 2709 | + ..Default::default() | ||
| 2710 | + }, | ||
| 2693 | ..Default::default() | 2711 | ..Default::default() |
| 2694 | }; | 2712 | }; |
| 2695 | check_ops_with_options(options, ops); | 2713 | check_ops_with_options(options, ops); |
| @@ -2705,7 +2723,10 @@ fn close_window_empty_ws_above_first() { | |||
| 2705 | Op::CloseWindow(1), | 2723 | Op::CloseWindow(1), |
| 2706 | ]; | 2724 | ]; |
| 2707 | let options = Options { | 2725 | let options = Options { |
| 2708 | - empty_workspace_above_first: true, | 2726 | + layout: niri_config::Layout { |
| 2727 | + empty_workspace_above_first: true, | ||
| 2728 | + ..Default::default() | ||
| 2729 | + }, | ||
| 2709 | ..Default::default() | 2730 | ..Default::default() |
| 2710 | }; | 2731 | }; |
| 2711 | check_ops_with_options(options, ops); | 2732 | check_ops_with_options(options, ops); |
| @@ -2722,7 +2743,10 @@ fn add_and_remove_output() { | |||
| 2722 | Op::RemoveOutput(2), | 2743 | Op::RemoveOutput(2), |
| 2723 | ]; | 2744 | ]; |
| 2724 | let options = Options { | 2745 | let options = Options { |
| 2725 | - empty_workspace_above_first: true, | 2746 | + layout: niri_config::Layout { |
| 2747 | + empty_workspace_above_first: true, | ||
| 2748 | + ..Default::default() | ||
| 2749 | + }, | ||
| 2726 | ..Default::default() | 2750 | ..Default::default() |
| 2727 | }; | 2751 | }; |
| 2728 | check_ops_with_options(options, ops); | 2752 | check_ops_with_options(options, ops); |
| @@ -2739,7 +2763,10 @@ fn switch_ewaf_on() { | |||
| 2739 | 2763 | ||
| 2740 | let mut layout = check_ops(ops); | 2764 | let mut layout = check_ops(ops); |
| 2741 | layout.update_options(Options { | 2765 | layout.update_options(Options { |
| 2742 | - empty_workspace_above_first: true, | 2766 | + layout: niri_config::Layout { |
| 2767 | + empty_workspace_above_first: true, | ||
| 2768 | + ..Default::default() | ||
| 2769 | + }, | ||
| 2743 | ..Default::default() | 2770 | ..Default::default() |
| 2744 | }); | 2771 | }); |
| 2745 | layout.verify_invariants(); | 2772 | layout.verify_invariants(); |
| @@ -2755,7 +2782,10 @@ fn switch_ewaf_off() { | |||
| 2755 | ]; | 2782 | ]; |
| 2756 | 2783 | ||
| 2757 | let options = Options { | 2784 | let options = Options { |
| 2758 | - empty_workspace_above_first: true, | 2785 | + layout: niri_config::Layout { |
| 2786 | + empty_workspace_above_first: true, | ||
| 2787 | + ..Default::default() | ||
| 2788 | + }, | ||
| 2759 | ..Default::default() | 2789 | ..Default::default() |
| 2760 | }; | 2790 | }; |
| 2761 | let mut layout = check_ops_with_options(options, ops); | 2791 | let mut layout = check_ops_with_options(options, ops); |
| @@ -3074,7 +3104,10 @@ fn set_first_workspace_name_ewaf() { | |||
| 3074 | ]; | 3104 | ]; |
| 3075 | 3105 | ||
| 3076 | let options = Options { | 3106 | let options = Options { |
| 3077 | - empty_workspace_above_first: true, | 3107 | + layout: niri_config::Layout { |
| 3108 | + empty_workspace_above_first: true, | ||
| 3109 | + ..Default::default() | ||
| 3110 | + }, | ||
| 3078 | ..Default::default() | 3111 | ..Default::default() |
| 3079 | }; | 3112 | }; |
| 3080 | check_ops_with_options(options, ops); | 3113 | check_ops_with_options(options, ops); |
| @@ -3165,7 +3198,10 @@ fn preset_column_width_fixed_correct_with_border() { | |||
| 3165 | ]; | 3198 | ]; |
| 3166 | 3199 | ||
| 3167 | let options = Options { | 3200 | let options = Options { |
| 3168 | - preset_column_widths: vec![PresetSize::Fixed(500)], | 3201 | + layout: niri_config::Layout { |
| 3202 | + preset_column_widths: vec![PresetSize::Fixed(500)], | ||
| 3203 | + ..Default::default() | ||
| 3204 | + }, | ||
| 3169 | ..Default::default() | 3205 | ..Default::default() |
| 3170 | }; | 3206 | }; |
| 3171 | let mut layout = check_ops_with_options(options, ops); | 3207 | let mut layout = check_ops_with_options(options, ops); |
| @@ -3175,10 +3211,13 @@ fn preset_column_width_fixed_correct_with_border() { | |||
| 3175 | 3211 | ||
| 3176 | // Add border. | 3212 | // Add border. |
| 3177 | let options = Options { | 3213 | let options = Options { |
| 3178 | - preset_column_widths: vec![PresetSize::Fixed(500)], | 3214 | + layout: niri_config::Layout { |
| 3179 | - border: niri_config::Border { | 3215 | + preset_column_widths: vec![PresetSize::Fixed(500)], |
| 3180 | - off: false, | 3216 | + border: niri_config::Border { |
| 3181 | - width: 5., | 3217 | + off: false, |
| 3218 | + width: 5., | ||
| 3219 | + ..Default::default() | ||
| 3220 | + }, | ||
| 3182 | ..Default::default() | 3221 | ..Default::default() |
| 3183 | }, | 3222 | }, |
| 3184 | ..Default::default() | 3223 | ..Default::default() |
| @@ -3211,7 +3250,10 @@ fn preset_column_width_reset_after_set_width() { | |||
| 3211 | ]; | 3250 | ]; |
| 3212 | 3251 | ||
| 3213 | let options = Options { | 3252 | let options = Options { |
| 3214 | - preset_column_widths: vec![PresetSize::Fixed(500), PresetSize::Fixed(1000)], | 3253 | + layout: niri_config::Layout { |
| 3254 | + preset_column_widths: vec![PresetSize::Fixed(500), PresetSize::Fixed(1000)], | ||
| 3255 | + ..Default::default() | ||
| 3256 | + }, | ||
| 3215 | ..Default::default() | 3257 | ..Default::default() |
| 3216 | }; | 3258 | }; |
| 3217 | let layout = check_ops_with_options(options, ops); | 3259 | let layout = check_ops_with_options(options, ops); |
| @@ -3469,7 +3511,7 @@ prop_compose! { | |||
| 3469 | } | 3511 | } |
| 3470 | 3512 | ||
| 3471 | prop_compose! { | 3513 | prop_compose! { |
| 3472 | - fn arbitrary_options()( | 3514 | + fn arbitrary_layout_config()( |
| 3473 | gaps in arbitrary_spacing(), | 3515 | gaps in arbitrary_spacing(), |
| 3474 | struts in arbitrary_struts(), | 3516 | struts in arbitrary_struts(), |
| 3475 | focus_ring in arbitrary_focus_ring(), | 3517 | focus_ring in arbitrary_focus_ring(), |
| @@ -3479,8 +3521,8 @@ prop_compose! { | |||
| 3479 | center_focused_column in arbitrary_center_focused_column(), | 3521 | center_focused_column in arbitrary_center_focused_column(), |
| 3480 | always_center_single_column in any::<bool>(), | 3522 | always_center_single_column in any::<bool>(), |
| 3481 | empty_workspace_above_first in any::<bool>(), | 3523 | empty_workspace_above_first in any::<bool>(), |
| 3482 | - ) -> Options { | 3524 | + ) -> niri_config::Layout { |
| 3483 | - Options { | 3525 | + niri_config::Layout { |
| 3484 | gaps, | 3526 | gaps, |
| 3485 | struts, | 3527 | struts, |
| 3486 | center_focused_column, | 3528 | center_focused_column, |
| @@ -3495,6 +3537,17 @@ prop_compose! { | |||
| 3495 | } | 3537 | } |
| 3496 | } | 3538 | } |
| 3497 | 3539 | ||
| 3540 | +prop_compose! { | ||
| 3541 | + fn arbitrary_options()( | ||
| 3542 | + layout in arbitrary_layout_config() | ||
| 3543 | + ) -> Options { | ||
| 3544 | + Options { | ||
| 3545 | + layout, | ||
| 3546 | + ..Default::default() | ||
| 3547 | + } | ||
| 3548 | + } | ||
| 3549 | +} | ||
| 3550 | + | ||
| 3498 | proptest! { | 3551 | proptest! { |
| 3499 | #![proptest_config(ProptestConfig { | 3552 | #![proptest_config(ProptestConfig { |
| 3500 | cases: if std::env::var_os("RUN_SLOW_TESTS").is_none() { | 3553 | cases: if std::env::var_os("RUN_SLOW_TESTS").is_none() { |
src/layout/tests/animations.rsmodified+4 -1
| @@ -29,7 +29,10 @@ fn make_options() -> Options { | |||
| 29 | }); | 29 | }); |
| 30 | 30 | ||
| 31 | let mut options = Options { | 31 | let mut options = Options { |
| 32 | - gaps: 0.0, | 32 | + layout: niri_config::Layout { |
| 33 | + gaps: 0.0, | ||
| 34 | + ..Default::default() | ||
| 35 | + }, | ||
| 33 | ..Options::default() | 36 | ..Options::default() |
| 34 | }; | 37 | }; |
| 35 | options.animations.window_resize.anim.kind = LINEAR; | 38 | options.animations.window_resize.anim.kind = LINEAR; |
src/layout/tests/fullscreen.rsmodified+6 -3
| @@ -188,9 +188,12 @@ fn unfullscreen_with_large_border() { | |||
| 188 | ]; | 188 | ]; |
| 189 | 189 | ||
| 190 | let options = Options { | 190 | let options = Options { |
| 191 | - border: niri_config::Border { | 191 | + layout: niri_config::Layout { |
| 192 | - off: false, | 192 | + border: niri_config::Border { |
| 193 | - width: 10000., | 193 | + off: false, |
| 194 | + width: 10000., | ||
| 195 | + ..Default::default() | ||
| 196 | + }, | ||
| 194 | ..Default::default() | 197 | ..Default::default() |
| 195 | }, | 198 | }, |
| 196 | ..Default::default() | 199 | ..Default::default() |
src/layout/tile.rsmodified+19 -11
| @@ -175,9 +175,9 @@ impl<W: LayoutElement> Tile<W> { | |||
| 175 | options: Rc<Options>, | 175 | options: Rc<Options>, |
| 176 | ) -> Self { | 176 | ) -> Self { |
| 177 | let rules = window.rules(); | 177 | let rules = window.rules(); |
| 178 | - let border_config = options.border.merged_with(&rules.border); | 178 | + let border_config = options.layout.border.merged_with(&rules.border); |
| 179 | - let focus_ring_config = options.focus_ring.merged_with(&rules.focus_ring); | 179 | + let focus_ring_config = options.layout.focus_ring.merged_with(&rules.focus_ring); |
| 180 | - let shadow_config = options.shadow.merged_with(&rules.shadow); | 180 | + let shadow_config = options.layout.shadow.merged_with(&rules.shadow); |
| 181 | let is_fullscreen = window.is_fullscreen(); | 181 | let is_fullscreen = window.is_fullscreen(); |
| 182 | 182 | ||
| 183 | Self { | 183 | Self { |
| @@ -214,10 +214,10 @@ impl<W: LayoutElement> Tile<W> { | |||
| 214 | options: Rc<Options>, | 214 | options: Rc<Options>, |
| 215 | ) { | 215 | ) { |
| 216 | // If preset widths or heights changed, clear our stored preset index. | 216 | // If preset widths or heights changed, clear our stored preset index. |
| 217 | - if self.options.preset_column_widths != options.preset_column_widths { | 217 | + if self.options.layout.preset_column_widths != options.layout.preset_column_widths { |
| 218 | self.floating_preset_width_idx = None; | 218 | self.floating_preset_width_idx = None; |
| 219 | } | 219 | } |
| 220 | - if self.options.preset_window_heights != options.preset_window_heights { | 220 | + if self.options.layout.preset_window_heights != options.layout.preset_window_heights { |
| 221 | self.floating_preset_height_idx = None; | 221 | self.floating_preset_height_idx = None; |
| 222 | } | 222 | } |
| 223 | 223 | ||
| @@ -227,13 +227,17 @@ impl<W: LayoutElement> Tile<W> { | |||
| 227 | 227 | ||
| 228 | let rules = self.window.rules(); | 228 | let rules = self.window.rules(); |
| 229 | 229 | ||
| 230 | - let border_config = self.options.border.merged_with(&rules.border); | 230 | + let border_config = self.options.layout.border.merged_with(&rules.border); |
| 231 | self.border.update_config(border_config.into()); | 231 | self.border.update_config(border_config.into()); |
| 232 | 232 | ||
| 233 | - let focus_ring_config = self.options.focus_ring.merged_with(&rules.focus_ring); | 233 | + let focus_ring_config = self |
| 234 | + .options | ||
| 235 | + .layout | ||
| 236 | + .focus_ring | ||
| 237 | + .merged_with(&rules.focus_ring); | ||
| 234 | self.focus_ring.update_config(focus_ring_config); | 238 | self.focus_ring.update_config(focus_ring_config); |
| 235 | 239 | ||
| 236 | - let shadow_config = self.options.shadow.merged_with(&rules.shadow); | 240 | + let shadow_config = self.options.layout.shadow.merged_with(&rules.shadow); |
| 237 | self.shadow.update_config(shadow_config); | 241 | self.shadow.update_config(shadow_config); |
| 238 | } | 242 | } |
| 239 | 243 | ||
| @@ -332,12 +336,16 @@ impl<W: LayoutElement> Tile<W> { | |||
| 332 | } | 336 | } |
| 333 | 337 | ||
| 334 | let rules = self.window.rules(); | 338 | let rules = self.window.rules(); |
| 335 | - let border_config = self.options.border.merged_with(&rules.border); | 339 | + let border_config = self.options.layout.border.merged_with(&rules.border); |
| 336 | self.border.update_config(border_config.into()); | 340 | self.border.update_config(border_config.into()); |
| 337 | - let focus_ring_config = self.options.focus_ring.merged_with(&rules.focus_ring); | 341 | + let focus_ring_config = self |
| 342 | + .options | ||
| 343 | + .layout | ||
| 344 | + .focus_ring | ||
| 345 | + .merged_with(&rules.focus_ring); | ||
| 338 | self.focus_ring.update_config(focus_ring_config); | 346 | self.focus_ring.update_config(focus_ring_config); |
| 339 | 347 | ||
| 340 | - let shadow_config = self.options.shadow.merged_with(&rules.shadow); | 348 | + let shadow_config = self.options.layout.shadow.merged_with(&rules.shadow); |
| 341 | self.shadow.update_config(shadow_config); | 349 | self.shadow.update_config(shadow_config); |
| 342 | 350 | ||
| 343 | let window_size = self.window_size(); | 351 | let window_size = self.window_size(); |
src/layout/workspace.rsmodified+7 -6
| @@ -754,7 +754,7 @@ impl<W: LayoutElement> Workspace<W> { | |||
| 754 | Some(Some(width)) => Some(width), | 754 | Some(Some(width)) => Some(width), |
| 755 | Some(None) => None, | 755 | Some(None) => None, |
| 756 | None if is_floating => None, | 756 | None if is_floating => None, |
| 757 | - None => self.options.default_column_width, | 757 | + None => self.options.layout.default_column_width, |
| 758 | } | 758 | } |
| 759 | } | 759 | } |
| 760 | 760 | ||
| @@ -1272,11 +1272,12 @@ impl<W: LayoutElement> Workspace<W> { | |||
| 1272 | // Come up with a default floating position close to the tile position. | 1272 | // Come up with a default floating position close to the tile position. |
| 1273 | let stored_or_default = self.floating.stored_or_default_tile_pos(&removed.tile); | 1273 | let stored_or_default = self.floating.stored_or_default_tile_pos(&removed.tile); |
| 1274 | if stored_or_default.is_none() { | 1274 | if stored_or_default.is_none() { |
| 1275 | - let offset = if self.options.center_focused_column == CenterFocusedColumn::Always { | 1275 | + let offset = |
| 1276 | - Point::from((0., 0.)) | 1276 | + if self.options.layout.center_focused_column == CenterFocusedColumn::Always { |
| 1277 | - } else { | 1277 | + Point::from((0., 0.)) |
| 1278 | - Point::from((50., 50.)) | 1278 | + } else { |
| 1279 | - }; | 1279 | + Point::from((50., 50.)) |
| 1280 | + }; | ||
| 1280 | let pos = render_pos + offset; | 1281 | let pos = render_pos + offset; |
| 1281 | let size = removed.tile.tile_size(); | 1282 | let size = removed.tile.tile_size(); |
| 1282 | let pos = self.floating.clamp_within_working_area(pos, size); | 1283 | let pos = self.floating.clamp_within_working_area(pos, size); |