On Wayland, fix wl_surface being dropped first

The surface was automatically dropped due to new RAII type in SCTK
when dropping the Window, which was not the case at some point with
SCTK.

Thus destroying objects associated with it where causing issues
with some window managers.

Links: https://github.com/neovide/neovide/issues/2109
This commit is contained in:
Kirill Chibisov 2023-11-11 20:35:30 +04:00 committed by GitHub
parent eab982c402
commit 14140607d1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 14 deletions

View file

@ -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

View file

@ -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<Window>,
/// The window frame, which is created from the configure request.
frame: Option<WinitFrame>,
@ -149,6 +145,9 @@ pub struct WindowState {
///
/// The value is the serial of the event triggered moved.
has_pending_move: Option<u32>,
/// 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`.
}
}