From 2bf769ac3287ff2916427878222a62340191b441 Mon Sep 17 00:00:00 2001 From: Victoria Brekenfeld Date: Tue, 27 Feb 2024 14:19:59 +0100 Subject: [PATCH] stacks: Better handle minimize/unminimize of specific surface --- src/wayland/handlers/toplevel_management.rs | 9 +++++++-- src/wayland/handlers/xdg_shell/mod.rs | 6 +++++- src/xwayland.rs | 14 +++++++++++--- 3 files changed, 23 insertions(+), 6 deletions(-) diff --git a/src/wayland/handlers/toplevel_management.rs b/src/wayland/handlers/toplevel_management.rs index 92667de2..38260d69 100644 --- a/src/wayland/handlers/toplevel_management.rs +++ b/src/wayland/handlers/toplevel_management.rs @@ -186,14 +186,19 @@ impl ToplevelManagementHandler for State { fn minimize(&mut self, _dh: &DisplayHandle, window: &::Window) { if let Some(mapped) = self.common.shell.element_for_surface(window).cloned() { - self.common.shell.minimize_request(&mapped); + if !mapped.is_stack() || &mapped.active_window() == window { + self.common.shell.minimize_request(&mapped); + } } } fn unminimize(&mut self, _dh: &DisplayHandle, window: &::Window) { - if let Some(mapped) = self.common.shell.element_for_surface(window).cloned() { + if let Some(mut mapped) = self.common.shell.element_for_surface(window).cloned() { let seat = self.common.last_active_seat().clone(); self.common.shell.unminimize_request(&mapped, &seat); + if mapped.is_stack() { + mapped.stack_ref_mut().unwrap().set_active(window); + } } } } diff --git a/src/wayland/handlers/xdg_shell/mod.rs b/src/wayland/handlers/xdg_shell/mod.rs index e874b926..e779c50c 100644 --- a/src/wayland/handlers/xdg_shell/mod.rs +++ b/src/wayland/handlers/xdg_shell/mod.rs @@ -172,7 +172,11 @@ impl XdgShellHandler for State { .element_for_wl_surface(surface.wl_surface()) .cloned() { - self.common.shell.minimize_request(&mapped) + if !mapped.is_stack() + || mapped.active_window().wl_surface().as_ref() == Some(surface.wl_surface()) + { + self.common.shell.minimize_request(&mapped) + } } } diff --git a/src/xwayland.rs b/src/xwayland.rs index f5cbfc00..44066cfb 100644 --- a/src/xwayland.rs +++ b/src/xwayland.rs @@ -33,7 +33,7 @@ use smithay::{ xdg_activation::XdgActivationToken, }, xwayland::{ - xwm::{Reorder, XwmId}, + xwm::{Reorder, X11Relatable, XwmId}, X11Surface, X11Wm, XWayland, XWaylandEvent, XwmHandler, }, }; @@ -432,14 +432,22 @@ impl XwmHandler for State { fn minimize_request(&mut self, _xwm: XwmId, window: X11Surface) { if let Some(mapped) = self.common.shell.element_for_x11_surface(&window).cloned() { - self.common.shell.minimize_request(&mapped); + if !mapped.is_stack() || mapped.active_window().is_window(&window) { + self.common.shell.minimize_request(&mapped); + } } } fn unminimize_request(&mut self, _xwm: XwmId, window: X11Surface) { - if let Some(mapped) = self.common.shell.element_for_x11_surface(&window).cloned() { + if let Some(mut mapped) = self.common.shell.element_for_x11_surface(&window).cloned() { let seat = self.common.last_active_seat().clone(); self.common.shell.unminimize_request(&mapped, &seat); + if mapped.is_stack() { + let maybe_surface = mapped.windows().find(|(w, _)| w.is_window(&window)); + if let Some((surface, _)) = maybe_surface { + mapped.stack_ref_mut().unwrap().set_active(&surface); + } + } } }