From 2fd453e7478cfbe45c940dcf9747f713d0c88db6 Mon Sep 17 00:00:00 2001 From: Robbert van der Helm Date: Sun, 2 May 2021 18:33:05 +0200 Subject: [PATCH] Repeat the window mapped check for Ardour This is probably a better idea than trying to be efficient. If we get two events in a row, then it can be that the map status has changed between the two events. --- src/wine-host/editor.cpp | 35 ++++++++++++++++++----------------- 1 file changed, 18 insertions(+), 17 deletions(-) diff --git a/src/wine-host/editor.cpp b/src/wine-host/editor.cpp index d203902b..e659e946 100644 --- a/src/wine-host/editor.cpp +++ b/src/wine-host/editor.cpp @@ -343,26 +343,27 @@ HWND Editor::get_win32_handle() const { } void Editor::handle_x11_events() const { - // NOTE: Ardour will unmap the window instead of closing the editor. When - // the window is unmapped, we don't need to handle any X11 events, and - // doing so might even cause X11 errors so we'll abstain from doing - // so. It would be nice if we could stop drawing the GUI when the - // window is unmapped, but filtering Win32 paint messages is probably - // not as easy as it sounds because there's no way to easily link a - // Win32 event to a hidden X11 window. - xcb_generic_error_t* error; - const xcb_get_window_attributes_cookie_t map_state_cookie = - xcb_get_window_attributes(x11_connection.get(), parent_window); - xcb_get_window_attributes_reply_t* reply = xcb_get_window_attributes_reply( - x11_connection.get(), map_state_cookie, &error); - assert(!error); - - const bool window_mapped = reply->map_state == XCB_MAP_STATE_VIEWABLE; - free(reply); - xcb_generic_event_t* generic_event; while ((generic_event = xcb_poll_for_event(x11_connection.get())) != nullptr) { + // NOTE: Ardour will unmap the window instead of closing the editor. + // When the window is unmapped, we don't need to handle any X11 + // events, and doing so might even cause X11 errors so we'll + // abstain from doing so. It would be nice if we could stop + // drawing the GUI when the window is unmapped, but filtering + // Win32 paint messages is probably not as easy as it sounds + // because there's no way to easily link a Win32 event to a hidden + // X11 window. + xcb_generic_error_t* error; + const xcb_get_window_attributes_cookie_t map_state_cookie = + xcb_get_window_attributes(x11_connection.get(), parent_window); + xcb_get_window_attributes_reply_t* reply = + xcb_get_window_attributes_reply(x11_connection.get(), + map_state_cookie, &error); + assert(!error); + + const bool window_mapped = reply->map_state == XCB_MAP_STATE_VIEWABLE; + free(reply); if (!window_mapped) { continue; }