forge
Explore
Log in

Don't you dare go Hollow

layout: Cache monitor output name

Browse files at this commit

74d1b1f40620a42c92c71ddfec658dc6b2de0dd7Ivan MolodetskikhParent: 2b3d196
src/layout/mod.rsmodified+1 -1
@@ -1854,7 +1854,7 @@ impl<W: LayoutElement> Layout<W> {
1854 .map(|name| {1854 .map(|name| {
1855 monitors1855 monitors
1856 .iter_mut()1856 .iter_mut()
1857- .position(|monitor| monitor.output.name().eq_ignore_ascii_case(name))1857+ .position(|monitor| monitor.output_name().eq_ignore_ascii_case(name))
1858 .unwrap_or(*primary_idx)1858 .unwrap_or(*primary_idx)
1859 })1859 })
1860 .unwrap_or(*active_monitor_idx);1860 .unwrap_or(*active_monitor_idx);
src/layout/monitor.rsmodified+7 -0
@@ -34,6 +34,8 @@ const WORKSPACE_GESTURE_RUBBER_BAND: RubberBand = RubberBand {
34 pub struct Monitor<W: LayoutElement> {34 pub struct Monitor<W: LayoutElement> {
35 /// Output for this monitor.35 /// Output for this monitor.
36 pub output: Output,36 pub output: Output,
37+ /// Cached name of the output.
38+ output_name: String,
37 // Must always contain at least one.39 // Must always contain at least one.
38 pub workspaces: Vec<Workspace<W>>,40 pub workspaces: Vec<Workspace<W>>,
39 /// Index of the currently active workspace.41 /// Index of the currently active workspace.
@@ -93,6 +95,7 @@ impl WorkspaceSwitch {
93 impl<W: LayoutElement> Monitor<W> {95 impl<W: LayoutElement> Monitor<W> {
94 pub fn new(output: Output, workspaces: Vec<Workspace<W>>, options: Rc<Options>) -> Self {96 pub fn new(output: Output, workspaces: Vec<Workspace<W>>, options: Rc<Options>) -> Self {
95 Self {97 Self {
98+ output_name: output.name(),
96 output,99 output,
97 workspaces,100 workspaces,
98 active_workspace_idx: 0,101 active_workspace_idx: 0,
@@ -102,6 +105,10 @@ impl<W: LayoutElement> Monitor<W> {
102 }105 }
103 }106 }
104 107
108+ pub fn output_name(&self) -> &String {
109+ &self.output_name
110+ }
111+
105 pub fn active_workspace_ref(&self) -> &Workspace<W> {112 pub fn active_workspace_ref(&self) -> &Workspace<W> {
106 &self.workspaces[self.active_workspace_idx]113 &self.workspaces[self.active_workspace_idx]
107 }114 }