Skip to content

Commit

Permalink
focus: Don't sort children behind their parents
Browse files Browse the repository at this point in the history
  • Loading branch information
Drakulix committed Sep 20, 2023
1 parent 4709a1d commit de83185
Showing 1 changed file with 26 additions and 4 deletions.
30 changes: 26 additions & 4 deletions src/shell/focus/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,14 @@ use smithay::{
desktop::{layer_map_for_output, PopupUngrabStrategy},
input::Seat,
utils::{IsAlive, Serial, SERIAL_COUNTER},
wayland::seat::WaylandFocus,
};
use std::cell::RefCell;
use tracing::{debug, trace};

use self::target::{KeyboardFocusTarget, WindowGroup};

use super::CosmicSurface;
use super::{layout::floating::FloatingLayout, CosmicSurface};

pub mod target;

Expand Down Expand Up @@ -170,9 +171,7 @@ impl Shell {
let _ = xwm.raise_window(&window);
}
}
if workspace.floating_layer.mapped().any(|m| m == focused) {
workspace.floating_layer.space.raise_element(focused, true);
}
raise_with_children(&mut workspace.floating_layer, focused);
}
for window in workspace.mapped() {
window.set_activated(focused_windows.contains(&window));
Expand All @@ -182,6 +181,29 @@ impl Shell {
}
}

fn raise_with_children(floating_layer: &mut FloatingLayout, focused: &CosmicMapped) {
if floating_layer.mapped().any(|m| m == focused) {
floating_layer.space.raise_element(focused, true);
for element in floating_layer
.space
.elements()
.filter(|elem| {
let parent = match elem.active_window() {
CosmicSurface::Wayland(w) => w.toplevel().parent(),
_ => None,
};

parent == focused.active_window().wl_surface()
})
.cloned()
.collect::<Vec<_>>()
.into_iter()
{
raise_with_children(floating_layer, &element);
}
}
}

impl Common {
pub fn set_focus(
state: &mut State,
Expand Down

0 comments on commit de83185

Please sign in to comment.