Fix window position when entering fullscreen mode on Windows platform (#1099)

This commit is contained in:
bakasuradbl 2020-10-05 19:59:36 +02:00 committed by GitHub
parent 70400bc83e
commit 83959e5e23
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -852,10 +852,19 @@ void WIN32Window::setFullscreen(bool fullscreen)
wpPrev.length = sizeof(wpPrev); wpPrev.length = sizeof(wpPrev);
if(fullscreen) { if(fullscreen) {
Size size = getDisplaySize(); MONITORINFO mi;
HMONITOR m = MonitorFromWindow(m_window, MONITOR_DEFAULTTONEAREST);
mi.cbSize = sizeof(mi);
GetMonitorInfoW(m, &mi);
uint x = mi.rcMonitor.left;
uint y = mi.rcMonitor.top;
uint width = mi.rcMonitor.right - mi.rcMonitor.left;
uint height = mi.rcMonitor.bottom - mi.rcMonitor.top;
GetWindowPlacement(m_window, &wpPrev); GetWindowPlacement(m_window, &wpPrev);
SetWindowLong(m_window, GWL_STYLE, (dwStyle & ~WS_OVERLAPPEDWINDOW) | WS_POPUP | WS_EX_TOPMOST); SetWindowLong(m_window, GWL_STYLE, (dwStyle & ~WS_OVERLAPPEDWINDOW) | WS_POPUP | WS_EX_TOPMOST);
SetWindowPos(m_window, HWND_TOPMOST, 0, 0, size.width(), size.height(), SWP_FRAMECHANGED); SetWindowPos(m_window, HWND_TOPMOST, x, y, width, height, SWP_FRAMECHANGED);
} else { } else {
SetWindowLong(m_window, GWL_STYLE, (dwStyle & ~(WS_POPUP | WS_EX_TOPMOST)) | WS_OVERLAPPEDWINDOW); SetWindowLong(m_window, GWL_STYLE, (dwStyle & ~(WS_POPUP | WS_EX_TOPMOST)) | WS_OVERLAPPEDWINDOW);
SetWindowPlacement(m_window, &wpPrev); SetWindowPlacement(m_window, &wpPrev);