diff --git a/CHANGELOG.md b/CHANGELOG.md index a0c8775b..541d954e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,7 @@ Unreleased` header. - On Windows, fix so `drag_window` and `drag_resize_window` can be called from another thread. - On Windows, fix `set_control_flow` in `AboutToWait` not being taken in account. - On macOS, send a `Resized` event after each `ScaleFactorChanged` event. +- On Wayland, fix `wl_surface` being destroyed before associated objects. # 0.29.3 diff --git a/src/platform_impl/linux/wayland/window/state.rs b/src/platform_impl/linux/wayland/window/state.rs index f9f3187e..0b04ce93 100644 --- a/src/platform_impl/linux/wayland/window/state.rs +++ b/src/platform_impl/linux/wayland/window/state.rs @@ -1,6 +1,5 @@ //! The state of the window, which is shared with the event-loop. -use std::mem::ManuallyDrop; use std::num::NonZeroU32; use std::sync::{Arc, Weak}; use std::time::Duration; @@ -55,9 +54,6 @@ pub struct WindowState { /// The connection to Wayland server. pub connection: Connection, - /// The underlying SCTK window. - pub window: ManuallyDrop, - /// The window frame, which is created from the configure request. frame: Option, @@ -149,6 +145,9 @@ pub struct WindowState { /// /// The value is the serial of the event triggered moved. has_pending_move: Option, + + /// The underlying SCTK window. + pub window: Window, } impl WindowState { @@ -206,7 +205,7 @@ impl WindowState { title: String::default(), transparent: false, viewport, - window: ManuallyDrop::new(window), + window, } } @@ -271,7 +270,7 @@ impl WindowState { && !self.csd_fails { match WinitFrame::new( - &*self.window, + &self.window, shm, subcompositor.clone(), self.queue_handle.clone(), @@ -1026,13 +1025,6 @@ impl WindowState { impl Drop for WindowState { fn drop(&mut self) { - let surface = self.window.wl_surface().clone(); - unsafe { - ManuallyDrop::drop(&mut self.window); - } - - // Cleanup objects. - if let Some(blur) = self.blur.take() { blur.release(); } @@ -1045,7 +1037,8 @@ impl Drop for WindowState { viewport.destroy(); } - surface.destroy(); + // NOTE: the wl_surface used by the window is being cleaned up when + // dropping SCTK `Window`. } }