From ec9e700e7003e266c269cc257bdc1a32f033d6a7 Mon Sep 17 00:00:00 2001 From: Thorsten Ball Date: Tue, 11 Jun 2024 17:23:48 +0200 Subject: [PATCH] linux/x11: Mark windows as destroyed after destroy request (#12892) Turns out we still get FocusOut and UnmapNotify events after the window has been destroyed, which resulted in error messages popping up because we can't find the window anymore that we want to mark as unfocused. Release Notes: - N/A --- crates/gpui/src/platform/linux/x11/client.rs | 1 + crates/gpui/src/platform/linux/x11/window.rs | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/crates/gpui/src/platform/linux/x11/client.rs b/crates/gpui/src/platform/linux/x11/client.rs index b91f9e165c7d324a9c0aea6d9a6a0bd1d4ba781d..b542acfbc57db5f9c96cbea1e5b411cc73860a60 100644 --- a/crates/gpui/src/platform/linux/x11/client.rs +++ b/crates/gpui/src/platform/linux/x11/client.rs @@ -458,6 +458,7 @@ impl X11Client { state .windows .get(&win) + .filter(|window_reference| !window_reference.window.state.borrow().destroyed) .map(|window_reference| window_reference.window.clone()) } diff --git a/crates/gpui/src/platform/linux/x11/window.rs b/crates/gpui/src/platform/linux/x11/window.rs index d5c1846d5699380f43a480be166f7484d5f4a88b..7ebcbfa0324d59dc07431121d6f61e5c5e8a00cb 100644 --- a/crates/gpui/src/platform/linux/x11/window.rs +++ b/crates/gpui/src/platform/linux/x11/window.rs @@ -154,6 +154,7 @@ pub struct Callbacks { } pub struct X11WindowState { + pub destroyed: bool, client: X11ClientStatePtr, executor: ForegroundExecutor, atoms: XcbAtoms, @@ -368,6 +369,7 @@ impl X11WindowState { input_handler: None, appearance, handle, + destroyed: false, } } @@ -394,6 +396,10 @@ impl Drop for X11Window { .unwrap(); self.0.xcb_connection.flush().unwrap(); + // Mark window as destroyed so that we can filter out when X11 events + // for it still come in. + state.destroyed = true; + let this_ptr = self.0.clone(); let client_ptr = state.client.clone(); state