diff options
| author | Ivan Molodetskikh <yalterz@gmail.com> | 2024-05-16 10:54:24 +0400 |
|---|---|---|
| committer | Ivan Molodetskikh <yalterz@gmail.com> | 2024-05-16 01:24:34 -0700 |
| commit | 109d99fe82205b144e68e4571140d32d28db2597 (patch) | |
| tree | 0db664a2d0e65103b0d1125003aca381bcf93d8e /src/layout/monitor.rs | |
| parent | eb9bbe3352820754a4ee3c19f15cff690d1c193d (diff) | |
| download | niri-109d99fe82205b144e68e4571140d32d28db2597.tar.gz niri-109d99fe82205b144e68e4571140d32d28db2597.tar.bz2 niri-109d99fe82205b144e68e4571140d32d28db2597.zip | |
Make workspace names case-insensitive
Diffstat (limited to 'src/layout/monitor.rs')
| -rw-r--r-- | src/layout/monitor.rs | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/src/layout/monitor.rs b/src/layout/monitor.rs index 9dcc552e..c56146a4 100644 --- a/src/layout/monitor.rs +++ b/src/layout/monitor.rs @@ -104,15 +104,19 @@ impl<W: LayoutElement> Monitor<W> { } pub fn find_named_workspace(&self, workspace_name: &str) -> Option<&Workspace<W>> { - self.workspaces - .iter() - .find(|w| w.name.as_deref() == Some(workspace_name)) + self.workspaces.iter().find(|ws| { + ws.name + .as_ref() + .map_or(false, |name| name.eq_ignore_ascii_case(workspace_name)) + }) } pub fn find_named_workspace_index(&self, workspace_name: &str) -> Option<usize> { - self.workspaces - .iter() - .position(|w| w.name.as_deref() == Some(workspace_name)) + self.workspaces.iter().position(|ws| { + ws.name + .as_ref() + .map_or(false, |name| name.eq_ignore_ascii_case(workspace_name)) + }) } pub fn active_workspace(&mut self) -> &mut Workspace<W> { @@ -227,7 +231,11 @@ impl<W: LayoutElement> Monitor<W> { pub fn unname_workspace(&mut self, workspace_name: &str) -> bool { for ws in &mut self.workspaces { - if ws.name.as_deref() == Some(workspace_name) { + if ws + .name + .as_ref() + .map_or(false, |name| name.eq_ignore_ascii_case(workspace_name)) + { ws.unname(); return true; } |
