forge
Explore
Log in

Don't you dare go Hollow

layout: Store Layout directly in Options

Browse files at this commit

4c524b47196badd281bc159bef3137cf16f963e5Ivan MolodetskikhParent: 1fa9dd3
niri-visual-tests/src/cases/layout.rsmodified+15 -12
@@ -52,20 +52,23 @@ impl Layout {
5252 });
5353
5454 let options = Options {
55- focus_ring: niri_config::FocusRing {
56- off: true,
55+ layout: niri_config::Layout {
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+ },
5770 ..Default::default()
5871 },
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- },
6972 ..Default::default()
7073 };
7174 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 {
5858 let Args { size, clock } = args;
5959
6060 let options = Options {
61- focus_ring: niri_config::FocusRing {
62- off: true,
63- ..Default::default()
64- },
65- border: niri_config::Border {
66- off: false,
67- width: 32.,
68- active_color: Color::from_rgba8_unpremul(255, 163, 72, 255),
61+ layout: niri_config::Layout {
62+ focus_ring: niri_config::FocusRing {
63+ off: true,
64+ ..Default::default()
65+ },
66+ border: niri_config::Border {
67+ off: false,
68+ width: 32.,
69+ active_color: Color::from_rgba8_unpremul(255, 163, 72, 255),
70+ ..Default::default()
71+ },
6972 ..Default::default()
7073 },
7174 ..Default::default()
src/layout/floating.rsmodified+11 -9
@@ -340,7 +340,7 @@ impl<W: LayoutElement> FloatingSpace<W> {
340340 }
341341
342342 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);
344344 compute_toplevel_bounds(border_config, self.working_area.size)
345345 }
346346
@@ -633,7 +633,7 @@ impl<W: LayoutElement> FloatingSpace<W> {
633633
634634 let available_size = self.working_area.size.w;
635635
636- let len = self.options.preset_column_widths.len();
636+ let len = self.options.layout.preset_column_widths.len();
637637 let tile = &mut self.tiles[idx];
638638 let preset_idx = if let Some(idx) = tile.floating_preset_width_idx {
639639 (idx + if forwards { 1 } else { len - 1 }) % len
@@ -643,6 +643,7 @@ impl<W: LayoutElement> FloatingSpace<W> {
643643
644644 let mut it = self
645645 .options
646+ .layout
646647 .preset_column_widths
647648 .iter()
648649 .map(|preset| resolve_preset_size(*preset, available_size));
@@ -668,7 +669,7 @@ impl<W: LayoutElement> FloatingSpace<W> {
668669 }
669670 };
670671
671- let preset = self.options.preset_column_widths[preset_idx];
672+ let preset = self.options.layout.preset_column_widths[preset_idx];
672673 self.set_window_width(Some(&id), SizeChange::from(preset), true);
673674
674675 self.tiles[idx].floating_preset_width_idx = Some(preset_idx);
@@ -693,7 +694,7 @@ impl<W: LayoutElement> FloatingSpace<W> {
693694
694695 let available_size = self.working_area.size.h;
695696
696- let len = self.options.preset_window_heights.len();
697+ let len = self.options.layout.preset_window_heights.len();
697698 let tile = &mut self.tiles[idx];
698699 let preset_idx = if let Some(idx) = tile.floating_preset_height_idx {
699700 (idx + if forwards { 1 } else { len - 1 }) % len
@@ -703,6 +704,7 @@ impl<W: LayoutElement> FloatingSpace<W> {
703704
704705 let mut it = self
705706 .options
707+ .layout
706708 .preset_window_heights
707709 .iter()
708710 .map(|preset| resolve_preset_size(*preset, available_size));
@@ -728,7 +730,7 @@ impl<W: LayoutElement> FloatingSpace<W> {
728730 }
729731 };
730732
731- let preset = self.options.preset_window_heights[preset_idx];
733+ let preset = self.options.layout.preset_window_heights[preset_idx];
732734 self.set_window_height(Some(&id), SizeChange::from(preset), true);
733735
734736 let tile = &mut self.tiles[idx];
@@ -1156,7 +1158,7 @@ impl<W: LayoutElement> FloatingSpace<W> {
11561158 .map(|resize| resize.data);
11571159 win.set_interactive_resize(resize_data);
11581160
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);
11601162 let bounds = compute_toplevel_bounds(border_config, self.working_area.size);
11611163 win.set_bounds(bounds);
11621164
@@ -1220,7 +1222,7 @@ impl<W: LayoutElement> FloatingSpace<W> {
12201222 height: Option<PresetSize>,
12211223 rules: &ResolvedWindowRules,
12221224 ) -> Size<i32, Logical> {
1223- let border = self.options.border.merged_with(&rules.border);
1225+ let border = self.options.layout.border.merged_with(&rules.border);
12241226
12251227 let resolve = |size: Option<PresetSize>, working_area_size: f64| {
12261228 if let Some(size) = size {
@@ -1317,10 +1319,10 @@ impl<W: LayoutElement> FloatingSpace<W> {
13171319 tile.verify_invariants();
13181320
13191321 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());
13211323 }
13221324 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());
13241326 }
13251327
13261328 assert!(
src/layout/mod.rsmodified+25 -105
@@ -40,8 +40,7 @@ use std::time::Duration;
4040 use monitor::{InsertHint, InsertPosition, InsertWorkspace, MonitorAddWindowTarget};
4141 use niri_config::utils::MergeWith as _;
4242 use niri_config::{
43- CenterFocusedColumn, Config, CornerRadius, PresetSize, Struts, Workspace as WorkspaceConfig,
44- WorkspaceReference,
43+ Config, CornerRadius, PresetSize, Workspace as WorkspaceConfig, WorkspaceReference,
4544 };
4645 use niri_ipc::{ColumnDisplay, PositionChange, SizeChange, WindowLayout};
4746 use scrolling::{Column, ColumnWidth};
@@ -334,27 +333,9 @@ enum MonitorSet<W: LayoutElement> {
334333 },
335334 }
336335
337-#[derive(Debug, Clone, PartialEq)]
336+#[derive(Debug, Default, Clone, PartialEq)]
338337 pub struct Options {
339- /// Padding around windows in logical pixels.
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>,
338+ pub layout: niri_config::Layout,
358339 pub animations: niri_config::Animations,
359340 pub gestures: niri_config::Gestures,
360341 pub overview: niri_config::Overview,
@@ -364,41 +345,6 @@ pub struct Options {
364345 pub deactivate_unfocused_windows: bool,
365346 }
366347
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-
402348 #[allow(clippy::large_enum_variant)]
403349 #[derive(Debug)]
404350 enum InteractiveMoveState<W: LayoutElement> {
@@ -620,49 +566,23 @@ impl HitType {
620566
621567 impl Options {
622568 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-
636569 Self {
637- gaps: layout.gaps,
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,
570+ layout: config.resolve_layout(),
650571 animations: config.animations.clone(),
651572 gestures: config.gestures,
652573 overview: config.overview,
653574 disable_resize_throttling: config.debug.disable_resize_throttling,
654575 disable_transactions: config.debug.disable_transactions,
655576 deactivate_unfocused_windows: config.debug.deactivate_unfocused_windows,
656- preset_window_heights,
657577 }
658578 }
659579
660580 fn adjusted_for_scale(mut self, scale: f64) -> Self {
661581 let round = |logical: f64| round_logical_in_physical_max1(scale, logical);
662582
663- self.gaps = round(self.gaps);
664- self.focus_ring.width = round(self.focus_ring.width);
665- self.border.width = round(self.border.width);
583+ self.layout.gaps = round(self.layout.gaps);
584+ self.layout.focus_ring.width = round(self.layout.focus_ring.width);
585+ self.layout.border.width = round(self.layout.border.width);
666586
667587 self
668588 }
@@ -775,7 +695,7 @@ impl<W: LayoutElement> Layout<W> {
775695 // workspaces set up across multiple monitors. Without this check, the
776696 // first monitor to connect can end up with the first empty workspace
777697 // focused instead of the first named workspace.
778- && !(self.options.empty_workspace_above_first
698+ && !(self.options.layout.empty_workspace_above_first
779699 && primary.active_workspace_idx == 1)
780700 {
781701 primary.active_workspace_idx =
@@ -790,7 +710,7 @@ impl<W: LayoutElement> Layout<W> {
790710 // takes care of this.
791711
792712 if stopped_primary_ws_switch
793- || (primary.options.empty_workspace_above_first
713+ || (primary.options.layout.empty_workspace_above_first
794714 && primary.workspaces.len() == 2)
795715 {
796716 primary.clean_up_workspaces();
@@ -810,7 +730,7 @@ impl<W: LayoutElement> Layout<W> {
810730 self.options.clone(),
811731 ));
812732
813- if self.options.empty_workspace_above_first && workspaces.len() > 1 {
733+ if self.options.layout.empty_workspace_above_first && workspaces.len() > 1 {
814734 workspaces.insert(
815735 0,
816736 Workspace::new(output.clone(), self.clock.clone(), self.options.clone()),
@@ -844,7 +764,7 @@ impl<W: LayoutElement> Layout<W> {
844764 ));
845765
846766 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 {
848768 workspaces.insert(
849769 0,
850770 Workspace::new(output.clone(), self.clock.clone(), self.options.clone()),
@@ -944,7 +864,7 @@ impl<W: LayoutElement> Layout<W> {
944864
945865 // If empty_workspace_above_first is set and the first workspace is now no
946866 // 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
948868 && primary.workspaces[0].has_windows_or_name()
949869 {
950870 primary.add_workspace_top();
@@ -1242,7 +1162,7 @@ impl<W: LayoutElement> Layout<W> {
12421162
12431163 // Special case handling when empty_workspace_above_first is set and all
12441164 // workspaces are empty.
1245- if mon.options.empty_workspace_above_first
1165+ if mon.options.layout.empty_workspace_above_first
12461166 && mon.workspaces.len() == 2
12471167 && mon.workspace_switch.is_none()
12481168 {
@@ -2637,7 +2557,7 @@ impl<W: LayoutElement> Layout<W> {
26372557 !monitor.workspaces.last().unwrap().has_windows(),
26382558 "monitor must have an empty workspace in the end"
26392559 );
2640- if monitor.options.empty_workspace_above_first {
2560+ if monitor.options.layout.empty_workspace_above_first {
26412561 assert!(
26422562 !monitor.workspaces.first().unwrap().has_windows(),
26432563 "first workspace must be empty when empty_workspace_above_first is set"
@@ -2648,14 +2568,14 @@ impl<W: LayoutElement> Layout<W> {
26482568 monitor.workspaces.last().unwrap().name.is_none(),
26492569 "monitor must have an unnamed workspace in the end"
26502570 );
2651- if monitor.options.empty_workspace_above_first {
2571+ if monitor.options.layout.empty_workspace_above_first {
26522572 assert!(
26532573 monitor.workspaces.first().unwrap().name.is_none(),
26542574 "first workspace must be unnamed when empty_workspace_above_first is set"
26552575 )
26562576 }
26572577
2658- if monitor.options.empty_workspace_above_first {
2578+ if monitor.options.layout.empty_workspace_above_first {
26592579 assert!(
26602580 monitor.workspaces.len() != 2,
26612581 "if empty_workspace_above_first is set there must be just 1 or 3+ workspaces"
@@ -2665,7 +2585,7 @@ impl<W: LayoutElement> Layout<W> {
26652585 // If there's no workspace switch in progress, there can't be any non-last non-active
26662586 // empty workspaces. If empty_workspace_above_first is set then the first workspace
26672587 // 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 {
26692589 1
26702590 } else {
26712591 0
@@ -3107,7 +3027,7 @@ impl<W: LayoutElement> Layout<W> {
31073027 let mon = &mut monitors[mon_idx];
31083028
31093029 let mut insert_idx = 0;
3110- if mon.options.empty_workspace_above_first {
3030+ if mon.options.layout.empty_workspace_above_first {
31113031 // need to insert new empty workspace on top
31123032 mon.add_workspace_top();
31133033 insert_idx += 1;
@@ -3622,7 +3542,7 @@ impl<W: LayoutElement> Layout<W> {
36223542 // Insert a new empty workspace.
36233543 current.add_workspace_bottom();
36243544 }
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 {
36263546 current.add_workspace_top();
36273547 }
36283548
@@ -3642,7 +3562,7 @@ impl<W: LayoutElement> Layout<W> {
36423562
36433563 target.previous_workspace_id = Some(target.workspaces[target.active_workspace_idx].id());
36443564
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 {
36463566 // Insert a new empty workspace on top to prepare for insertion of new workspace.
36473567 target.add_workspace_top();
36483568 }
@@ -3711,7 +3631,7 @@ impl<W: LayoutElement> Layout<W> {
37113631
37123632 let mut ws = current.workspaces.remove(old_idx);
37133633
3714- if current.options.empty_workspace_above_first && old_idx == 0 {
3634+ if current.options.layout.empty_workspace_above_first && old_idx == 0 {
37153635 current.add_workspace_top();
37163636 }
37173637
@@ -3728,7 +3648,7 @@ impl<W: LayoutElement> Layout<W> {
37283648
37293649 target.previous_workspace_id = Some(target.workspaces[target.active_workspace_idx].id());
37303650
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 {
37323652 // Insert a new empty workspace on top to prepare for insertion of new workspace.
37333653 target.add_workspace_top();
37343654 }
@@ -4480,7 +4400,7 @@ impl<W: LayoutElement> Layout<W> {
44804400 .position(|ws| ws.id() == ws_id)
44814401 .unwrap(),
44824402 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 {
44844404 // Reuse the top empty workspace.
44854405 0
44864406 } else if mon.workspaces.len() - 1 <= ws_idx {
@@ -4813,7 +4733,7 @@ impl<W: LayoutElement> Layout<W> {
48134733 } = &mut self.monitor_set
48144734 {
48154735 let monitor = &mut monitors[*active_monitor_idx];
4816- if self.options.empty_workspace_above_first
4736+ if self.options.layout.empty_workspace_above_first
48174737 && monitor
48184738 .workspaces
48194739 .first()
@@ -5242,7 +5162,7 @@ impl<W: LayoutElement> Layout<W> {
52425162
52435163 // Add border width since ColumnWidth includes borders.
52445164 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);
52465166 if !border.off {
52475167 fixed += border.width * 2.;
52485168 }
src/layout/monitor.rsmodified+16 -14
@@ -293,7 +293,7 @@ impl<W: LayoutElement> Monitor<W> {
293293 active_workspace_idx: 0,
294294 previous_workspace_id: None,
295295 insert_hint: None,
296- insert_hint_element: InsertHintElement::new(options.insert_hint),
296+ insert_hint_element: InsertHintElement::new(options.layout.insert_hint),
297297 insert_hint_render_loc: None,
298298 overview_open: false,
299299 overview_progress: None,
@@ -463,7 +463,7 @@ impl<W: LayoutElement> Monitor<W> {
463463 if workspace_idx == self.workspaces.len() - 1 {
464464 self.add_workspace_bottom();
465465 }
466- if self.options.empty_workspace_above_first && workspace_idx == 0 {
466+ if self.options.layout.empty_workspace_above_first && workspace_idx == 0 {
467467 self.add_workspace_top();
468468 workspace_idx += 1;
469469 }
@@ -522,7 +522,7 @@ impl<W: LayoutElement> Monitor<W> {
522522 self.add_workspace_bottom();
523523 }
524524
525- if self.options.empty_workspace_above_first && workspace_idx == 0 {
525+ if self.options.layout.empty_workspace_above_first && workspace_idx == 0 {
526526 self.add_workspace_top();
527527 workspace_idx += 1;
528528 }
@@ -562,7 +562,7 @@ impl<W: LayoutElement> Monitor<W> {
562562 pub fn clean_up_workspaces(&mut self) {
563563 assert!(self.workspace_switch.is_none());
564564
565- let range_start = if self.options.empty_workspace_above_first {
565+ let range_start = if self.options.layout.empty_workspace_above_first {
566566 1
567567 } else {
568568 0
@@ -582,7 +582,7 @@ impl<W: LayoutElement> Monitor<W> {
582582
583583 // Special case handling when empty_workspace_above_first is set and all workspaces
584584 // 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 {
586586 assert!(!self.workspaces[0].has_windows_or_name());
587587 assert!(!self.workspaces[1].has_windows_or_name());
588588 self.workspaces.remove(1);
@@ -1023,10 +1023,11 @@ impl<W: LayoutElement> Monitor<W> {
10231023 }
10241024
10251025 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
10271028 && self.workspaces.len() > 1
10281029 {
1029- if options.empty_workspace_above_first {
1030+ if options.layout.empty_workspace_above_first {
10301031 self.add_workspace_top();
10311032 } else if self.workspace_switch.is_none() && self.active_workspace_idx != 0 {
10321033 self.workspaces.remove(0);
@@ -1038,7 +1039,8 @@ impl<W: LayoutElement> Monitor<W> {
10381039 ws.update_config(options.clone());
10391040 }
10401041
1041- self.insert_hint_element.update_config(options.insert_hint);
1042+ self.insert_hint_element
1043+ .update_config(options.layout.insert_hint);
10421044
10431045 self.options = options;
10441046 }
@@ -1074,7 +1076,7 @@ impl<W: LayoutElement> Monitor<W> {
10741076 self.add_workspace_bottom();
10751077 }
10761078
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 {
10781080 self.add_workspace_top();
10791081 new_idx += 1;
10801082 }
@@ -1100,7 +1102,7 @@ impl<W: LayoutElement> Monitor<W> {
11001102 self.add_workspace_bottom();
11011103 }
11021104
1103- if self.options.empty_workspace_above_first && new_idx == 0 {
1105+ if self.options.layout.empty_workspace_above_first && new_idx == 0 {
11041106 self.add_workspace_top();
11051107 new_idx += 1;
11061108 }
@@ -1132,7 +1134,7 @@ impl<W: LayoutElement> Monitor<W> {
11321134 self.add_workspace_bottom();
11331135 }
11341136
1135- if self.options.empty_workspace_above_first && old_idx == 0 {
1137+ if self.options.layout.empty_workspace_above_first && old_idx == 0 {
11361138 self.add_workspace_top();
11371139 new_idx += 1;
11381140 }
@@ -1142,7 +1144,7 @@ impl<W: LayoutElement> Monitor<W> {
11421144 self.add_workspace_bottom();
11431145 }
11441146
1145- if self.options.empty_workspace_above_first && new_idx == 0 {
1147+ if self.options.layout.empty_workspace_above_first && new_idx == 0 {
11461148 self.add_workspace_top();
11471149 new_idx += 1;
11481150 }
@@ -1464,7 +1466,7 @@ impl<W: LayoutElement> Monitor<W> {
14641466 ) -> impl Iterator<Item = MonitorRenderElement<R>> {
14651467 let mut rv = None;
14661468
1467- if !self.options.insert_hint.off {
1469+ if !self.options.layout.insert_hint.off {
14681470 if let Some(render_loc) = self.insert_hint_render_loc {
14691471 if let InsertWorkspace::NewAt(_) = render_loc.workspace {
14701472 let iter = self
@@ -1525,7 +1527,7 @@ impl<W: LayoutElement> Monitor<W> {
15251527
15261528 // Draw the insert hint.
15271529 let mut insert_hint = None;
1528- if !self.options.insert_hint.off {
1530+ if !self.options.layout.insert_hint.off {
15291531 if let Some(render_loc) = self.insert_hint_render_loc {
15301532 if let InsertWorkspace::Existing(workspace_id) = render_loc.workspace {
15311533 insert_hint = Some((
src/layout/scrolling.rsmodified+78 -71
@@ -276,7 +276,7 @@ impl<W: LayoutElement> ScrollingSpace<W> {
276276 clock: Clock,
277277 options: Rc<Options>,
278278 ) -> 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);
280280
281281 Self {
282282 columns: Vec::new(),
@@ -303,7 +303,7 @@ impl<W: LayoutElement> ScrollingSpace<W> {
303303 scale: f64,
304304 options: Rc<Options>,
305305 ) {
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);
307307
308308 for (column, data) in zip(&mut self.columns, &mut self.data) {
309309 column.update_config(view_size, working_area, scale, options.clone());
@@ -444,14 +444,14 @@ impl<W: LayoutElement> ScrollingSpace<W> {
444444 }
445445
446446 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);
448448
449449 let display_mode = rules
450450 .default_column_display
451- .unwrap_or(self.options.default_column_display);
451+ .unwrap_or(self.options.layout.default_column_display);
452452 let will_tab = display_mode == ColumnDisplay::Tabbed;
453453 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)
455455 } else {
456456 Size::from((0., 0.))
457457 };
@@ -460,7 +460,7 @@ impl<W: LayoutElement> ScrollingSpace<W> {
460460 border_config,
461461 self.working_area.size,
462462 extra_size,
463- self.options.gaps,
463+ self.options.layout.gaps,
464464 )
465465 }
466466
@@ -470,14 +470,14 @@ impl<W: LayoutElement> ScrollingSpace<W> {
470470 height: Option<PresetSize>,
471471 rules: &ResolvedWindowRules,
472472 ) -> Size<i32, Logical> {
473- let border = self.options.border.merged_with(&rules.border);
473+ let border = self.options.layout.border.merged_with(&rules.border);
474474
475475 let display_mode = rules
476476 .default_column_display
477- .unwrap_or(self.options.default_column_display);
477+ .unwrap_or(self.options.layout.default_column_display);
478478 let will_tab = display_mode == ColumnDisplay::Tabbed;
479479 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)
481481 } else {
482482 Size::from((0., 0.))
483483 };
@@ -500,7 +500,7 @@ impl<W: LayoutElement> ScrollingSpace<W> {
500500 0
501501 };
502502
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.;
504504 if !border.off {
505505 full_height -= border.width * 2.;
506506 }
@@ -524,8 +524,8 @@ impl<W: LayoutElement> ScrollingSpace<W> {
524524 }
525525
526526 pub fn is_centering_focused_column(&self) -> bool {
527- self.options.center_focused_column == CenterFocusedColumn::Always
528- || (self.options.always_center_single_column && self.columns.len() <= 1)
527+ self.options.layout.center_focused_column == CenterFocusedColumn::Always
528+ || (self.options.layout.always_center_single_column && self.columns.len() <= 1)
529529 }
530530
531531 fn compute_new_view_offset_fit(
@@ -546,7 +546,7 @@ impl<W: LayoutElement> ScrollingSpace<W> {
546546 self.working_area.size.w,
547547 col_x,
548548 width,
549- self.options.gaps,
549+ self.options.layout.gaps,
550550 );
551551
552552 // Non-fullscreen windows are always offset at least by the working area position.
@@ -606,7 +606,7 @@ impl<W: LayoutElement> ScrollingSpace<W> {
606606 return self.compute_new_view_offset_for_column_centered(target_x, idx);
607607 }
608608
609- match self.options.center_focused_column {
609+ match self.options.layout.center_focused_column {
610610 CenterFocusedColumn::Always => {
611611 self.compute_new_view_offset_for_column_centered(target_x, idx)
612612 }
@@ -639,7 +639,7 @@ impl<W: LayoutElement> ScrollingSpace<W> {
639639 } else {
640640 // Source is right from target.
641641 source_col_x - target_col_x + source_col_width
642- } + self.options.gaps * 2.;
642+ } + self.options.layout.gaps * 2.;
643643
644644 // If it fits together, do a normal animation, otherwise center the new column.
645645 if total_width <= self.working_area.size.w {
@@ -783,8 +783,8 @@ impl<W: LayoutElement> ScrollingSpace<W> {
783783 let x = pos.x + self.view_pos();
784784
785785 // Aim for the center of the gap.
786- let x = x + self.options.gaps / 2.;
787- let y = pos.y + self.options.gaps / 2.;
786+ let x = x + self.options.layout.gaps / 2.;
787+ let y = pos.y + self.options.layout.gaps / 2.;
788788
789789 // Insert position is before the first column.
790790 if x < 0. {
@@ -2224,7 +2224,7 @@ impl<W: LayoutElement> ScrollingSpace<W> {
22242224 let mut leftmost_col_x = None;
22252225 let mut active_col_x = None;
22262226
2227- let gap = self.options.gaps;
2227+ let gap = self.options.layout.gaps;
22282228 let col_xs = self.column_xs(self.data.iter().copied());
22292229 for (idx, col_x) in col_xs.take(self.columns.len()).enumerate() {
22302230 if col_x < view_x + working_x + gap {
@@ -2274,7 +2274,7 @@ impl<W: LayoutElement> ScrollingSpace<W> {
22742274 // HACK: pass a self.data iterator in manually as a workaround for the lack of method partial
22752275 // borrowing. Note that this method's return value does not borrow the entire &Self!
22762276 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;
22782278 let mut x = 0.;
22792279
22802280 // Chain with a dummy value to be able to get one past all columns' X.
@@ -2408,25 +2408,29 @@ impl<W: LayoutElement> ScrollingSpace<W> {
24082408 let mut hint_area = match position {
24092409 InsertPosition::NewColumn(column_index) => {
24102410 if column_index == 0 || column_index == self.columns.len() {
2411- let size =
2412- Size::from((300., self.working_area.size.h - self.options.gaps * 2.));
2411+ let size = Size::from((
2412+ 300.,
2413+ self.working_area.size.h - self.options.layout.gaps * 2.,
2414+ ));
24132415 let mut loc = Point::from((
24142416 self.column_x(column_index),
2415- self.working_area.loc.y + self.options.gaps,
2417+ self.working_area.loc.y + self.options.layout.gaps,
24162418 ));
24172419 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;
24192421 }
24202422 Rectangle::new(loc, size)
24212423 } else if column_index > self.columns.len() {
24222424 error!("insert hint column index is out of range");
24232425 return None;
24242426 } else {
2425- let size =
2426- Size::from((300., self.working_area.size.h - self.options.gaps * 2.));
2427+ let size = Size::from((
2428+ 300.,
2429+ self.working_area.size.h - self.options.layout.gaps * 2.,
2430+ ));
24272431 let loc = Point::from((
2428- self.column_x(column_index) - size.w / 2. - self.options.gaps / 2.,
2429- self.working_area.loc.y + self.options.gaps,
2432+ self.column_x(column_index) - size.w / 2. - self.options.layout.gaps / 2.,
2433+ self.working_area.loc.y + self.options.layout.gaps,
24302434 ));
24312435 Rectangle::new(loc, size)
24322436 }
@@ -2462,9 +2466,9 @@ impl<W: LayoutElement> ScrollingSpace<W> {
24622466 if tile_index == 0 {
24632467 (150., top)
24642468 } else if tile_index == col.tiles.len() {
2465- (150., top - self.options.gaps - 150.)
2469+ (150., top - self.options.layout.gaps - 150.)
24662470 } else {
2467- (300., top - self.options.gaps / 2. - 150.)
2471+ (300., top - self.options.layout.gaps / 2. - 150.)
24682472 }
24692473 };
24702474
@@ -2716,7 +2720,7 @@ impl<W: LayoutElement> ScrollingSpace<W> {
27162720 let mut active_col_x = None;
27172721 let mut counted_non_active_column = false;
27182722
2719- let gap = self.options.gaps;
2723+ let gap = self.options.layout.gaps;
27202724 let col_xs = self.column_xs(self.data.iter().copied());
27212725 for (idx, col_x) in col_xs.take(self.columns.len()).enumerate() {
27222726 if col_x < view_x + working_x + gap {
@@ -3051,7 +3055,7 @@ impl<W: LayoutElement> ScrollingSpace<W> {
30513055 let (leftmost, rightmost) = if self.columns.is_empty() {
30523056 (0., 0.)
30533057 } else {
3054- let gaps = self.options.gaps;
3058+ let gaps = self.options.layout.gaps;
30553059
30563060 let mut leftmost = -self.working_area.size.w;
30573061
@@ -3147,17 +3151,17 @@ impl<W: LayoutElement> ScrollingSpace<W> {
31473151 };
31483152 snapping_points.push(Snap { view_pos, col_idx });
31493153
3150- col_x += col_w + self.options.gaps;
3154+ col_x += col_w + self.options.layout.gaps;
31513155 }
31523156 } else {
31533157 let center_on_overflow = matches!(
3154- self.options.center_focused_column,
3158+ self.options.layout.center_focused_column,
31553159 CenterFocusedColumn::OnOverflow
31563160 );
31573161
31583162 let view_width = self.view_size.w;
31593163 let working_area_width = self.working_area.size.w;
3160- let gaps = self.options.gaps;
3164+ let gaps = self.options.layout.gaps;
31613165
31623166 let snap_points =
31633167 |col_x, col: &Column<W>, prev_col_w: Option<f64>, next_col_w: Option<f64>| {
@@ -3297,8 +3301,8 @@ impl<W: LayoutElement> ScrollingSpace<W> {
32973301 break;
32983302 }
32993303 } else {
3300- let padding =
3301- ((self.working_area.size.w - col_w) / 2.).clamp(0., self.options.gaps);
3304+ let padding = ((self.working_area.size.w - col_w) / 2.)
3305+ .clamp(0., self.options.layout.gaps);
33023306 if target_snap.view_pos + left_strut + self.working_area.size.w
33033307 < col_x + col_w + padding
33043308 {
@@ -3319,8 +3323,8 @@ impl<W: LayoutElement> ScrollingSpace<W> {
33193323 break;
33203324 }
33213325 } else {
3322- let padding =
3323- ((self.working_area.size.w - col_w) / 2.).clamp(0., self.options.gaps);
3326+ let padding = ((self.working_area.size.w - col_w) / 2.)
3327+ .clamp(0., self.options.layout.gaps);
33243328 if col_x - padding < target_snap.view_pos + left_strut {
33253329 break;
33263330 }
@@ -3548,12 +3552,12 @@ impl<W: LayoutElement> ScrollingSpace<W> {
35483552
35493553 win.set_interactive_resize(col_resize_data);
35503554
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);
35523556 let bounds = compute_toplevel_bounds(
35533557 border_config,
35543558 self.working_area.size,
35553559 extra_size,
3556- self.options.gaps,
3560+ self.options.layout.gaps,
35573561 );
35583562 win.set_bounds(bounds);
35593563
@@ -3614,7 +3618,7 @@ impl<W: LayoutElement> ScrollingSpace<W> {
36143618 assert_eq!(self.columns.len(), self.data.len());
36153619 assert_eq!(
36163620 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)
36183622 );
36193623
36203624 if !self.columns.is_empty() {
@@ -3802,7 +3806,7 @@ impl<W: LayoutElement> Column<W> {
38023806 .window()
38033807 .rules()
38043808 .default_column_display
3805- .unwrap_or(options.default_column_display);
3809+ .unwrap_or(options.layout.default_column_display);
38063810
38073811 let mut rv = Self {
38083812 tiles: vec![],
@@ -3813,7 +3817,7 @@ impl<W: LayoutElement> Column<W> {
38133817 is_full_width,
38143818 is_pending_fullscreen: false,
38153819 display_mode,
3816- tab_indicator: TabIndicator::new(options.tab_indicator),
3820+ tab_indicator: TabIndicator::new(options.layout.tab_indicator),
38173821 move_animation: None,
38183822 view_size,
38193823 working_area,
@@ -3832,7 +3836,7 @@ impl<W: LayoutElement> Column<W> {
38323836
38333837 // Animate the tab indicator for new columns.
38343838 if display_mode == ColumnDisplay::Tabbed
3835- && !rv.options.tab_indicator.hide_when_single_tab
3839+ && !rv.options.layout.tab_indicator.hide_when_single_tab
38363840 && !rv.is_fullscreen()
38373841 {
38383842 // Usually new columns are created together with window movement actions. For new
@@ -3858,27 +3862,27 @@ impl<W: LayoutElement> Column<W> {
38583862 }
38593863
38603864 // 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 {
38623866 self.preset_width_idx = None;
38633867 }
38643868
38653869 // 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 {
38673871 self.convert_heights_to_auto();
38683872 update_sizes = true;
38693873 }
38703874
3871- if self.options.gaps != options.gaps {
3875+ if self.options.layout.gaps != options.layout.gaps {
38723876 update_sizes = true;
38733877 }
38743878
3875- if self.options.border.off != options.border.off
3876- || self.options.border.width != options.border.width
3879+ if self.options.layout.border.off != options.layout.border.off
3880+ || self.options.layout.border.width != options.layout.border.width
38773881 {
38783882 update_sizes = true;
38793883 }
38803884
3881- if self.options.tab_indicator != options.tab_indicator {
3885+ if self.options.layout.tab_indicator != options.layout.tab_indicator {
38823886 update_sizes = true;
38833887 }
38843888
@@ -3887,7 +3891,8 @@ impl<W: LayoutElement> Column<W> {
38873891 data.update(tile);
38883892 }
38893893
3890- self.tab_indicator.update_config(options.tab_indicator);
3894+ self.tab_indicator
3895+ .update_config(options.layout.tab_indicator);
38913896 self.view_size = view_size;
38923897 self.working_area = working_area;
38933898 self.scale = scale;
@@ -4192,7 +4197,7 @@ impl<W: LayoutElement> Column<W> {
41924197
41934198 fn resolve_column_width(&self, width: ColumnWidth) -> f64 {
41944199 let working_size = self.working_area.size;
4195- let gaps = self.options.gaps;
4200+ let gaps = self.options.layout.gaps;
41964201 let extra = self.extra_size();
41974202
41984203 match width {
@@ -4274,7 +4279,7 @@ impl<W: LayoutElement> Column<W> {
42744279
42754280 let width = self.resolve_column_width(width);
42764281 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;
42784283
42794284 // If there are multiple windows in a column, clamp the non-auto window's height according
42804285 // to other windows' min sizes.
@@ -4289,7 +4294,7 @@ impl<W: LayoutElement> Column<W> {
42894294 .iter()
42904295 .enumerate()
42914296 .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)
42934298 .sum::<f64>();
42944299
42954300 let tile = &self.tiles[non_auto_idx];
@@ -4318,7 +4323,7 @@ impl<W: LayoutElement> Column<W> {
43184323 WindowHeight::Fixed(tile.tile_height_for_window_height(window_height))
43194324 }
43204325 WindowHeight::Preset(idx) => {
4321- let preset = self.options.preset_window_heights[idx];
4326+ let preset = self.options.layout.preset_window_heights[idx];
43224327 let window_height = match self.resolve_preset_height(preset) {
43234328 ResolvedSize::Tile(h) => tile.window_height_for_tile_height(h),
43244329 ResolvedSize::Window(h) => h,
@@ -4366,7 +4371,7 @@ impl<W: LayoutElement> Column<W> {
43664371 // The following logic will apply individual min/max height, etc.
43674372 }
43684373
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;
43704375 let mut height_left = working_size.h - gaps_left;
43714376 let mut auto_tiles_left = self.tiles.len();
43724377
@@ -4589,7 +4594,7 @@ impl<W: LayoutElement> Column<W> {
45894594 self.preset_width_idx
45904595 };
45914596
4592- let len = self.options.preset_column_widths.len();
4597+ let len = self.options.layout.preset_column_widths.len();
45934598 let preset_idx = if let Some(idx) = preset_idx {
45944599 (idx + if forwards { 1 } else { len - 1 }) % len
45954600 } else {
@@ -4599,6 +4604,7 @@ impl<W: LayoutElement> Column<W> {
45994604
46004605 let mut it = self
46014606 .options
4607+ .layout
46024608 .preset_column_widths
46034609 .iter()
46044610 .map(|preset| self.resolve_preset_width(*preset));
@@ -4624,7 +4630,7 @@ impl<W: LayoutElement> Column<W> {
46244630 }
46254631 };
46264632
4627- let preset = self.options.preset_column_widths[preset_idx];
4633+ let preset = self.options.layout.preset_column_widths[preset_idx];
46284634 self.set_column_width(SizeChange::from(preset), Some(tile_idx), true);
46294635
46304636 self.preset_width_idx = Some(preset_idx);
@@ -4672,11 +4678,11 @@ impl<W: LayoutElement> Column<W> {
46724678 ColumnWidth::Proportion(proportion)
46734679 }
46744680 (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;
46764682 let current = if full == 0. {
46774683 1.
46784684 } else {
4679- (current_px + self.options.gaps + self.extra_size().w) / full
4685+ (current_px + self.options.layout.gaps + self.extra_size().w) / full
46804686 };
46814687 let proportion = (current + delta / 100.).clamp(0., MAX_F);
46824688 ColumnWidth::Proportion(proportion)
@@ -4710,7 +4716,7 @@ impl<W: LayoutElement> Column<W> {
47104716 let current_tile_px = tile.tile_height_for_window_height(current_window_px);
47114717
47124718 let working_size = self.working_area.size.h;
4713- let gaps = self.options.gaps;
4719+ let gaps = self.options.layout.gaps;
47144720 let extra_size = self.extra_size().h;
47154721 let full = working_size - gaps;
47164722 let current_prop = if full == 0. {
@@ -4794,7 +4800,7 @@ impl<W: LayoutElement> Column<W> {
47944800 self.convert_heights_to_auto();
47954801 }
47964802
4797- let len = self.options.preset_window_heights.len();
4803+ let len = self.options.layout.preset_window_heights.len();
47984804 let preset_idx = match self.data[tile_idx].height {
47994805 WindowHeight::Preset(idx) => (idx + if forwards { 1 } else { len - 1 }) % len,
48004806 _ => {
@@ -4803,6 +4809,7 @@ impl<W: LayoutElement> Column<W> {
48034809
48044810 let mut it = self
48054811 .options
4812+ .layout
48064813 .preset_window_heights
48074814 .iter()
48084815 .copied()
@@ -4933,7 +4940,7 @@ impl<W: LayoutElement> Column<W> {
49334940 return origin;
49344941 }
49354942
4936- origin.y += self.working_area.loc.y + self.options.gaps;
4943+ origin.y += self.working_area.loc.y + self.options.layout.gaps;
49374944
49384945 if self.display_mode == ColumnDisplay::Tabbed {
49394946 origin += self
@@ -4953,8 +4960,8 @@ impl<W: LayoutElement> Column<W> {
49534960 // FIXME: this should take into account always-center-single-column, which means that
49544961 // Column should somehow know when it is being centered due to being the single column on
49554962 // the workspace or some other reason.
4956- let center = self.options.center_focused_column == CenterFocusedColumn::Always;
4957- let gaps = self.options.gaps;
4963+ let center = self.options.layout.center_focused_column == CenterFocusedColumn::Always;
4964+ let gaps = self.options.layout.gaps;
49584965 let tabbed = self.display_mode == ColumnDisplay::Tabbed;
49594966
49604967 // Does not include extra size from the tab indicator.
@@ -5117,7 +5124,7 @@ impl<W: LayoutElement> Column<W> {
51175124 }
51185125
51195126 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());
51215128 }
51225129
51235130 let is_tabbed = self.display_mode == ColumnDisplay::Tabbed;
@@ -5134,7 +5141,7 @@ impl<W: LayoutElement> Column<W> {
51345141
51355142 let working_size = self.working_area.size;
51365143 let extra_size = self.extra_size();
5137- let gaps = self.options.gaps;
5144+ let gaps = self.options.layout.gaps;
51385145
51395146 let mut found_fixed = false;
51405147 let mut total_height = 0.;
@@ -5163,7 +5170,7 @@ impl<W: LayoutElement> Column<W> {
51635170 }
51645171
51655172 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);
51675174 }
51685175
51695176 let requested_size = tile.window().requested_size().unwrap();
@@ -5312,9 +5319,9 @@ fn resolve_preset_size(
53125319 extra_size: f64,
53135320 ) -> ResolvedSize {
53145321 match preset {
5315- PresetSize::Proportion(proportion) => {
5316- ResolvedSize::Tile((view_size - options.gaps) * proportion - options.gaps - extra_size)
5317- }
5322+ PresetSize::Proportion(proportion) => ResolvedSize::Tile(
5323+ (view_size - options.layout.gaps) * proportion - options.layout.gaps - extra_size,
5324+ ),
53185325 PresetSize::Fixed(width) => ResolvedSize::Window(f64::from(width)),
53195326 }
53205327 }
src/layout/tests.rsmodified+87 -34
@@ -2,7 +2,8 @@ use std::cell::{Cell, OnceCell, RefCell};
22
33 use niri_config::workspace::WorkspaceName;
44 use niri_config::{
5- FloatOrInt, OutputName, TabIndicatorLength, TabIndicatorPosition, WorkspaceReference,
5+ CenterFocusedColumn, FloatOrInt, OutputName, Struts, TabIndicatorLength, TabIndicatorPosition,
6+ WorkspaceReference,
67 };
78 use proptest::prelude::*;
89 use proptest_derive::Arbitrary;
@@ -2066,8 +2067,8 @@ fn large_negative_height_change() {
20662067 ];
20672068
20682069 let mut options = Options::default();
2069- options.border.off = false;
2070- options.border.width = 1.;
2070+ options.layout.border.off = false;
2071+ options.layout.border.width = 1.;
20712072
20722073 check_ops_with_options(options, ops);
20732074 }
@@ -2085,8 +2086,8 @@ fn large_max_size() {
20852086 ];
20862087
20872088 let mut options = Options::default();
2088- options.border.off = false;
2089- options.border.width = 1.;
2089+ options.layout.border.off = false;
2090+ options.layout.border.width = 1.;
20902091
20912092 check_ops_with_options(options, ops);
20922093 }
@@ -2244,7 +2245,10 @@ fn open_right_of_on_different_workspace_ewaf() {
22442245 ];
22452246
22462247 let options = Options {
2247- empty_workspace_above_first: true,
2248+ layout: niri_config::Layout {
2249+ empty_workspace_above_first: true,
2250+ ..Default::default()
2251+ },
22482252 ..Default::default()
22492253 };
22502254 let layout = check_ops_with_options(options, ops);
@@ -2306,11 +2310,7 @@ fn config_change_updates_cached_sizes() {
23062310 }
23072311 .apply(&mut layout);
23082312
2309- config
2310- .layout
2311- .border
2312- .get_or_insert_with(Default::default)
2313- .width = Some(FloatOrInt(4.));
2313+ config.layout.border.as_mut().unwrap().width = Some(FloatOrInt(4.));
23142314 layout.update_config(&config);
23152315
23162316 layout.verify_invariants();
@@ -2427,12 +2427,15 @@ fn fixed_height_takes_max_non_auto_into_account() {
24272427 ];
24282428
24292429 let options = Options {
2430- border: niri_config::Border {
2431- off: false,
2432- width: 4.,
2430+ layout: niri_config::Layout {
2431+ border: niri_config::Border {
2432+ off: false,
2433+ width: 4.,
2434+ ..Default::default()
2435+ },
2436+ gaps: 0.,
24332437 ..Default::default()
24342438 },
2435- gaps: 0.,
24362439 ..Default::default()
24372440 };
24382441 check_ops_with_options(options, ops);
@@ -2511,7 +2514,10 @@ fn interactive_move_onto_empty_output_ewaf() {
25112514 ];
25122515
25132516 let options = Options {
2514- empty_workspace_above_first: true,
2517+ layout: niri_config::Layout {
2518+ empty_workspace_above_first: true,
2519+ ..Default::default()
2520+ },
25152521 ..Default::default()
25162522 };
25172523 check_ops_with_options(options, ops);
@@ -2572,7 +2578,10 @@ fn interactive_move_onto_first_empty_workspace() {
25722578 Op::InteractiveMoveEnd { window: 1 },
25732579 ];
25742580 let options = Options {
2575- empty_workspace_above_first: true,
2581+ layout: niri_config::Layout {
2582+ empty_workspace_above_first: true,
2583+ ..Default::default()
2584+ },
25762585 ..Default::default()
25772586 };
25782587 check_ops_with_options(options, ops);
@@ -2653,7 +2662,10 @@ fn named_workspace_to_output_ewaf() {
26532662 Op::AddOutput(2),
26542663 ];
26552664 let options = Options {
2656- empty_workspace_above_first: true,
2665+ layout: niri_config::Layout {
2666+ empty_workspace_above_first: true,
2667+ ..Default::default()
2668+ },
26572669 ..Default::default()
26582670 };
26592671 check_ops_with_options(options, ops);
@@ -2672,7 +2684,10 @@ fn move_window_to_empty_workspace_above_first() {
26722684 Op::MoveWorkspaceDown,
26732685 ];
26742686 let options = Options {
2675- empty_workspace_above_first: true,
2687+ layout: niri_config::Layout {
2688+ empty_workspace_above_first: true,
2689+ ..Default::default()
2690+ },
26762691 ..Default::default()
26772692 };
26782693 check_ops_with_options(options, ops);
@@ -2689,7 +2704,10 @@ fn move_window_to_different_output() {
26892704 Op::MoveWorkspaceToOutput(2),
26902705 ];
26912706 let options = Options {
2692- empty_workspace_above_first: true,
2707+ layout: niri_config::Layout {
2708+ empty_workspace_above_first: true,
2709+ ..Default::default()
2710+ },
26932711 ..Default::default()
26942712 };
26952713 check_ops_with_options(options, ops);
@@ -2705,7 +2723,10 @@ fn close_window_empty_ws_above_first() {
27052723 Op::CloseWindow(1),
27062724 ];
27072725 let options = Options {
2708- empty_workspace_above_first: true,
2726+ layout: niri_config::Layout {
2727+ empty_workspace_above_first: true,
2728+ ..Default::default()
2729+ },
27092730 ..Default::default()
27102731 };
27112732 check_ops_with_options(options, ops);
@@ -2722,7 +2743,10 @@ fn add_and_remove_output() {
27222743 Op::RemoveOutput(2),
27232744 ];
27242745 let options = Options {
2725- empty_workspace_above_first: true,
2746+ layout: niri_config::Layout {
2747+ empty_workspace_above_first: true,
2748+ ..Default::default()
2749+ },
27262750 ..Default::default()
27272751 };
27282752 check_ops_with_options(options, ops);
@@ -2739,7 +2763,10 @@ fn switch_ewaf_on() {
27392763
27402764 let mut layout = check_ops(ops);
27412765 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+ },
27432770 ..Default::default()
27442771 });
27452772 layout.verify_invariants();
@@ -2755,7 +2782,10 @@ fn switch_ewaf_off() {
27552782 ];
27562783
27572784 let options = Options {
2758- empty_workspace_above_first: true,
2785+ layout: niri_config::Layout {
2786+ empty_workspace_above_first: true,
2787+ ..Default::default()
2788+ },
27592789 ..Default::default()
27602790 };
27612791 let mut layout = check_ops_with_options(options, ops);
@@ -3074,7 +3104,10 @@ fn set_first_workspace_name_ewaf() {
30743104 ];
30753105
30763106 let options = Options {
3077- empty_workspace_above_first: true,
3107+ layout: niri_config::Layout {
3108+ empty_workspace_above_first: true,
3109+ ..Default::default()
3110+ },
30783111 ..Default::default()
30793112 };
30803113 check_ops_with_options(options, ops);
@@ -3165,7 +3198,10 @@ fn preset_column_width_fixed_correct_with_border() {
31653198 ];
31663199
31673200 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+ },
31693205 ..Default::default()
31703206 };
31713207 let mut layout = check_ops_with_options(options, ops);
@@ -3175,10 +3211,13 @@ fn preset_column_width_fixed_correct_with_border() {
31753211
31763212 // Add border.
31773213 let options = Options {
3178- preset_column_widths: vec![PresetSize::Fixed(500)],
3179- border: niri_config::Border {
3180- off: false,
3181- width: 5.,
3214+ layout: niri_config::Layout {
3215+ preset_column_widths: vec![PresetSize::Fixed(500)],
3216+ border: niri_config::Border {
3217+ off: false,
3218+ width: 5.,
3219+ ..Default::default()
3220+ },
31823221 ..Default::default()
31833222 },
31843223 ..Default::default()
@@ -3211,7 +3250,10 @@ fn preset_column_width_reset_after_set_width() {
32113250 ];
32123251
32133252 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+ },
32153257 ..Default::default()
32163258 };
32173259 let layout = check_ops_with_options(options, ops);
@@ -3469,7 +3511,7 @@ prop_compose! {
34693511 }
34703512
34713513 prop_compose! {
3472- fn arbitrary_options()(
3514+ fn arbitrary_layout_config()(
34733515 gaps in arbitrary_spacing(),
34743516 struts in arbitrary_struts(),
34753517 focus_ring in arbitrary_focus_ring(),
@@ -3479,8 +3521,8 @@ prop_compose! {
34793521 center_focused_column in arbitrary_center_focused_column(),
34803522 always_center_single_column in any::<bool>(),
34813523 empty_workspace_above_first in any::<bool>(),
3482- ) -> Options {
3483- Options {
3524+ ) -> niri_config::Layout {
3525+ niri_config::Layout {
34843526 gaps,
34853527 struts,
34863528 center_focused_column,
@@ -3495,6 +3537,17 @@ prop_compose! {
34953537 }
34963538 }
34973539
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+
34983551 proptest! {
34993552 #![proptest_config(ProptestConfig {
35003553 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 {
2929 });
3030
3131 let mut options = Options {
32- gaps: 0.0,
32+ layout: niri_config::Layout {
33+ gaps: 0.0,
34+ ..Default::default()
35+ },
3336 ..Options::default()
3437 };
3538 options.animations.window_resize.anim.kind = LINEAR;
src/layout/tests/fullscreen.rsmodified+6 -3
@@ -188,9 +188,12 @@ fn unfullscreen_with_large_border() {
188188 ];
189189
190190 let options = Options {
191- border: niri_config::Border {
192- off: false,
193- width: 10000.,
191+ layout: niri_config::Layout {
192+ border: niri_config::Border {
193+ off: false,
194+ width: 10000.,
195+ ..Default::default()
196+ },
194197 ..Default::default()
195198 },
196199 ..Default::default()
src/layout/tile.rsmodified+19 -11
@@ -175,9 +175,9 @@ impl<W: LayoutElement> Tile<W> {
175175 options: Rc<Options>,
176176 ) -> Self {
177177 let rules = window.rules();
178- let border_config = options.border.merged_with(&rules.border);
179- let focus_ring_config = options.focus_ring.merged_with(&rules.focus_ring);
180- let shadow_config = options.shadow.merged_with(&rules.shadow);
178+ let border_config = options.layout.border.merged_with(&rules.border);
179+ let focus_ring_config = options.layout.focus_ring.merged_with(&rules.focus_ring);
180+ let shadow_config = options.layout.shadow.merged_with(&rules.shadow);
181181 let is_fullscreen = window.is_fullscreen();
182182
183183 Self {
@@ -214,10 +214,10 @@ impl<W: LayoutElement> Tile<W> {
214214 options: Rc<Options>,
215215 ) {
216216 // 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 {
218218 self.floating_preset_width_idx = None;
219219 }
220- if self.options.preset_window_heights != options.preset_window_heights {
220+ if self.options.layout.preset_window_heights != options.layout.preset_window_heights {
221221 self.floating_preset_height_idx = None;
222222 }
223223
@@ -227,13 +227,17 @@ impl<W: LayoutElement> Tile<W> {
227227
228228 let rules = self.window.rules();
229229
230- let border_config = self.options.border.merged_with(&rules.border);
230+ let border_config = self.options.layout.border.merged_with(&rules.border);
231231 self.border.update_config(border_config.into());
232232
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);
234238 self.focus_ring.update_config(focus_ring_config);
235239
236- let shadow_config = self.options.shadow.merged_with(&rules.shadow);
240+ let shadow_config = self.options.layout.shadow.merged_with(&rules.shadow);
237241 self.shadow.update_config(shadow_config);
238242 }
239243
@@ -332,12 +336,16 @@ impl<W: LayoutElement> Tile<W> {
332336 }
333337
334338 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);
336340 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);
338346 self.focus_ring.update_config(focus_ring_config);
339347
340- let shadow_config = self.options.shadow.merged_with(&rules.shadow);
348+ let shadow_config = self.options.layout.shadow.merged_with(&rules.shadow);
341349 self.shadow.update_config(shadow_config);
342350
343351 let window_size = self.window_size();
src/layout/workspace.rsmodified+7 -6
@@ -754,7 +754,7 @@ impl<W: LayoutElement> Workspace<W> {
754754 Some(Some(width)) => Some(width),
755755 Some(None) => None,
756756 None if is_floating => None,
757- None => self.options.default_column_width,
757+ None => self.options.layout.default_column_width,
758758 }
759759 }
760760
@@ -1272,11 +1272,12 @@ impl<W: LayoutElement> Workspace<W> {
12721272 // Come up with a default floating position close to the tile position.
12731273 let stored_or_default = self.floating.stored_or_default_tile_pos(&removed.tile);
12741274 if stored_or_default.is_none() {
1275- let offset = if self.options.center_focused_column == CenterFocusedColumn::Always {
1276- Point::from((0., 0.))
1277- } else {
1278- Point::from((50., 50.))
1279- };
1275+ let offset =
1276+ if self.options.layout.center_focused_column == CenterFocusedColumn::Always {
1277+ Point::from((0., 0.))
1278+ } else {
1279+ Point::from((50., 50.))
1280+ };
12801281 let pos = render_pos + offset;
12811282 let size = removed.tile.tile_size();
12821283 let pos = self.floating.clamp_within_working_area(pos, size);