fix(shell): distinguish between unmapping and destroying surfaces

Previously, `unmap_surface` automatically pushed all unmapped windows
into the `pending_windows` list. This behavior is correct for X11
windows (which may be remapped) but incorrect for Wayland `toplevel_destroyed`
events, where the role is permanently gone.

This caused issues with clients like Telegram that reuse `wl_surface`s.
Because the destroyed toplevel remained in `pending_windows`, a
subsequent cleanup commit (e.g., null buffer) triggered a configure
event. This prematurely marked the surface as `configured` in the
shell state.

Consequently, when the client attached a new `xdg_toplevel` role,
the compositor skipped the mandatory initial configure event (assuming
it was already done), causing the window to never appear.

This refactors `unmap_surface` to return `Option<PendingWindow>`
instead of mutating global state.
- XWayland: Explicitly saves the pending window (behavior preserved).
- XDG Shell: Drops the pending window, preventing ghost state interactions.

Fixes #1816
This commit is contained in:
mikairyuu 2026-01-09 17:23:58 +09:00 committed by Jacob Kauffmann
parent e6a3a3a9c9
commit 15b6b678c1
3 changed files with 11 additions and 5 deletions

View file

@ -2832,7 +2832,8 @@ impl Shell {
surface: &S,
seat: &Seat<State>,
toplevel_info: &mut ToplevelInfoState<State, CosmicSurface>,
) where
) -> Option<PendingWindow>
where
CosmicSurface: PartialEq<S>,
{
for set in self.workspaces.sets.values_mut() {
@ -2890,15 +2891,16 @@ impl Shell {
if let Some(surface) = surface {
toplevel_info.remove_toplevel(&surface);
self.pending_windows.push(PendingWindow {
return Some(PendingWindow {
surface,
seat: seat.clone(),
fullscreen: None,
maximized: false,
});
return;
}
}
None
}
pub fn move_current(