From 887fab09367daf3347a74fb4967f26305bd591c9 Mon Sep 17 00:00:00 2001 From: Julian Orth Date: Sun, 16 Oct 2022 20:58:19 +0200 Subject: [PATCH] xwayland: don't send raw wl_surface's to xwm This handles a race where the surface was already destroyed when the message was handled. --- src/ifs/wl_compositor.rs | 2 +- src/xwayland.rs | 7 ++----- src/xwayland/xwm.rs | 6 +++++- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/ifs/wl_compositor.rs b/src/ifs/wl_compositor.rs index 88936825..4ad23cc9 100644 --- a/src/ifs/wl_compositor.rs +++ b/src/ifs/wl_compositor.rs @@ -58,7 +58,7 @@ impl WlCompositor { .state .xwayland .queue - .push(XWaylandEvent::SurfaceCreated(surface.clone())); + .push(XWaylandEvent::SurfaceCreated(surface.id)); } Ok(()) } diff --git a/src/xwayland.rs b/src/xwayland.rs index ad6f35c5..6f9ae204 100644 --- a/src/xwayland.rs +++ b/src/xwayland.rs @@ -13,10 +13,7 @@ use { zwp_primary_selection_source_v1::ZwpPrimarySelectionSourceV1, }, wl_seat::SeatId, - wl_surface::{ - x_surface::xwindow::{Xwindow, XwindowData}, - WlSurface, - }, + wl_surface::x_surface::xwindow::{Xwindow, XwindowData}, }, io_uring::IoUringError, state::State, @@ -273,7 +270,7 @@ async fn log_xwayland(state: Rc, stderr: OwnedFd) { } pub enum XWaylandEvent { - SurfaceCreated(Rc), + SurfaceCreated(WlSurfaceId), SurfaceDestroyed(WlSurfaceId), Configure(Rc), Activate(Rc), diff --git a/src/xwayland/xwm.rs b/src/xwayland/xwm.rs index 80dab9c5..7361ff8f 100644 --- a/src/xwayland/xwm.rs +++ b/src/xwayland/xwm.rs @@ -1421,7 +1421,11 @@ impl Wm { window.map_status_changed(); } - async fn handle_xwayland_surface_created(&mut self, surface: Rc) { + async fn handle_xwayland_surface_created(&mut self, surface: WlSurfaceId) { + let surface = match self.client.lookup(surface) { + Ok(s) => s, + _ => return, + }; let data = match self.windows_by_surface_id.get(&surface.id) { Some(w) => w.clone(), _ => return,