From 71eadff1edd6f9e54ab608e828cdd6f4b9e9f28c Mon Sep 17 00:00:00 2001 From: Robbert van der Helm Date: Sun, 3 Jan 2021 16:49:23 +0100 Subject: [PATCH] Fix rare X11 error on editor closing With the new deferred closing behaviour, closing the editor of Vital's VST2 version would trigger an X11 error in Wine's X11drv. This doesn't seem to happen with other plugins (or the VST3 version of Vital) and the fact that this workaround even works is strange to say the least, but at least it does work. --- src/wine-host/editor.cpp | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/src/wine-host/editor.cpp b/src/wine-host/editor.cpp index 1c9d11de..1952d140 100644 --- a/src/wine-host/editor.cpp +++ b/src/wine-host/editor.cpp @@ -242,16 +242,26 @@ Editor::Editor(const Configuration& config, const size_t parent_window_handle) } Editor::~Editor() { - // Wine will wait for the parent window to properly delete the window during - // `DestroyWindow()`. Instead of implementing this behavior ourselves we - // just reparent the window back to the window root and let the WM handle - // it. + // Reparent the window back to the root window, as the actual window will be + // destroyed as part of the next Win32 message loop cycle xcb_window_t root = xcb_setup_roots_iterator(xcb_get_setup(x11_connection.get())) .data->root; xcb_reparent_window(x11_connection.get(), wine_window, root, 0, 0); xcb_flush(x11_connection.get()); + + // XXX: I'm pretty sure this is a Wine bug (or, well, an unfortunate + // interaction of Wine's behaviour and our embedding). If we don't + // explicitly hide the window before sending a `WM_CLOSE` (in + // `destroy_window_async()`), then we might get an X11 error because + // the closing of the window will trigger an X11 event in Wine's X11drv + // which then tries to interact with the no longer existing window. + // Manually hiding the window seems to work around this. + // TODO: Check if we also have to do something special for + // editor_double_embed (probalby not) + // TODO: Retest XEmbed after all of these changes + ShowWindow(win32_handle.get(), SW_HIDE); } HWND Editor::get_win32_handle() const {