mirror of
https://github.com/pinnacle-comp/pinnacle.git
synced 2025-01-29 20:34:46 +01:00
Update focus on xwayland window destroy
This commit is contained in:
parent
f811771fbe
commit
f8fcfcd8ce
1 changed files with 37 additions and 0 deletions
|
@ -183,6 +183,10 @@ impl XwmHandler for CalloopData {
|
|||
|
||||
fn unmapped_window(&mut self, _xwm: XwmId, window: X11Surface) {
|
||||
tracing::debug!("UNMAPPED WINDOW");
|
||||
self.state.focus_state.focus_stack.retain(|win| {
|
||||
win.wl_surface()
|
||||
.is_some_and(|surf| Some(surf) != window.wl_surface())
|
||||
});
|
||||
let win = self
|
||||
.state
|
||||
.space
|
||||
|
@ -191,6 +195,22 @@ impl XwmHandler for CalloopData {
|
|||
.cloned();
|
||||
if let Some(win) = win {
|
||||
self.state.space.unmap_elem(&win);
|
||||
if let Some(output) = win.output(&self.state) {
|
||||
self.state.update_windows(&output);
|
||||
let focus = self.state.current_focus(&output).map(FocusTarget::Window);
|
||||
if let Some(FocusTarget::Window(win)) = &focus {
|
||||
tracing::debug!("Focusing on prev win");
|
||||
self.state.space.raise_element(win, true);
|
||||
if let WindowElement::Wayland(win) = &win {
|
||||
win.toplevel().send_configure();
|
||||
}
|
||||
}
|
||||
self.state
|
||||
.seat
|
||||
.get_keyboard()
|
||||
.expect("Seat had no keyboard")
|
||||
.set_focus(&mut self.state, focus, SERIAL_COUNTER.next_serial());
|
||||
}
|
||||
}
|
||||
if !window.is_override_redirect() {
|
||||
tracing::debug!("set mapped to false");
|
||||
|
@ -199,6 +219,10 @@ impl XwmHandler for CalloopData {
|
|||
}
|
||||
|
||||
fn destroyed_window(&mut self, _xwm: XwmId, window: X11Surface) {
|
||||
self.state.focus_state.focus_stack.retain(|win| {
|
||||
win.wl_surface()
|
||||
.is_some_and(|surf| Some(surf) != window.wl_surface())
|
||||
});
|
||||
let win = self
|
||||
.state
|
||||
.windows
|
||||
|
@ -216,6 +240,19 @@ impl XwmHandler for CalloopData {
|
|||
|
||||
if let Some(output) = win.output(&self.state) {
|
||||
self.state.update_windows(&output);
|
||||
let focus = self.state.current_focus(&output).map(FocusTarget::Window);
|
||||
if let Some(FocusTarget::Window(win)) = &focus {
|
||||
tracing::debug!("Focusing on prev win");
|
||||
self.state.space.raise_element(win, true);
|
||||
if let WindowElement::Wayland(win) = &win {
|
||||
win.toplevel().send_configure();
|
||||
}
|
||||
}
|
||||
self.state
|
||||
.seat
|
||||
.get_keyboard()
|
||||
.expect("Seat had no keyboard")
|
||||
.set_focus(&mut self.state, focus, SERIAL_COUNTER.next_serial());
|
||||
}
|
||||
}
|
||||
tracing::debug!("destroyed x11 window");
|
||||
|
|
Loading…
Add table
Reference in a new issue