Use keyboard focus target rather than focus_stack in keybindings

`Action::Close` already used the keyboard focus target, but some other
bindings didn't. Presumably it's most intuitive if all "current window"
key bindings affect the window with keyboard focus.

These used the focus stack on the `focused_output()` (the one with
keyboard focus), so I guess the main impact is when the keyboard target
is a window being dragged? Then the binding will operate on that window,
or have no effect.

This seems related to some of the behaviors discussed in
https://github.com/pop-os/cosmic-comp/issues/453.
This commit is contained in:
Ian Douglas Scott 2025-10-01 13:40:39 -07:00 committed by Ian Douglas Scott
parent 12857672f6
commit e09fcec9f3
3 changed files with 23 additions and 24 deletions

View file

@ -220,6 +220,14 @@ impl KeyboardFocusTarget {
}
}
pub fn active_window(&self) -> Option<CosmicSurface> {
match self {
KeyboardFocusTarget::Element(mapped) => Some(mapped.active_window()),
KeyboardFocusTarget::Fullscreen(surface) => Some(surface.clone()),
_ => None,
}
}
fn x11_surface(&self) -> Option<X11Surface> {
match self {
KeyboardFocusTarget::Element(mapped) => mapped.active_window().x11_surface().cloned(),