diff --git a/src/shell/element/surface.rs b/src/shell/element/surface.rs index 99ccbef5..68dfda38 100644 --- a/src/shell/element/surface.rs +++ b/src/shell/element/surface.rs @@ -584,7 +584,7 @@ impl CosmicSurface { pub fn with_surfaces(&self, processor: F) where - F: FnMut(&WlSurface, &SurfaceData) + Copy, + F: FnMut(&WlSurface, &SurfaceData), { match self { CosmicSurface::Wayland(window) => window.with_surfaces(processor), diff --git a/src/shell/mod.rs b/src/shell/mod.rs index d315adbb..3c3f7750 100644 --- a/src/shell/mod.rs +++ b/src/shell/mod.rs @@ -2,7 +2,7 @@ use calloop::LoopHandle; use indexmap::IndexMap; use std::{ collections::HashMap, - sync::atomic::{AtomicBool, Ordering}, + sync::atomic::Ordering, time::{Duration, Instant}, }; use wayland_backend::server::ClientId; @@ -1024,11 +1024,13 @@ impl Shell { }) .or_else(|| { self.pending_layers.iter().find_map(|(l, output, _)| { - let found = AtomicBool::new(false); + let mut found = false; l.with_surfaces(|s, _| { - found.fetch_or(s == surface, Ordering::SeqCst); + if s == surface { + found = true; + } }); - found.load(Ordering::SeqCst).then_some(output) + found.then_some(output) }) }) { Some(output) => { diff --git a/src/wayland/handlers/xdg_activation.rs b/src/wayland/handlers/xdg_activation.rs index e76c5856..88736021 100644 --- a/src/wayland/handlers/xdg_activation.rs +++ b/src/wayland/handlers/xdg_activation.rs @@ -128,6 +128,20 @@ impl XdgActivationHandler for State { .raise_element(&element, true); } + if element.is_stack() { + if let Some((window, _)) = element.windows().find(|(window, _)| { + let mut found = false; + window.with_surfaces(|wl_surface, _| { + if wl_surface == &surface { + found = true; + } + }); + found + }) { + element.set_active(&window); + } + } + let target = element.into(); if workspace == ¤t_workspace.handle { Shell::set_focus(self, Some(&target), &seat, None);