diff --git a/src/wine-host/editor.cpp b/src/wine-host/editor.cpp index 42597911..40c01e9d 100644 --- a/src/wine-host/editor.cpp +++ b/src/wine-host/editor.cpp @@ -87,13 +87,18 @@ constexpr uint32_t wrapper_event_mask = constexpr char active_window_property_name[] = "_NET_ACTIVE_WINDOW"; /** - * We'll use this property to filter windows for `host_window_`. Like `xprop` - * and `xwininfo`, we'll only consider windows with this property set, although - * we won't filter on whether or not the window is actually visible because it - * may be minimalized when the plugin's GUI is being opened. + * We'll set this property on the Wine window to emulate the behavior of + * a minimal window manager. */ constexpr char icccm_wm_state_property_name[] = "WM_STATE"; +/** + * We'll use this property to filter windows for `host_window_`. WM_STATE + * can end up being set too late during window initialization, so we miss + * identifying the host window. + */ +constexpr char icccm_wm_window_role_property_name[] = "WM_WINDOW_ROLE"; + /** * This `WM_STATE` property value indicates that a window is a visible top level * window. Needs to be set on Wine's window as part of emulating the behavior of @@ -292,6 +297,9 @@ Editor::Editor(MainContext& main_context, }), xcb_wm_state_property_( get_atom_by_name(*x11_connection_, icccm_wm_state_property_name)), + xcb_wm_window_role_property_( + get_atom_by_name(*x11_connection_, + icccm_wm_window_role_property_name)), parent_window_(parent_window_handle), wrapper_window_( x11_connection_, @@ -316,7 +324,7 @@ Editor::Editor(MainContext& main_context, wine_window_(get_x11_handle(win32_window_.handle_)), host_window_(find_host_window(*x11_connection_, parent_window_, - xcb_wm_state_property_) + xcb_wm_window_role_property_) .value_or(parent_window_)) { logger.log_editor_trace([&]() { return "DEBUG: host_window: " + std::to_string(host_window_); @@ -931,7 +939,7 @@ bool Editor::is_wine_window_active() const { void Editor::redetect_host_window() noexcept { const xcb_window_t new_host_window = find_host_window(*x11_connection_, parent_window_, - xcb_wm_state_property_) + xcb_wm_window_role_property_) .value_or(parent_window_); if (new_host_window == host_window_) { return; diff --git a/src/wine-host/editor.h b/src/wine-host/editor.h index 7b4786f6..52eaa4f5 100644 --- a/src/wine-host/editor.h +++ b/src/wine-host/editor.h @@ -374,6 +374,11 @@ class Editor { */ xcb_atom_t xcb_wm_state_property_; + /** + * The atom corresponding to `WM_WINDOW_ROLE`. + */ + xcb_atom_t xcb_wm_window_role_property_; + /** * The window handle of the editor window created by the DAW. */