Skip to content

Commit

Permalink
xwayland: destroy xdg role before surface
Browse files Browse the repository at this point in the history
  • Loading branch information
maxhbooth committed Jul 1, 2024
1 parent dcb3759 commit 6b99333
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
10 changes: 8 additions & 2 deletions src/xwayland_xdg_shell/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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();
Expand Down
7 changes: 6 additions & 1 deletion src/xwayland_xdg_shell/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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(
Expand Down

0 comments on commit 6b99333

Please sign in to comment.