diff --git a/src/xwayland_xdg_shell/client.rs b/src/xwayland_xdg_shell/client.rs index 51eb466d..225e5d18 100644 --- a/src/xwayland_xdg_shell/client.rs +++ b/src/xwayland_xdg_shell/client.rs @@ -1304,6 +1304,12 @@ impl WaylandSurface for SubSurface { } } +impl Drop for SubSurface { + fn drop(&mut self) { + self.subsurface.destroy(); + } +} + #[derive(Debug)] pub struct XWaylandSubSurface { pub local_subsurface: SubSurface, @@ -1330,10 +1336,10 @@ impl XWaylandSubSurface { .unwrap(); let local_subsurface = SubSurface { - subsurface: subsurface.clone(), + subsurface, surface: local_surface, }; - subsurface.set_desync(); + local_subsurface.subsurface.set_desync(); let x11_surface = surface.get_x11_surface().location(loc!())?; let geometry = x11_surface.geometry(); diff --git a/src/xwayland_xdg_shell/mod.rs b/src/xwayland_xdg_shell/mod.rs index ad763323..92df63d8 100644 --- a/src/xwayland_xdg_shell/mod.rs +++ b/src/xwayland_xdg_shell/mod.rs @@ -399,7 +399,6 @@ impl WprsState { self.remove_surface(&child); } - self.surface_bimap.remove_by_left(surface_id); if let Some(xwayland_surface) = self.surfaces.remove(surface_id) { if let Some(parent) = xwayland_surface.parent { let parent_xwayland_surface = self.surfaces.get_mut(&parent.surface_id).unwrap(); @@ -408,6 +407,12 @@ impl WprsState { .retain(|child_surface_id| child_surface_id != surface_id); } } + + // this MUST come after removing xwayland_surface, because xwayland_surface's role needs + // to be destroyed before it's client wl_surface. + // ultimately, the wayland object should be destroyed in order from: + // xdg_popup/xdg_toplevel -> xdg_surface -> wl_surface + self.surface_bimap.remove_by_left(surface_id); } #[instrument(