diff --git a/src/shell/focus/mod.rs b/src/shell/focus/mod.rs index 916b2493..6b8830d5 100644 --- a/src/shell/focus/mod.rs +++ b/src/shell/focus/mod.rs @@ -17,7 +17,7 @@ use smithay::{ shell::wlr_layer::{KeyboardInteractivity, Layer}, }, }; -use std::{borrow::Cow, mem, sync::Mutex}; +use std::{borrow::Cow, hash::Hash, mem, sync::Mutex}; use tracing::{debug, trace}; @@ -47,6 +47,18 @@ impl PartialEq for FocusTarget { } } +impl indexmap::Equivalent for CosmicMapped { + fn equivalent(&self, key: &FocusTarget) -> bool { + key == self + } +} + +impl indexmap::Equivalent for CosmicSurface { + fn equivalent(&self, key: &FocusTarget) -> bool { + key == self + } +} + impl From for FocusTarget { fn from(value: CosmicMapped) -> Self { Self::Window(value) @@ -119,9 +131,9 @@ impl FocusStackMut<'_> { pub fn remove(&mut self, target: &T) where - FocusTarget: PartialEq, + T: Hash + indexmap::Equivalent, { - self.0.retain(|w| w != target); + self.0.shift_remove(target); } pub fn last(&self) -> Option<&FocusTarget> {