tiling: Add proper output_enter/leave events

This commit is contained in:
Victoria Brekenfeld 2022-11-14 11:54:22 +01:00
parent 77858d3628
commit 7e45e51781
3 changed files with 90 additions and 60 deletions

View file

@ -55,6 +55,12 @@ pub struct Workspace {
#[derive(Debug, Default)]
pub struct FocusStacks(HashMap<Seat<State>, IndexSet<CosmicMapped>>);
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub enum ManagedState {
Tiling,
Floating,
}
impl Workspace {
pub fn new(handle: WorkspaceHandle) -> Workspace {
Workspace {
@ -100,6 +106,25 @@ impl Workspace {
self.refresh();
}
pub fn unmap(&mut self, mapped: &CosmicMapped) -> Option<ManagedState> {
let was_floating = self.floating_layer.unmap(&mapped);
let was_tiling = self.tiling_layer.unmap(&mapped).is_some();
if was_floating || was_tiling {
assert!(was_floating != was_tiling);
}
self.focus_stack
.0
.values_mut()
.for_each(|set| set.retain(|m| m != mapped));
if was_floating {
Some(ManagedState::Floating)
} else if was_tiling {
Some(ManagedState::Tiling)
} else {
None
}
}
pub fn element_for_surface(&self, surface: &WlSurface) -> Option<&CosmicMapped> {
self.floating_layer
.mapped()