forge
Explore
Log in

Don't you dare go Hollow

Add per-workspace layout config

Browse files at this commit

d5f4e79e4c35d4f5a7a4a64e85e72fb1545ef2dbIvan MolodetskikhParent: d015c7e
Per-workspace background-color doesn't work yet.
niri-config/src/lib.rsmodified+4 -1
@@ -38,7 +38,7 @@ pub use crate::output::{Output, OutputName, Outputs, Position, Vrr};
38 pub use crate::utils::FloatOrInt;38 pub use crate::utils::FloatOrInt;
39 use crate::utils::MergeWith as _;39 use crate::utils::MergeWith as _;
40 pub use crate::window_rule::{FloatingPosition, RelativeTo, WindowRule};40 pub use crate::window_rule::{FloatingPosition, RelativeTo, WindowRule};
41-pub use crate::workspace::Workspace;41+pub use crate::workspace::{Workspace, WorkspaceLayoutPart};
42 42
43 #[derive(knuffel::Decode, Debug, PartialEq)]43 #[derive(knuffel::Decode, Debug, PartialEq)]
44 pub struct Config {44 pub struct Config {
@@ -1795,18 +1795,21 @@ mod tests {
1795 open_on_output: Some(1795 open_on_output: Some(
1796 "eDP-1",1796 "eDP-1",
1797 ),1797 ),
1798+ layout: None,
1798 },1799 },
1799 Workspace {1800 Workspace {
1800 name: WorkspaceName(1801 name: WorkspaceName(
1801 "workspace-2",1802 "workspace-2",
1802 ),1803 ),
1803 open_on_output: None,1804 open_on_output: None,
1805+ layout: None,
1804 },1806 },
1805 Workspace {1807 Workspace {
1806 name: WorkspaceName(1808 name: WorkspaceName(
1807 "workspace-3",1809 "workspace-3",
1808 ),1810 ),
1809 open_on_output: None,1811 open_on_output: None,
1812+ layout: None,
1810 },1813 },
1811 ],1814 ],
1812 }1815 }
niri-config/src/workspace.rsmodified+35 -1
@@ -1,16 +1,50 @@
1 use knuffel::errors::DecodeError;1 use knuffel::errors::DecodeError;
2 2
3-#[derive(knuffel::Decode, Debug, Clone, PartialEq, Eq)]3+use crate::LayoutPart;
4+
5+#[derive(knuffel::Decode, Debug, Clone, PartialEq)]
4 pub struct Workspace {6 pub struct Workspace {
5 #[knuffel(argument)]7 #[knuffel(argument)]
6 pub name: WorkspaceName,8 pub name: WorkspaceName,
7 #[knuffel(child, unwrap(argument))]9 #[knuffel(child, unwrap(argument))]
8 pub open_on_output: Option<String>,10 pub open_on_output: Option<String>,
11+ #[knuffel(child)]
12+ pub layout: Option<WorkspaceLayoutPart>,
9 }13 }
10 14
11 #[derive(Debug, Clone, PartialEq, Eq)]15 #[derive(Debug, Clone, PartialEq, Eq)]
12 pub struct WorkspaceName(pub String);16 pub struct WorkspaceName(pub String);
13 17
18+#[derive(Debug, Clone, PartialEq)]
19+pub struct WorkspaceLayoutPart(pub LayoutPart);
20+
21+impl<S: knuffel::traits::ErrorSpan> knuffel::Decode<S> for WorkspaceLayoutPart {
22+ fn decode_node(
23+ node: &knuffel::ast::SpannedNode<S>,
24+ ctx: &mut knuffel::decode::Context<S>,
25+ ) -> Result<Self, DecodeError<S>> {
26+ for child in node.children() {
27+ let name = &**child.node_name;
28+
29+ // Check for disallowed properties.
30+ //
31+ // - empty-workspace-above-first is a monitor-level concept.
32+ // - insert-hint customization could make sense for workspaces, however currently it is
33+ // also handled at the monitor level (since insert hints in-between workspaces are a
34+ // monitor-level concept), so for now this config option would do nothing.
35+ if matches!(name, "empty-workspace-above-first" | "insert-hint") {
36+ ctx.emit_error(DecodeError::unexpected(
37+ child,
38+ "node",
39+ format!("node `{name}` is not allowed inside `workspace.layout`"),
40+ ));
41+ }
42+ }
43+
44+ LayoutPart::decode_node(node, ctx).map(Self)
45+ }
46+}
47+
14 impl<S: knuffel::traits::ErrorSpan> knuffel::DecodeScalar<S> for WorkspaceName {48 impl<S: knuffel::traits::ErrorSpan> knuffel::DecodeScalar<S> for WorkspaceName {
15 fn type_check(49 fn type_check(
16 type_name: &Option<knuffel::span::Spanned<knuffel::ast::TypeName, S>>,50 type_name: &Option<knuffel::span::Spanned<knuffel::ast::TypeName, S>>,
src/layout/mod.rsmodified+63 -19
@@ -380,6 +380,12 @@ struct InteractiveMoveData<W: LayoutElement> {
380 ///380 ///
381 /// This helps the pointer remain inside the window as it resizes.381 /// This helps the pointer remain inside the window as it resizes.
382 pub(self) pointer_ratio_within_window: (f64, f64),382 pub(self) pointer_ratio_within_window: (f64, f64),
383+ /// Config overrides for the workspace where the window is currently located.
384+ ///
385+ /// To avoid sudden window changes when starting an interactive move, it will remember the
386+ /// config overrides for the workspace where the move originated from. As soon as the window
387+ /// moves over some different workspace though, this override will reset.
388+ pub(self) workspace_config: Option<(WorkspaceId, niri_config::LayoutPart)>,
383 }389 }
384 390
385 #[derive(Debug)]391 #[derive(Debug)]
@@ -576,6 +582,13 @@ impl Options {
576 }582 }
577 }583 }
578 584
585+ fn with_merged_layout(mut self, part: Option<&niri_config::LayoutPart>) -> Self {
586+ if let Some(part) = part {
587+ self.layout.merge_with(part);
588+ }
589+ self
590+ }
591+
579 fn adjusted_for_scale(mut self, scale: f64) -> Self {592 fn adjusted_for_scale(mut self, scale: f64) -> Self {
580 let round = |logical: f64| round_logical_in_physical_max1(scale, logical);593 let round = |logical: f64| round_logical_in_physical_max1(scale, logical);
581 594
@@ -2296,7 +2309,9 @@ impl<W: LayoutElement> Layout<W> {
2296 move_.tile.verify_invariants();2309 move_.tile.verify_invariants();
2297 2310
2298 let scale = move_.output.current_scale().fractional_scale();2311 let scale = move_.output.current_scale().fractional_scale();
2299- let options = Options::clone(&self.options).adjusted_for_scale(scale);2312+ let options = Options::clone(&self.options)
2313+ .with_merged_layout(move_.workspace_config.as_ref().map(|(_, c)| c))
2314+ .adjusted_for_scale(scale);
2300 assert_eq!(2315 assert_eq!(
2301 &*move_.tile.options, &options,2316 &*move_.tile.options, &options,
2302 "interactive moved tile options must be \2317 "interactive moved tile options must be \
@@ -2830,6 +2845,14 @@ impl<W: LayoutElement> Layout<W> {
2830 }2845 }
2831 2846
2832 pub fn update_config(&mut self, config: &Config) {2847 pub fn update_config(&mut self, config: &Config) {
2848+ // Update workspace-specific config for all named workspaces.
2849+ for ws in self.workspaces_mut() {
2850+ let Some(name) = ws.name() else { continue };
2851+ if let Some(config) = config.workspaces.iter().find(|w| &w.name.0 == name) {
2852+ ws.update_layout_config(config.layout.clone().map(|x| x.0));
2853+ }
2854+ }
2855+
2833 self.update_options(Options::from_config(config));2856 self.update_options(Options::from_config(config));
2834 }2857 }
2835 2858
@@ -2839,11 +2862,10 @@ impl<W: LayoutElement> Layout<W> {
2839 if let Some(InteractiveMoveState::Moving(move_)) = &mut self.interactive_move {2862 if let Some(InteractiveMoveState::Moving(move_)) = &mut self.interactive_move {
2840 let view_size = output_size(&move_.output);2863 let view_size = output_size(&move_.output);
2841 let scale = move_.output.current_scale().fractional_scale();2864 let scale = move_.output.current_scale().fractional_scale();
2842- move_.tile.update_config(2865+ let options = Options::clone(&options)
2843- view_size,2866+ .with_merged_layout(move_.workspace_config.as_ref().map(|(_, c)| c))
2844- scale,2867+ .adjusted_for_scale(scale);
2845- Rc::new(Options::clone(&options).adjusted_for_scale(scale)),2868+ move_.tile.update_config(view_size, scale, Rc::new(options));
2846- );
2847 }2869 }
2848 2870
2849 match &mut self.monitor_set {2871 match &mut self.monitor_set {
@@ -3737,15 +3759,17 @@ impl<W: LayoutElement> Layout<W> {
3737 }3759 }
3738 .band(sq_dist / INTERACTIVE_MOVE_START_THRESHOLD);3760 .band(sq_dist / INTERACTIVE_MOVE_START_THRESHOLD);
3739 3761
3740- let (is_floating, tile) = self3762+ let (is_floating, tile, workspace_config) = self
3741 .workspaces_mut()3763 .workspaces_mut()
3742 .find(|ws| ws.has_window(&window_id))3764 .find(|ws| ws.has_window(&window_id))
3743 .map(|ws| {3765 .map(|ws| {
3766+ let workspace_config = ws.layout_config().cloned().map(|c| (ws.id(), c));
3744 (3767 (
3745 ws.is_floating(&window_id),3768 ws.is_floating(&window_id),
3746 ws.tiles_mut()3769 ws.tiles_mut()
3747 .find(|tile| *tile.window().id() == window_id)3770 .find(|tile| *tile.window().id() == window_id)
3748 .unwrap(),3771 .unwrap(),
3772+ workspace_config,
3749 )3773 )
3750 })3774 })
3751 .unwrap();3775 .unwrap();
@@ -3807,11 +3831,10 @@ impl<W: LayoutElement> Layout<W> {
3807 3831
3808 let view_size = output_size(&output);3832 let view_size = output_size(&output);
3809 let scale = output.current_scale().fractional_scale();3833 let scale = output.current_scale().fractional_scale();
3810- tile.update_config(3834+ let options = Options::clone(&self.options)
3811- view_size,3835+ .with_merged_layout(workspace_config.as_ref().map(|(_, c)| c))
3812- scale,3836+ .adjusted_for_scale(scale);
3813- Rc::new(Options::clone(&self.options).adjusted_for_scale(scale)),3837+ tile.update_config(view_size, scale, Rc::new(options));
3814- );
3815 3838
3816 // Unfullscreen.3839 // Unfullscreen.
3817 let floating_size = tile.floating_window_size;3840 let floating_size = tile.floating_window_size;
@@ -3864,6 +3887,7 @@ impl<W: LayoutElement> Layout<W> {
3864 is_full_width,3887 is_full_width,
3865 is_floating,3888 is_floating,
3866 pointer_ratio_within_window,3889 pointer_ratio_within_window,
3890+ workspace_config,
3867 };3891 };
3868 3892
3869 if let Some((tile_pos, zoom)) = tile_pos {3893 if let Some((tile_pos, zoom)) = tile_pos {
@@ -3880,6 +3904,23 @@ impl<W: LayoutElement> Layout<W> {
3880 return false;3904 return false;
3881 }3905 }
3882 3906
3907+ let mut ws_id = None;
3908+ if let Some(mon) = self.monitor_for_output(&output) {
3909+ let (insert_ws, _) = mon.insert_position(move_.pointer_pos_within_output);
3910+ if let InsertWorkspace::Existing(id) = insert_ws {
3911+ ws_id = Some(id);
3912+ }
3913+ }
3914+
3915+ // If moved over a different workspace, reset the config override.
3916+ let mut update_config = false;
3917+ if let Some((id, _)) = &move_.workspace_config {
3918+ if Some(*id) != ws_id {
3919+ move_.workspace_config = None;
3920+ update_config = true;
3921+ }
3922+ }
3923+
3883 if output != move_.output {3924 if output != move_.output {
3884 move_.tile.window().output_leave(&move_.output);3925 move_.tile.window().output_leave(&move_.output);
3885 move_.tile.window().output_enter(&output);3926 move_.tile.window().output_enter(&output);
@@ -3887,15 +3928,18 @@ impl<W: LayoutElement> Layout<W> {
3887 output.current_scale(),3928 output.current_scale(),
3888 output.current_transform(),3929 output.current_transform(),
3889 );3930 );
3890- let view_size = output_size(&output);
3891- let scale = output.current_scale().fractional_scale();
3892- move_.tile.update_config(
3893- view_size,
3894- scale,
3895- Rc::new(Options::clone(&self.options).adjusted_for_scale(scale)),
3896- );
3897 move_.output = output.clone();3931 move_.output = output.clone();
3898 self.focus_output(&output);3932 self.focus_output(&output);
3933+ update_config = true;
3934+ }
3935+
3936+ if update_config {
3937+ let view_size = output_size(&output);
3938+ let scale = output.current_scale().fractional_scale();
3939+ let options = Options::clone(&self.options)
3940+ .with_merged_layout(move_.workspace_config.as_ref().map(|(_, c)| c))
3941+ .adjusted_for_scale(scale);
3942+ move_.tile.update_config(view_size, scale, Rc::new(options));
3899 }3943 }
3900 3944
3901 move_.pointer_pos_within_output = pointer_pos_within_output;3945 move_.pointer_pos_within_output = pointer_pos_within_output;
src/layout/tests.rsmodified+89 -0
@@ -414,11 +414,19 @@ enum Op {
414 ws_name: usize,414 ws_name: usize,
415 #[proptest(strategy = "prop::option::of(1..=5usize)")]415 #[proptest(strategy = "prop::option::of(1..=5usize)")]
416 output_name: Option<usize>,416 output_name: Option<usize>,
417+ #[proptest(strategy = "prop::option::of(arbitrary_layout_part().prop_map(Box::new))")]
418+ layout_config: Option<Box<niri_config::LayoutPart>>,
417 },419 },
418 UnnameWorkspace {420 UnnameWorkspace {
419 #[proptest(strategy = "1..=5usize")]421 #[proptest(strategy = "1..=5usize")]
420 ws_name: usize,422 ws_name: usize,
421 },423 },
424+ UpdateWorkspaceLayoutConfig {
425+ #[proptest(strategy = "1..=5usize")]
426+ ws_name: usize,
427+ #[proptest(strategy = "prop::option::of(arbitrary_layout_part().prop_map(Box::new))")]
428+ layout_config: Option<Box<niri_config::LayoutPart>>,
429+ },
422 AddWindow {430 AddWindow {
423 params: TestWindowParams,431 params: TestWindowParams,
424 },432 },
@@ -817,15 +825,31 @@ impl Op {
817 Op::AddNamedWorkspace {825 Op::AddNamedWorkspace {
818 ws_name,826 ws_name,
819 output_name,827 output_name,
828+ layout_config,
820 } => {829 } => {
821 layout.ensure_named_workspace(&WorkspaceConfig {830 layout.ensure_named_workspace(&WorkspaceConfig {
822 name: WorkspaceName(format!("ws{ws_name}")),831 name: WorkspaceName(format!("ws{ws_name}")),
823 open_on_output: output_name.map(|name| format!("output{name}")),832 open_on_output: output_name.map(|name| format!("output{name}")),
833+ layout: layout_config.map(|x| niri_config::WorkspaceLayoutPart(*x)),
824 });834 });
825 }835 }
826 Op::UnnameWorkspace { ws_name } => {836 Op::UnnameWorkspace { ws_name } => {
827 layout.unname_workspace(&format!("ws{ws_name}"));837 layout.unname_workspace(&format!("ws{ws_name}"));
828 }838 }
839+ Op::UpdateWorkspaceLayoutConfig {
840+ ws_name,
841+ layout_config,
842+ } => {
843+ let ws_name = format!("ws{ws_name}");
844+ let Some(ws) = layout
845+ .workspaces_mut()
846+ .find(|ws| ws.name() == Some(&ws_name))
847+ else {
848+ return;
849+ };
850+
851+ ws.update_layout_config(layout_config.map(|x| *x));
852+ }
829 Op::SetWorkspaceName {853 Op::SetWorkspaceName {
830 new_ws_name,854 new_ws_name,
831 ws_name,855 ws_name,
@@ -1607,6 +1631,7 @@ fn operations_dont_panic() {
1607 Op::AddNamedWorkspace {1631 Op::AddNamedWorkspace {
1608 ws_name: 1,1632 ws_name: 1,
1609 output_name: Some(1),1633 output_name: Some(1),
1634+ layout_config: None,
1610 },1635 },
1611 Op::UnnameWorkspace { ws_name: 1 },1636 Op::UnnameWorkspace { ws_name: 1 },
1612 Op::AddWindow {1637 Op::AddWindow {
@@ -1754,6 +1779,7 @@ fn operations_from_starting_state_dont_panic() {
1754 Op::AddNamedWorkspace {1779 Op::AddNamedWorkspace {
1755 ws_name: 1,1780 ws_name: 1,
1756 output_name: Some(1),1781 output_name: Some(1),
1782+ layout_config: None,
1757 },1783 },
1758 Op::UnnameWorkspace { ws_name: 1 },1784 Op::UnnameWorkspace { ws_name: 1 },
1759 Op::AddWindow {1785 Op::AddWindow {
@@ -2289,10 +2315,12 @@ fn removing_all_outputs_preserves_empty_named_workspaces() {
2289 Op::AddNamedWorkspace {2315 Op::AddNamedWorkspace {
2290 ws_name: 1,2316 ws_name: 1,
2291 output_name: None,2317 output_name: None,
2318+ layout_config: None,
2292 },2319 },
2293 Op::AddNamedWorkspace {2320 Op::AddNamedWorkspace {
2294 ws_name: 2,2321 ws_name: 2,
2295 output_name: None,2322 output_name: None,
2323+ layout_config: None,
2296 },2324 },
2297 Op::RemoveOutput(1),2325 Op::RemoveOutput(1),
2298 ];2326 ];
@@ -2655,6 +2683,7 @@ fn named_workspace_to_output() {
2655 Op::AddNamedWorkspace {2683 Op::AddNamedWorkspace {
2656 ws_name: 1,2684 ws_name: 1,
2657 output_name: None,2685 output_name: None,
2686+ layout_config: None,
2658 },2687 },
2659 Op::AddOutput(1),2688 Op::AddOutput(1),
2660 Op::MoveWorkspaceToOutput(1),2689 Op::MoveWorkspaceToOutput(1),
@@ -2670,6 +2699,7 @@ fn named_workspace_to_output_ewaf() {
2670 Op::AddNamedWorkspace {2699 Op::AddNamedWorkspace {
2671 ws_name: 1,2700 ws_name: 1,
2672 output_name: Some(2),2701 output_name: Some(2),
2702+ layout_config: None,
2673 },2703 },
2674 Op::AddOutput(1),2704 Op::AddOutput(1),
2675 Op::AddOutput(2),2705 Op::AddOutput(2),
@@ -2897,6 +2927,65 @@ fn interactive_move_toggle_floating_ends_dnd_gesture() {
2897 check_ops(ops);2927 check_ops(ops);
2898 }2928 }
2899 2929
2930+#[test]
2931+fn interactive_move_from_workspace_with_layout_config() {
2932+ let ops = [
2933+ Op::AddNamedWorkspace {
2934+ ws_name: 1,
2935+ output_name: Some(2),
2936+ layout_config: Some(Box::new(niri_config::LayoutPart {
2937+ border: Some(niri_config::BorderRule {
2938+ on: true,
2939+ ..Default::default()
2940+ }),
2941+ ..Default::default()
2942+ })),
2943+ },
2944+ Op::AddOutput(1),
2945+ Op::AddWindow {
2946+ params: TestWindowParams::new(2),
2947+ },
2948+ Op::InteractiveMoveBegin {
2949+ window: 2,
2950+ output_idx: 1,
2951+ px: 0.0,
2952+ py: 0.0,
2953+ },
2954+ Op::InteractiveMoveUpdate {
2955+ window: 2,
2956+ dx: 0.0,
2957+ dy: 3586.692842955048,
2958+ output_idx: 1,
2959+ px: 0.0,
2960+ py: 0.0,
2961+ },
2962+ // Now remove and add the output. It will have the same workspace.
2963+ Op::RemoveOutput(1),
2964+ Op::AddOutput(1),
2965+ Op::InteractiveMoveUpdate {
2966+ window: 2,
2967+ dx: 0.0,
2968+ dy: 0.0,
2969+ output_idx: 1,
2970+ px: 0.0,
2971+ py: 0.0,
2972+ },
2973+ // Now move onto a different workspace.
2974+ Op::FocusWorkspaceDown,
2975+ Op::CompleteAnimations,
2976+ Op::InteractiveMoveUpdate {
2977+ window: 2,
2978+ dx: 0.0,
2979+ dy: 0.0,
2980+ output_idx: 1,
2981+ px: 0.0,
2982+ py: 0.0,
2983+ },
2984+ ];
2985+
2986+ check_ops(ops);
2987+}
2988+
2900 #[test]2989 #[test]
2901 fn set_width_fixed_negative() {2990 fn set_width_fixed_negative() {
2902 let ops = [2991 let ops = [
src/layout/workspace.rsmodified+42 -8
@@ -99,6 +99,9 @@ pub struct Workspace<W: LayoutElement> {
99 /// Optional name of this workspace.99 /// Optional name of this workspace.
100 pub(super) name: Option<String>,100 pub(super) name: Option<String>,
101 101
102+ /// Layout config overrides for this workspace.
103+ layout_config: Option<niri_config::LayoutPart>,
104+
102 /// Unique ID of this workspace.105 /// Unique ID of this workspace.
103 id: WorkspaceId,106 id: WorkspaceId,
104 }107 }
@@ -202,7 +205,7 @@ impl<W: LayoutElement> Workspace<W> {
202 205
203 pub fn new_with_config(206 pub fn new_with_config(
204 output: Output,207 output: Output,
205- config: Option<WorkspaceConfig>,208+ mut config: Option<WorkspaceConfig>,
206 clock: Clock,209 clock: Clock,
207 base_options: Rc<Options>,210 base_options: Rc<Options>,
208 ) -> Self {211 ) -> Self {
@@ -212,9 +215,14 @@ impl<W: LayoutElement> Workspace<W> {
212 .map(OutputId)215 .map(OutputId)
213 .unwrap_or(OutputId::new(&output));216 .unwrap_or(OutputId::new(&output));
214 217
218+ let layout_config = config.as_mut().and_then(|c| c.layout.take().map(|x| x.0));
219+
215 let scale = output.current_scale();220 let scale = output.current_scale();
216- let options =221+ let options = Rc::new(
217- Rc::new(Options::clone(&base_options).adjusted_for_scale(scale.fractional_scale()));222+ Options::clone(&base_options)
223+ .with_merged_layout(layout_config.as_ref())
224+ .adjusted_for_scale(scale.fractional_scale()),
225+ );
218 226
219 let view_size = output_size(&output);227 let view_size = output_size(&output);
220 let working_area = compute_working_area(&output);228 let working_area = compute_working_area(&output);
@@ -253,12 +261,13 @@ impl<W: LayoutElement> Workspace<W> {
253 base_options,261 base_options,
254 options,262 options,
255 name: config.map(|c| c.name.0),263 name: config.map(|c| c.name.0),
264+ layout_config,
256 id: WorkspaceId::next(),265 id: WorkspaceId::next(),
257 }266 }
258 }267 }
259 268
260 pub fn new_with_config_no_outputs(269 pub fn new_with_config_no_outputs(
261- config: Option<WorkspaceConfig>,270+ mut config: Option<WorkspaceConfig>,
262 clock: Clock,271 clock: Clock,
263 base_options: Rc<Options>,272 base_options: Rc<Options>,
264 ) -> Self {273 ) -> Self {
@@ -269,9 +278,14 @@ impl<W: LayoutElement> Workspace<W> {
269 .unwrap_or_default(),278 .unwrap_or_default(),
270 );279 );
271 280
281+ let layout_config = config.as_mut().and_then(|c| c.layout.take().map(|x| x.0));
282+
272 let scale = smithay::output::Scale::Integer(1);283 let scale = smithay::output::Scale::Integer(1);
273- let options =284+ let options = Rc::new(
274- Rc::new(Options::clone(&base_options).adjusted_for_scale(scale.fractional_scale()));285+ Options::clone(&base_options)
286+ .with_merged_layout(layout_config.as_ref())
287+ .adjusted_for_scale(scale.fractional_scale()),
288+ );
275 289
276 let view_size = Size::from((1280., 720.));290 let view_size = Size::from((1280., 720.));
277 let working_area = Rectangle::from_size(Size::from((1280., 720.)));291 let working_area = Rectangle::from_size(Size::from((1280., 720.)));
@@ -310,6 +324,7 @@ impl<W: LayoutElement> Workspace<W> {
310 base_options,324 base_options,
311 options,325 options,
312 name: config.map(|c| c.name.0),326 name: config.map(|c| c.name.0),
327+ layout_config,
313 id: WorkspaceId::next(),328 id: WorkspaceId::next(),
314 }329 }
315 }330 }
@@ -370,7 +385,11 @@ impl<W: LayoutElement> Workspace<W> {
370 385
371 pub fn update_config(&mut self, base_options: Rc<Options>) {386 pub fn update_config(&mut self, base_options: Rc<Options>) {
372 let scale = self.scale.fractional_scale();387 let scale = self.scale.fractional_scale();
373- let options = Rc::new(Options::clone(&base_options).adjusted_for_scale(scale));388+ let options = Rc::new(
389+ Options::clone(&base_options)
390+ .with_merged_layout(self.layout_config.as_ref())
391+ .adjusted_for_scale(scale),
392+ );
374 393
375 self.scrolling.update_config(394 self.scrolling.update_config(
376 self.view_size,395 self.view_size,
@@ -394,6 +413,15 @@ impl<W: LayoutElement> Workspace<W> {
394 self.options = options;413 self.options = options;
395 }414 }
396 415
416+ pub fn update_layout_config(&mut self, layout_config: Option<niri_config::LayoutPart>) {
417+ if self.layout_config == layout_config {
418+ return;
419+ }
420+
421+ self.layout_config = layout_config;
422+ self.update_config(self.base_options.clone());
423+ }
424+
397 pub fn update_shaders(&mut self) {425 pub fn update_shaders(&mut self) {
398 self.scrolling.update_shaders();426 self.scrolling.update_shaders();
399 self.floating.update_shaders();427 self.floating.update_shaders();
@@ -1770,6 +1798,10 @@ impl<W: LayoutElement> Workspace<W> {
1770 self.working_area1798 self.working_area
1771 }1799 }
1772 1800
1801+ pub fn layout_config(&self) -> Option<&niri_config::LayoutPart> {
1802+ self.layout_config.as_ref()
1803+ }
1804+
1773 #[cfg(test)]1805 #[cfg(test)]
1774 pub fn scrolling(&self) -> &ScrollingSpace<W> {1806 pub fn scrolling(&self) -> &ScrollingSpace<W> {
1775 &self.scrolling1807 &self.scrolling
@@ -1788,7 +1820,9 @@ impl<W: LayoutElement> Workspace<W> {
1788 assert!(scale > 0.);1820 assert!(scale > 0.);
1789 assert!(scale.is_finite());1821 assert!(scale.is_finite());
1790 1822
1791- let options = Options::clone(&self.base_options).adjusted_for_scale(scale);1823+ let options = Options::clone(&self.base_options)
1824+ .with_merged_layout(self.layout_config.as_ref())
1825+ .adjusted_for_scale(scale);
1792 assert_eq!(1826 assert_eq!(
1793 &*self.options, &options,1827 &*self.options, &options,
1794 "options must be base options adjusted for scale"1828 "options must be base options adjusted for scale"