diff options
| author | Ivan Molodetskikh <yalterz@gmail.com> | 2024-08-28 10:35:02 +0300 |
|---|---|---|
| committer | Ivan Molodetskikh <yalterz@gmail.com> | 2024-09-01 23:47:19 -0700 |
| commit | 74d1b1f40620a42c92c71ddfec658dc6b2de0dd7 (patch) | |
| tree | 74cad375d96bb9e7c9f1245c8017d363841b4c11 /src/layout | |
| parent | 2b3d196876c6528be97f6a7e2a31539c25d2b1e6 (diff) | |
| download | niri-74d1b1f40620a42c92c71ddfec658dc6b2de0dd7.tar.gz niri-74d1b1f40620a42c92c71ddfec658dc6b2de0dd7.tar.bz2 niri-74d1b1f40620a42c92c71ddfec658dc6b2de0dd7.zip | |
layout: Cache monitor output name
Diffstat (limited to 'src/layout')
| -rw-r--r-- | src/layout/mod.rs | 2 | ||||
| -rw-r--r-- | src/layout/monitor.rs | 7 |
2 files changed, 8 insertions, 1 deletions
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<W: LayoutElement> Layout<W> { .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<W: LayoutElement> { /// Output for this monitor. pub output: Output, + /// Cached name of the output. + output_name: String, // Must always contain at least one. pub workspaces: Vec<Workspace<W>>, /// Index of the currently active workspace. @@ -93,6 +95,7 @@ impl WorkspaceSwitch { impl<W: LayoutElement> Monitor<W> { pub fn new(output: Output, workspaces: Vec<Workspace<W>>, options: Rc<Options>) -> Self { Self { + output_name: output.name(), output, workspaces, active_workspace_idx: 0, @@ -102,6 +105,10 @@ impl<W: LayoutElement> Monitor<W> { } } + pub fn output_name(&self) -> &String { + &self.output_name + } + pub fn active_workspace_ref(&self) -> &Workspace<W> { &self.workspaces[self.active_workspace_idx] } |
