From 83959e5e2327e2bc4bcd99a9467c7ccbbffe869f Mon Sep 17 00:00:00 2001 From: bakasuradbl <47023887+bakasuradbl@users.noreply.github.com> Date: Mon, 5 Oct 2020 19:59:36 +0200 Subject: [PATCH] Fix window position when entering fullscreen mode on Windows platform (#1099) --- src/framework/platform/win32window.cpp | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/framework/platform/win32window.cpp b/src/framework/platform/win32window.cpp index 9939f6f8..623dd38b 100644 --- a/src/framework/platform/win32window.cpp +++ b/src/framework/platform/win32window.cpp @@ -852,10 +852,19 @@ void WIN32Window::setFullscreen(bool fullscreen) wpPrev.length = sizeof(wpPrev); 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); + 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 { SetWindowLong(m_window, GWL_STYLE, (dwStyle & ~(WS_POPUP | WS_EX_TOPMOST)) | WS_OVERLAPPEDWINDOW); SetWindowPlacement(m_window, &wpPrev);