gdkwindow-win32.c: Set WS_BORDER for fullscreen GL windows if requested

With some GL drivers, it may be the case that menus are not shown
correctly in fullscreen GL windows because DWM is deactivated in the
process.

Force WS_BORDER to be applied to the fullscreen GL window so that we have
a small 1px border when needed (by setting an envvar), so that DWM does
not get deactivated, hence enabling the menus to show.  Also, when we
force WS_BORDER to be applied in this situation, we also deliberately
place the window just outside the top lefthand corner of the screen by
1px and make the window 1px larger than the screen size, so that we
effectively hide the 1px border from view.

Fixes issue #1702.
This commit is contained in:
Chun-wei Fan
2019-03-18 13:13:24 +08:00
parent 1a87249d1a
commit 11e5f2c473

View File

@ -5312,6 +5312,8 @@ gdk_win32_window_fullscreen (GdkWindow *window)
FullscreenInfo *fi;
HMONITOR monitor;
MONITORINFO mi;
DWORD extra_styles = WS_POPUP;
gint workaround_padding = 0;
g_return_if_fail (GDK_IS_WINDOW (window));
@ -5348,12 +5350,29 @@ gdk_win32_window_fullscreen (GdkWindow *window)
/* Send state change before configure event */
gdk_synthesize_window_state (window, 0, GDK_WINDOW_STATE_FULLSCREEN);
/* If we are using GL windows, and we set the envvar GDK_WIN32_GL_FULLSCREEN_WORKAROUND,
* set the WS_BORDER style so that DWM will not get deactivated. This is necessary
* when menus could not be shown correctly in fullscreen GL windows. To avoid seeing
* a border, we intentionally make the window bigger by 1px on all sides and place the
* window just 1px outside the top left-hand coordinates outside the screen area.
*/
if (window->gl_paint_context != NULL && g_getenv ("GDK_WIN32_GL_FULLSCREEN_WORKAROUND"))
{
extra_styles |= WS_BORDER;
workaround_padding = 1;
GDK_NOTE (MISC, g_print ("GL fullscreen workaround enabled for window [%p]\n",
GDK_WINDOW_HWND (window)));
}
SetWindowLong (GDK_WINDOW_HWND (window), GWL_STYLE,
(fi->style & ~WS_OVERLAPPEDWINDOW) | WS_POPUP);
(fi->style & ~WS_OVERLAPPEDWINDOW) | extra_styles);
API_CALL (SetWindowPos, (GDK_WINDOW_HWND (window), HWND_TOP,
x, y, width, height,
SWP_NOCOPYBITS | SWP_SHOWWINDOW | SWP_NOOWNERZORDER));
x - workaround_padding,
y - workaround_padding,
width + (workaround_padding * 2),
height + (workaround_padding * 2),
SWP_NOCOPYBITS | SWP_SHOWWINDOW | SWP_NOOWNERZORDER));
}
}