mirror of
https://github.com/italicsjenga/winit-sonoma-fix.git
synced 2024-12-23 22:01:31 +11:00
On Wayland, drop wl_surface on window close
This commit is contained in:
parent
78f1d1df38
commit
2d2ce70edc
|
@ -1,4 +1,5 @@
|
||||||
use std::cell::Cell;
|
use std::cell::Cell;
|
||||||
|
use std::mem::ManuallyDrop;
|
||||||
use std::sync::{Arc, Mutex};
|
use std::sync::{Arc, Mutex};
|
||||||
|
|
||||||
use sctk::reexports::client::protocol::wl_compositor::WlCompositor;
|
use sctk::reexports::client::protocol::wl_compositor::WlCompositor;
|
||||||
|
@ -154,7 +155,7 @@ impl WindowUpdate {
|
||||||
/// and react to events.
|
/// and react to events.
|
||||||
pub struct WindowHandle {
|
pub struct WindowHandle {
|
||||||
/// An actual window.
|
/// An actual window.
|
||||||
pub window: Window<WinitFrame>,
|
pub window: ManuallyDrop<Window<WinitFrame>>,
|
||||||
|
|
||||||
/// The current size of the window.
|
/// The current size of the window.
|
||||||
pub size: Arc<Mutex<LogicalSize<u32>>>,
|
pub size: Arc<Mutex<LogicalSize<u32>>>,
|
||||||
|
@ -206,7 +207,7 @@ impl WindowHandle {
|
||||||
let compositor = env.get_global::<WlCompositor>().unwrap();
|
let compositor = env.get_global::<WlCompositor>().unwrap();
|
||||||
|
|
||||||
Self {
|
Self {
|
||||||
window,
|
window: ManuallyDrop::new(window),
|
||||||
size,
|
size,
|
||||||
pending_window_requests,
|
pending_window_requests,
|
||||||
cursor_icon: Cell::new(CursorIcon::Default),
|
cursor_icon: Cell::new(CursorIcon::Default),
|
||||||
|
@ -563,3 +564,14 @@ pub fn handle_window_requests(winit_state: &mut WinitState) {
|
||||||
let _ = window_updates.remove(&window);
|
let _ = window_updates.remove(&window);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Drop for WindowHandle {
|
||||||
|
fn drop(&mut self) {
|
||||||
|
unsafe {
|
||||||
|
let surface = self.window.surface().clone();
|
||||||
|
// The window must be destroyed before wl_surface.
|
||||||
|
ManuallyDrop::drop(&mut self.window);
|
||||||
|
surface.destroy();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue