This confuses mutter and it manifests with spurious IconicState WM_STATE change when it decides to try managing the window, but it also makes it randomly lose focus or even fail to map the window back on screen.
Adding the flag after the window has been created fixes the issue.
-- v2: winex11: Avoid creating windows with override-redirect flag set.
From: Rémi Bernon rbernon@codeweavers.com
This confuses mutter and it manifests with spurious IconicState WM_STATE change when it decides to try managing the window, but it also makes it randomly lose focus or even fail to map the window back on screen.
Adding the flag after the window has been created fixes the issue. --- dlls/winex11.drv/window.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-)
diff --git a/dlls/winex11.drv/window.c b/dlls/winex11.drv/window.c index 7ae1d8ef66a..e8692fd69b6 100644 --- a/dlls/winex11.drv/window.c +++ b/dlls/winex11.drv/window.c @@ -2110,12 +2110,6 @@ static void create_whole_window( struct x11drv_win_data *data ) HRGN win_rgn; POINT pos;
- if (!data->managed && is_window_managed( data->hwnd, SWP_NOACTIVATE, &data->rects.window )) - { - TRACE( "making win %p/%lx managed\n", data->hwnd, data->whole_window ); - data->managed = TRUE; - } - if ((win_rgn = NtGdiCreateRectRgn( 0, 0, 0, 0 )) && NtUserGetWindowRgnEx( data->hwnd, win_rgn, 0 ) == ERROR) { @@ -2127,6 +2121,7 @@ static void create_whole_window( struct x11drv_win_data *data ) if (data->vis.visualid != default_visual.visualid) data->whole_colormap = XCreateColormap( data->display, root_window, data->vis.visual, AllocNone );
+ data->managed = managed_mode; mask = get_window_attributes( data, &attr );
if (!(cx = data->rects.visible.right - data->rects.visible.left)) cx = 1; @@ -2143,6 +2138,8 @@ static void create_whole_window( struct x11drv_win_data *data ) data->pending_state.rect = data->current_state.rect; data->desired_state.rect = data->current_state.rect;
+ /* Set override-redirect attribute only after window creation, Mutter gets confused otherwise */ + data->managed = is_window_managed( data->hwnd, SWP_NOACTIVATE, &data->rects.window ); x11drv_xinput2_enable( data->display, data->whole_window ); set_initial_wm_hints( data->display, data->whole_window ); set_wm_hints( data );
v2: Initialize with managed_mode, so unmanaged mode will always use override-redirect windows.
Fwiw this is definitely a window manager bug, but the workaround is simple and I think Mutter has a multitude of derivative WM which makes it difficult to fix.
That looks suspicious. Override redirect should not be managed by the WM or get focus. We've never needed to do that sort of thing, and I'm not aware of other apps doing that either.
It's a mutter bug for sure, it gets confused when the override-redirect attribute changes. This probably doesn't happen that often in general or with other applications, and only does in Wine as we're using it for some specific windows.
The attached test executable is enough to reproduce the issue (and confirm that it's fixed with this change). [test.c](/uploads/ff28611a1c52cae13ee372238453fdaf/test.c)
Fwiw the issue seems to reside in a dedicated window tracker mutter uses to decide when window frames are needed. The tracker checks whether the window is override-redirect at creation time, and will begin tracking the _MUTTER_NEEDS_FRAME property changes only when it's a managed window (https://gitlab.gnome.org/GNOME/mutter/-/blob/main/src/frames/meta-window-tra...).
If the attribute is changed at a later time, the window will still not be tracked, and mutter frame handling gets broken (which ultimately somehow leads to window getting minimized forever). It could probably be fixed by adding a ConfigureNotify case there, but I think the workaround on our side is simple and would be nice in the meantime.
This merge request was closed by Rémi Bernon.
It's been a month and I've pinged on that upstream MR a couple of times, and three people have been mentioned. I haven't received any actual feedback on the fix when the bug is obvious and easily reproduced, and a Linux test case is attached.
I suspect that GNOME is simply not interested in fixing their X11 bugs, and I don't see another option than working around it on our side, so reopening this.
I don't think the workaround is so bad, windows will all have override-redirect set from their creation in unmanaged mode, and only managed mode will change and override-redirect will be set only for windows that need it, right after they have been created.