Fetch the Wine and root window IDs early

There's no reason to wait until the last moment to fetch these.
This commit is contained in:
Robbert van der Helm
2021-07-21 18:06:18 +02:00
parent d41c05e90e
commit 9002468229
2 changed files with 9 additions and 12 deletions
+5 -11
View File
@@ -174,10 +174,12 @@ ATOM get_window_class() noexcept;
DeferredWin32Window::DeferredWin32Window(
MainContext& main_context,
std::shared_ptr<xcb_connection_t> x11_connection,
HWND window) noexcept
HWND window)
: handle(window),
main_context(main_context),
x11_connection(x11_connection) {}
x11_connection(x11_connection),
wine_window(get_x11_handle(handle)),
root_window(get_root_window(*x11_connection, wine_window)) {}
DeferredWin32Window::~DeferredWin32Window() noexcept {
// NOTE: For some rason, Wine will sometimes try to delete a window twice if
@@ -186,15 +188,7 @@ DeferredWin32Window::~DeferredWin32Window() noexcept {
// iZotope Rx plugins. In Renoise this would otherwise trigger an X11
// error every time you close such a plugin's editor, and in other
// DAWs I've also seen it happen from time to time.
try {
const xcb_window_t wine_window = get_x11_handle(handle);
const xcb_window_t root_window =
get_root_window(*x11_connection, wine_window);
xcb_reparent_window(x11_connection.get(), wine_window, root_window, 0,
0);
} catch (const std::runtime_error& error) {
std::cerr << error.what() << std::endl;
}
xcb_reparent_window(x11_connection.get(), wine_window, root_window, 0, 0);
// XXX: We are already deferring this closing by posting `WM_CLOSE` to the
// message loop instead of calling `DestroyWindow()` ourselves, but we