mirror of
https://github.com/marcoallegretti/WEFT_OS.git
synced 2026-11-22 08:13:59 +00:00
fix(compositor): hand focus on when a registering panel is lowered
A shell restarted while applications run took keyboard focus before it registered as the panel and kept it after being lowered beneath them; the window in front now gets it. Without an output, windows are still reordered, so a window that maps without taking focus does not cover the one in front.
This commit is contained in:
parent
cdc4a9e15d
commit
c8bae1cc4d
2 changed files with 30 additions and 12 deletions
|
|
@ -661,7 +661,8 @@ impl Dispatch<ZweftShellWindowV1, WeftShellWindowData> for WeftCompositorState {
|
||||||
) {
|
) {
|
||||||
// A panel that goes away, by destroy or with its client, releases
|
// A panel that goes away, by destroy or with its client, releases
|
||||||
// its reserved strip and its window slot; applications take the
|
// its reserved strip and its window slot; applications take the
|
||||||
// space back.
|
// space back. The surface's window is not mapped again if it
|
||||||
|
// registers once more.
|
||||||
if state.weft_shell_state.remove_panel(resource) {
|
if state.weft_shell_state.remove_panel(resource) {
|
||||||
if let Some(surface) = &data.surface {
|
if let Some(surface) = &data.surface {
|
||||||
state.window_closed(surface);
|
state.window_closed(surface);
|
||||||
|
|
|
||||||
|
|
@ -6,8 +6,9 @@
|
||||||
//! panel reserves. A session's first window, a clicked window (the panel
|
//! panel reserves. A session's first window, a clicked window (the panel
|
||||||
//! included, which then shows the shell's home over the applications) and
|
//! included, which then shows the shell's home over the applications) and
|
||||||
//! one appd asks to activate is raised to the top, marked activated and
|
//! one appd asks to activate is raised to the top, marked activated and
|
||||||
//! given keyboard focus; nothing else changes the order, and a window that
|
//! given keyboard focus; apart from a panel being lowered when it
|
||||||
//! maps without taking focus goes beneath the window in front. When the
|
//! registers, nothing else changes the order, and a window that maps
|
||||||
|
//! without taking focus goes beneath the window in front. When the
|
||||||
//! focused window closes, the topmost remaining application window gets
|
//! focused window closes, the topmost remaining application window gets
|
||||||
//! focus.
|
//! focus.
|
||||||
|
|
||||||
|
|
@ -79,6 +80,21 @@ impl WeftCompositorState {
|
||||||
/// application window; used when a panel registers.
|
/// application window; used when a panel registers.
|
||||||
pub fn fit_panels(&mut self) {
|
pub fn fit_panels(&mut self) {
|
||||||
self.place_windows(true, None);
|
self.place_windows(true, None);
|
||||||
|
// A shell that took focus before registering as the panel, such as
|
||||||
|
// one restarted while applications run, hands it to the window that
|
||||||
|
// is now in front.
|
||||||
|
let focus_on_panel = self
|
||||||
|
.seat
|
||||||
|
.get_keyboard()
|
||||||
|
.and_then(|keyboard| keyboard.current_focus())
|
||||||
|
.is_some_and(|focus| self.is_panel_surface(&focus));
|
||||||
|
let front = self.space.elements().last().cloned();
|
||||||
|
if focus_on_panel
|
||||||
|
&& let Some(front) = front
|
||||||
|
&& !self.is_panel(&front)
|
||||||
|
{
|
||||||
|
self.activate_window(&front);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Places every window for the current output and reservations: panels
|
/// Places every window for the current output and reservations: panels
|
||||||
|
|
@ -87,17 +103,14 @@ impl WeftCompositorState {
|
||||||
/// the applications, and `below_top` slips that window under the
|
/// the applications, and `below_top` slips that window under the
|
||||||
/// window that was on top.
|
/// window that was on top.
|
||||||
pub fn place_windows(&mut self, lower_panels: bool, below_top: Option<&Window>) {
|
pub fn place_windows(&mut self, lower_panels: bool, below_top: Option<&Window>) {
|
||||||
let Some(output) = self
|
// Without an output the order still changes; windows keep their
|
||||||
|
// size and place until one is mapped.
|
||||||
|
let output = self
|
||||||
.space
|
.space
|
||||||
.outputs()
|
.outputs()
|
||||||
.next()
|
.next()
|
||||||
.and_then(|output| self.space.output_geometry(output))
|
.and_then(|output| self.space.output_geometry(output));
|
||||||
else {
|
let area = self.work_area();
|
||||||
return;
|
|
||||||
};
|
|
||||||
let Some(area) = self.work_area() else {
|
|
||||||
return;
|
|
||||||
};
|
|
||||||
let mut order: Vec<Window> = self.space.elements().cloned().collect();
|
let mut order: Vec<Window> = self.space.elements().cloned().collect();
|
||||||
if lower_panels {
|
if lower_panels {
|
||||||
let (panels, apps): (Vec<Window>, Vec<Window>) =
|
let (panels, apps): (Vec<Window>, Vec<Window>) =
|
||||||
|
|
@ -113,7 +126,11 @@ impl WeftCompositorState {
|
||||||
}
|
}
|
||||||
for window in &order {
|
for window in &order {
|
||||||
let panel = self.is_panel(window);
|
let panel = self.is_panel(window);
|
||||||
let geometry = if panel { output } else { area };
|
let Some(geometry) = (if panel { output } else { area }) else {
|
||||||
|
let location = self.space.element_location(window).unwrap_or_default();
|
||||||
|
self.space.map_element(window.clone(), location, false);
|
||||||
|
continue;
|
||||||
|
};
|
||||||
if let Some(toplevel) = window.toplevel() {
|
if let Some(toplevel) = window.toplevel() {
|
||||||
toplevel.with_pending_state(|state| {
|
toplevel.with_pending_state(|state| {
|
||||||
state.size = Some(geometry.size);
|
state.size = Some(geometry.size);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue