Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

xdg-activation: Switch stack focus #223

Merged
merged 1 commit into from
Nov 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/shell/element/surface.rs
Original file line number Diff line number Diff line change
Expand Up @@ -584,7 +584,7 @@ impl CosmicSurface {

pub fn with_surfaces<F>(&self, processor: F)
where
F: FnMut(&WlSurface, &SurfaceData) + Copy,
F: FnMut(&WlSurface, &SurfaceData),
{
match self {
CosmicSurface::Wayland(window) => window.with_surfaces(processor),
Expand Down
10 changes: 6 additions & 4 deletions src/shell/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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) => {
Expand Down
14 changes: 14 additions & 0 deletions src/wayland/handlers/xdg_activation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 == &current_workspace.handle {
Shell::set_focus(self, Some(&target), &seat, None);
Expand Down