mirror of
https://github.com/LGUG2Z/komorebi.git
synced 2026-07-11 07:32:51 +02:00
refactor(wm): store config on workspace
Store the `WorkspaceConfig` on the `Workspace` itself so that when we want to cache the workspace as `WorkspaceConfig` on the monitor cache it properly saves things like the workspace rules and the custom layout and custom layout rules.
This commit is contained in:
@@ -206,7 +206,6 @@ impl From<&Workspace> for WorkspaceConfig {
|
|||||||
.name()
|
.name()
|
||||||
.clone()
|
.clone()
|
||||||
.unwrap_or_else(|| String::from("unnamed")),
|
.unwrap_or_else(|| String::from("unnamed")),
|
||||||
custom_layout: None,
|
|
||||||
layout: value
|
layout: value
|
||||||
.tile()
|
.tile()
|
||||||
.then_some(match value.layout() {
|
.then_some(match value.layout() {
|
||||||
@@ -214,13 +213,25 @@ impl From<&Workspace> for WorkspaceConfig {
|
|||||||
Layout::Custom(_) => None,
|
Layout::Custom(_) => None,
|
||||||
})
|
})
|
||||||
.flatten(),
|
.flatten(),
|
||||||
|
custom_layout: value
|
||||||
|
.workspace_config()
|
||||||
|
.as_ref()
|
||||||
|
.and_then(|c| c.custom_layout.clone()),
|
||||||
layout_rules: Option::from(layout_rules),
|
layout_rules: Option::from(layout_rules),
|
||||||
// TODO: figure out how we might resolve file references in the future
|
custom_layout_rules: value
|
||||||
custom_layout_rules: None,
|
.workspace_config()
|
||||||
|
.as_ref()
|
||||||
|
.and_then(|c| c.custom_layout_rules.clone()),
|
||||||
container_padding,
|
container_padding,
|
||||||
workspace_padding,
|
workspace_padding,
|
||||||
initial_workspace_rules: None,
|
initial_workspace_rules: value
|
||||||
workspace_rules: None,
|
.workspace_config()
|
||||||
|
.as_ref()
|
||||||
|
.and_then(|c| c.initial_workspace_rules.clone()),
|
||||||
|
workspace_rules: value
|
||||||
|
.workspace_config()
|
||||||
|
.as_ref()
|
||||||
|
.and_then(|c| c.workspace_rules.clone()),
|
||||||
apply_window_based_work_area_offset: Some(value.apply_window_based_work_area_offset()),
|
apply_window_based_work_area_offset: Some(value.apply_window_based_work_area_offset()),
|
||||||
window_container_behaviour: *value.window_container_behaviour(),
|
window_container_behaviour: *value.window_container_behaviour(),
|
||||||
window_container_behaviour_rules: Option::from(window_container_behaviour_rules),
|
window_container_behaviour_rules: Option::from(window_container_behaviour_rules),
|
||||||
|
|||||||
@@ -92,6 +92,8 @@ pub struct Workspace {
|
|||||||
window_container_behaviour_rules: Option<Vec<(usize, WindowContainerBehaviour)>>,
|
window_container_behaviour_rules: Option<Vec<(usize, WindowContainerBehaviour)>>,
|
||||||
#[getset(get = "pub", get_mut = "pub", set = "pub")]
|
#[getset(get = "pub", get_mut = "pub", set = "pub")]
|
||||||
float_override: Option<bool>,
|
float_override: Option<bool>,
|
||||||
|
#[getset(get = "pub", set = "pub")]
|
||||||
|
workspace_config: Option<WorkspaceConfig>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl_ring_elements!(Workspace, Container);
|
impl_ring_elements!(Workspace, Container);
|
||||||
@@ -118,6 +120,7 @@ impl Default for Workspace {
|
|||||||
window_container_behaviour: None,
|
window_container_behaviour: None,
|
||||||
window_container_behaviour_rules: None,
|
window_container_behaviour_rules: None,
|
||||||
float_override: None,
|
float_override: None,
|
||||||
|
workspace_config: None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -209,6 +212,8 @@ impl Workspace {
|
|||||||
self.set_float_override(config.float_override);
|
self.set_float_override(config.float_override);
|
||||||
self.set_layout_flip(config.layout_flip);
|
self.set_layout_flip(config.layout_flip);
|
||||||
|
|
||||||
|
self.set_workspace_config(Some(config.clone()));
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user