From 74d1b1f40620a42c92c71ddfec658dc6b2de0dd7 Mon Sep 17 00:00:00 2001 From: Ivan Molodetskikh Date: Wed, 28 Aug 2024 10:35:02 +0300 Subject: layout: Cache monitor output name --- src/layout/monitor.rs | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src/layout/monitor.rs') 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] } -- cgit