GlazeWM is a tiling window manager for macOS and Windows inspired by i3wm.
fix: get correct workspace config on activate
Lars Bergera89070eaf5bb
diff --git a/packages/wm/src/user_config.rs b/packages/wm/src/user_config.rsindex 6f42ffb7..8bd868a7 100644--- a/packages/wm/src/user_config.rs+++ b/packages/wm/src/user_config.rs@@ -80,12 +80,11 @@ impl UserConfig {Ok(())}- pub fn workspace_config_for_monitor(+ pub fn inactive_workspace_configs(&self,- monitor: &Monitor,active_workspaces: &Vec<Workspace>,- ) -> Option<WorkspaceConfig> {- let inactive_configs = self+ ) -> Vec<&WorkspaceConfig> {+ self.value.workspaces.iter()@@ -95,7 +94,16 @@ impl UserConfig {.find(|workspace| workspace.config().name == config.name).is_none()})- .collect::<Vec<_>>();+ .collect()+ }++ pub fn workspace_config_for_monitor(+ &self,+ monitor: &Monitor,+ active_workspaces: &Vec<Workspace>,+ ) -> Option<&WorkspaceConfig> {+ let inactive_configs =+ self.inactive_workspace_configs(active_workspaces);let bound_config = inactive_configs.iter().find(|&config| {config@@ -116,7 +124,6 @@ impl UserConfig {).or(inactive_configs.first()).cloned()- .cloned()}}diff --git a/packages/wm/src/workspaces/commands/activate_workspace.rs b/packages/wm/src/workspaces/commands/activate_workspace.rsindex fd963944..2205ef00 100644--- a/packages/wm/src/workspaces/commands/activate_workspace.rs+++ b/packages/wm/src/workspaces/commands/activate_workspace.rs@@ -21,7 +21,7 @@ pub fn activate_workspace(config: &UserConfig,) -> anyhow::Result<()> {let workspace_config =- get_workspace_config(workspace_name, target_monitor, state, config)?;+ workspace_config(workspace_name, target_monitor, state, config)?;let tiling_direction =match target_monitor.height()? > target_monitor.width()? {@@ -30,7 +30,7 @@ pub fn activate_workspace(};let workspace = Workspace::new(- workspace_config,+ workspace_config.clone(),config.value.gaps.outer_gap.clone(),tiling_direction,);@@ -49,7 +49,8 @@ pub fn activate_workspace(Ok(())}-fn get_workspace_config(+/// Gets config for the workspace to activate.+fn workspace_config(workspace_name: Option<String>,target_monitor: &Monitor,state: &mut WmState,@@ -57,23 +58,22 @@ fn get_workspace_config() -> anyhow::Result<WorkspaceConfig> {match workspace_name {Some(workspace_name) => {- let found_config = state- .workspaces()- .iter()- .find(|w| w.config().name == workspace_name)+ let found_config = config+ .inactive_workspace_configs(&state.workspaces())+ .into_iter()+ .find(|config| config.name == workspace_name).with_context(|| {format!("Workspace with name {} doesn't exist.", workspace_name)- })?- .config();+ })?;- Ok(found_config)+ Ok(found_config.clone())}None => {let inactive_config = config.workspace_config_for_monitor(&target_monitor, &state.workspaces()).context("No workspace config found for monitor.")?;- Ok(inactive_config)+ Ok(inactive_config.clone())}}}