[PATCH 0/1] MR9841: winex11.drv: Don't send -1 fullscreen monitor indices to window managers.
Fix a regression from 3bea06b8. This partly reverts 6a2e414d, which introduced this bug initially. With 3bea06b8, it becomes much more likely that indices (-1, -1, -1, -1) got sent to window managers. This can happen, for example, a game with a 1920x1080 window changes the display resolution to 3840x2160, then changes the window size to 3840x2160. After the resolution change and before the window size change, xinerama_get_fullscreen_monitors() will return monitor indices (-1, -1, -1, -1) because 1920x1080 is not fullscreen. While sending a _NET_WM_FULLSCREEN_MONITORS client message with fullscreen monitor indices (-1, -1, -1, -1) clears the _NET_WM_FULLSCREEN_MONITORS property for a window on KWin, it can also make the window to disappear and lose focus. See KWin X11Window::fullscreenMonitorsArea()[1] and X11Window::updateFullscreenMonitors()[2]. Note that QRect is constructed with an empty rect at the beginning of X11Window::fullscreenMonitorsArea(). So fullscreen monitor indices (-1, -1, -1, -1) will produce an empty rect for moveResize() in X11Window::updateFullscreenMonitors() and cause the window to disappear. While indices (-1, 0, 0, 0) might work, I think it's better not to change _NET_WM_FULLSCREEN_MONITORS when the window is not fullscreen because removing the property is not part of any standard. [1]: https://invent.kde.org/plasma/kwin-x11/-/blob/v6.5.4/src/x11window.cpp?ref_t... [2]: https://invent.kde.org/plasma/kwin-x11/-/blob/v6.5.4/src/x11window.cpp?ref_t... Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=59180 -- https://gitlab.winehq.org/wine/wine/-/merge_requests/9841
From: Zhiyi Zhang <zzhang@codeweavers.com> Fix a regression from 3bea06b8. This partly reverts 6a2e414d, which introduced this bug initially. With 3bea06b8, it becomes much more likely that indices (-1, -1, -1, -1) got sent to window managers. This can happen, for example, a game with a 1920x1080 window changes the display resolution to 3840x2160, then changes the window size to 3840x2160. After the resolution change and before the window size change, xinerama_get_fullscreen_monitors() will return monitor indices (-1, -1, -1, -1) because 1920x1080 is not fullscreen. While sending a _NET_WM_FULLSCREEN_MONITORS client message with fullscreen monitor indices (-1, -1, -1, -1) clears the _NET_WM_FULLSCREEN_MONITORS property for a window on KWin, it can also make the window to disappear and lose focus. See KWin X11Window::fullscreenMonitorsArea()[1] and X11Window::updateFullscreenMonitors()[2]. Note that QRect is constructed with an empty rect at the beginning of X11Window::fullscreenMonitorsArea(). So fullscreen monitor indices (-1, -1, -1, -1) will produce an empty rect for moveResize() in X11Window::updateFullscreenMonitors() and cause the window to disappear. While indices (-1, 0, 0, 0) might work, I think it's better not to change _NET_WM_FULLSCREEN_MONITORS when the window is not fullscreen because removing the property is not part of any standard. [1]: https://invent.kde.org/plasma/kwin-x11/-/blob/v6.5.4/src/x11window.cpp?ref_t... [2]: https://invent.kde.org/plasma/kwin-x11/-/blob/v6.5.4/src/x11window.cpp?ref_t... Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=59180 --- dlls/winex11.drv/window.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/dlls/winex11.drv/window.c b/dlls/winex11.drv/window.c index d256674c9c1..7ff9b880f22 100644 --- a/dlls/winex11.drv/window.c +++ b/dlls/winex11.drv/window.c @@ -1289,7 +1289,8 @@ static void update_net_wm_fullscreen_monitors( struct x11drv_win_data *data ) if (!X11DRV_DisplayDevices_SupportEventHandlers()) return; - xinerama_get_fullscreen_monitors( &data->rects.visible, &monitors.generation, monitors.indices ); + if (!xinerama_get_fullscreen_monitors( &data->rects.visible, &monitors.generation, monitors.indices )) + return; data->desired_state.monitors = monitors; if (!memcmp( old_monitors, &monitors, sizeof(monitors) )) return; /* states are the same, nothing to update */ @@ -1299,9 +1300,8 @@ static void update_net_wm_fullscreen_monitors( struct x11drv_win_data *data ) memcpy( &data->pending_state.monitors, &monitors, sizeof(monitors) ); TRACE( "window %p/%lx, requesting _NET_WM_FULLSCREEN_MONITORS %s serial %lu\n", data->hwnd, data->whole_window, debugstr_monitor_indices( &monitors ), NextRequest( data->display ) ); - if (monitors.indices[0] == -1) XDeleteProperty( data->display, data->whole_window, x11drv_atom(_NET_WM_FULLSCREEN_MONITORS) ); - else XChangeProperty( data->display, data->whole_window, x11drv_atom(_NET_WM_FULLSCREEN_MONITORS), - XA_CARDINAL, 32, PropModeReplace, (unsigned char *)monitors.indices, 4 ); + XChangeProperty( data->display, data->whole_window, x11drv_atom(_NET_WM_FULLSCREEN_MONITORS), + XA_CARDINAL, 32, PropModeReplace, (unsigned char *)monitors.indices, 4 ); } else { -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/9841
This merge request was approved by Rémi Bernon. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/9841
participants (3)
-
Rémi Bernon (@rbernon) -
Zhiyi Zhang -
Zhiyi Zhang (@zhiyi)