From 9ab4c03e89db2724e6386e3ee3e1a236989bbe44 Mon Sep 17 00:00:00 2001 From: Kirill Chibisov Date: Fri, 19 Apr 2024 14:40:00 +0400 Subject: [PATCH] wayland: fix CSD decorations glitch when closing In rare cases destroying subsurfaces before the main surface could result in a frame where the window is still shown, but decorations got hidden, right before the window itself disappears. --- src/changelog/unreleased.md | 1 + src/platform_impl/linux/wayland/window/state.rs | 10 +++++++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/changelog/unreleased.md b/src/changelog/unreleased.md index 9a230aef..ebdd8e47 100644 --- a/src/changelog/unreleased.md +++ b/src/changelog/unreleased.md @@ -253,3 +253,4 @@ changelog entry. - On Web, fix setting cursor icon overriding cursor visibility. - On Windows, fix cursor not confined to center of window when grabbed and hidden. - On macOS, fix sequence of mouse events being out of order when dragging on the trackpad. +- On Wayland, fix decoration glitch on close with some compositors diff --git a/src/platform_impl/linux/wayland/window/state.rs b/src/platform_impl/linux/wayland/window/state.rs index ef84f559..28e41ee1 100644 --- a/src/platform_impl/linux/wayland/window/state.rs +++ b/src/platform_impl/linux/wayland/window/state.rs @@ -57,9 +57,6 @@ pub struct WindowState { /// The connection to Wayland server. pub connection: Connection, - /// The window frame, which is created from the configure request. - frame: Option, - /// The `Shm` to set cursor. pub shm: WlShm, @@ -155,6 +152,13 @@ pub struct WindowState { /// The underlying SCTK window. pub window: Window, + + // NOTE: The spec says that destroying parent(`window` in our case), will unmap the + // subsurfaces. Thus to achieve atomic unmap of the client, drop the decorations + // frame after the `window` is dropped. To achieve that we rely on rust's struct + // field drop order guarantees. + /// The window frame, which is created from the configure request. + frame: Option, } impl WindowState {