diff --git a/src/layout/mod.rs b/src/layout/mod.rs index 2b684ddf..6407c7a1 100644 --- a/src/layout/mod.rs +++ b/src/layout/mod.rs @@ -1854,7 +1854,7 @@ impl Layout { .map(|name| { monitors .iter_mut() - .position(|monitor| monitor.output.name().eq_ignore_ascii_case(name)) + .position(|monitor| monitor.output_name().eq_ignore_ascii_case(name)) .unwrap_or(*primary_idx) }) .unwrap_or(*active_monitor_idx); diff --git a/src/layout/monitor.rs b/src/layout/monitor.rs index 07223521..df63a189 100644 --- a/src/layout/monitor.rs +++ b/src/layout/monitor.rs @@ -34,6 +34,8 @@ const WORKSPACE_GESTURE_RUBBER_BAND: RubberBand = RubberBand { pub struct Monitor { /// Output for this monitor. pub output: Output, + /// Cached name of the output. + output_name: String, // Must always contain at least one. pub workspaces: Vec>, /// Index of the currently active workspace. @@ -93,6 +95,7 @@ impl WorkspaceSwitch { impl Monitor { pub fn new(output: Output, workspaces: Vec>, options: Rc) -> Self { Self { + output_name: output.name(), output, workspaces, active_workspace_idx: 0, @@ -102,6 +105,10 @@ impl Monitor { } } + pub fn output_name(&self) -> &String { + &self.output_name + } + pub fn active_workspace_ref(&self) -> &Workspace { &self.workspaces[self.active_workspace_idx] }