From 5c6753e486e356bbbd8354241babed43f6793ce0 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sun, 20 Sep 2015 21:54:27 -0700 Subject: [PATCH] Correct render size on fullscreen->maximized. We don't get a WM_SIZE event, since that is only sent on "change". This means we don't recalculate the client area size, so we get it wrong. Fixes #7986. --- Windows/MainWindow.cpp | 74 +++++++++++++++++++++++------------------- 1 file changed, 41 insertions(+), 33 deletions(-) diff --git a/Windows/MainWindow.cpp b/Windows/MainWindow.cpp index 26d195bca8..10be6beaba 100644 --- a/Windows/MainWindow.cpp +++ b/Windows/MainWindow.cpp @@ -296,6 +296,42 @@ namespace MainWindow } } + static void HandleSizeChange(int newSizingType) { + SavePosition(); + Core_NotifyWindowHidden(false); + if (!g_Config.bPauseWhenMinimized) { + NativeMessageReceived("window minimized", "false"); + } + + int width = 0, height = 0; + RECT rc; + GetClientRect(hwndMain, &rc); + width = rc.right - rc.left; + height = rc.bottom - rc.top; + + // Moves the internal display window to match the inner size of the main window. + MoveWindow(hwndDisplay, 0, 0, width, height, TRUE); + + // Setting pixelWidth to be too small could have odd consequences. + if (width >= 4 && height >= 4) { + // The framebuffer manager reads these once per frame, hopefully safe enough.. should really use a mutex or some + // much better mechanism. + PSP_CoreParameter().pixelWidth = width; + PSP_CoreParameter().pixelHeight = height; + } + + UpdateRenderResolution(); + + if (UpdateScreenScale(width, height, IsWindowSmall())) { + NativeMessageReceived("gpu resized", ""); + } + + // Don't save the window state if fullscreen. + if (!g_Config.bFullScreen) { + g_WindowState = newSizingType; + } + } + void ToggleFullscreen(HWND hWnd, bool goingFullscreen) { // Make sure no rendering is happening during the switch. @@ -351,6 +387,10 @@ namespace MainWindow ShowWindow(hwndMain, SW_MAXIMIZE); } else { ShowWindow(hwndMain, oldWindowState == SIZE_MAXIMIZED ? SW_MAXIMIZE : SW_RESTORE); + if (oldWindowState == SIZE_MAXIMIZED) { + // WM_SIZE wasn't sent, since the size didn't change (it was full screen before and after.) + HandleSizeChange(oldWindowState); + } } CorrectCursor(); @@ -709,39 +749,7 @@ namespace MainWindow if (g_IgnoreWM_SIZE) { return DefWindowProc(hWnd, message, wParam, lParam); } else { - SavePosition(); - Core_NotifyWindowHidden(false); - if (!g_Config.bPauseWhenMinimized) { - NativeMessageReceived("window minimized", "false"); - } - - int width = 0, height = 0; - RECT rc; - GetClientRect(hwndMain, &rc); - width = rc.right - rc.left; - height = rc.bottom - rc.top; - - // Moves the internal display window to match the inner size of the main window. - MoveWindow(hwndDisplay, 0, 0, width, height, TRUE); - - // Setting pixelWidth to be too small could have odd consequences. - if (width >= 4 && height >= 4) { - // The framebuffer manager reads these once per frame, hopefully safe enough.. should really use a mutex or some - // much better mechanism. - PSP_CoreParameter().pixelWidth = width; - PSP_CoreParameter().pixelHeight = height; - } - - UpdateRenderResolution(); - - if (UpdateScreenScale(width, height, IsWindowSmall())) { - NativeMessageReceived("gpu resized", ""); - } - - // Don't save the window state if fullscreen. - if (!g_Config.bFullScreen) { - g_WindowState = wParam; - } + HandleSizeChange(wParam); } break;