diff --git a/Windows/WindowsHost.cpp b/Windows/WindowsHost.cpp index 4fb759a7e1..e023bd69e3 100644 --- a/Windows/WindowsHost.cpp +++ b/Windows/WindowsHost.cpp @@ -336,10 +336,7 @@ bool WindowsHost::CreateDesktopShortcut(std::string argumentPath, std::string ga } void WindowsHost::GoFullscreen(bool viewFullscreen) { - if (viewFullscreen) - MainWindow::SwitchToFullscreen(mainWindow_); - else - MainWindow::SwitchToWindowed(mainWindow_); + MainWindow::ToggleFullscreen(mainWindow_, viewFullscreen); } void WindowsHost::ToggleDebugConsoleVisibility() { diff --git a/Windows/WndMainWindow.cpp b/Windows/WndMainWindow.cpp index 3c5372f30b..5ca92a273f 100644 --- a/Windows/WndMainWindow.cpp +++ b/Windows/WndMainWindow.cpp @@ -309,59 +309,39 @@ namespace MainWindow } } - void SwitchToWindowed(HWND hWnd) { + void ToggleFullscreen(HWND hWnd, bool goingFullscreen = false) { // Make sure no rendering is happening during the switch. Core_NotifyWindowHidden(true); g_inModeSwitch = true; // Make sure WM_SIZE doesn't call Core_NotifyWindowHidden(false)... - // Put caption and border styles back. - DWORD dwOldStyle = ::GetWindowLong(hWnd, GWL_STYLE); - DWORD dwNewStyle = dwOldStyle | WS_CAPTION | WS_THICKFRAME | WS_SYSMENU; - ::SetWindowLong(hWnd, GWL_STYLE, dwNewStyle); + DWORD dwOldStyle; + DWORD dwNewStyle; - // Put back the menu bar. - ::SetMenu(hWnd, menu); + if (!goingFullscreen) { + // Put caption and border styles back. + dwOldStyle = ::GetWindowLong(hWnd, GWL_STYLE); + dwNewStyle = dwOldStyle | WS_CAPTION | WS_THICKFRAME | WS_SYSMENU; + + // Put back the menu bar. + ::SetMenu(hWnd, menu); + } else { + // Remember the normal window rectangle. + ::GetWindowRect(hWnd, &g_normalRC); - // Resize to normal view. - ShowWindow(hwndMain, SW_RESTORE); - - // Reset full screen indicator. - g_Config.bFullScreen = false; - CorrectCursor(); - - bool showOSM = (g_Config.iInternalResolution == RESOLUTION_AUTO); - ResizeDisplay(false); - if (showOSM) { - ShowScreenResolution(); + // Remove caption and border styles. + dwOldStyle = ::GetWindowLong(hWnd, GWL_STYLE); + dwNewStyle = dwOldStyle & ~(WS_CAPTION | WS_THICKFRAME | WS_SYSMENU); } - ShowOwnedPopups(hwndMain, TRUE); - W32Util::MakeTopMost(hwndMain, g_Config.bTopMost); - g_inModeSwitch = false; - Core_NotifyWindowHidden(false); - } - - void SwitchToFullscreen(HWND hWnd) { - // Make sure no rendering is happening during the switch. - Core_NotifyWindowHidden(true); - g_inModeSwitch = true; // Make sure WM_SIZE doesn't call Core_NotifyWindowHidden(false)... - - // Remember the normal window rectangle. - ::GetWindowRect(hWnd, &g_normalRC); - - // Remove caption and border styles. - DWORD dwOldStyle = ::GetWindowLong(hWnd, GWL_STYLE); - DWORD dwNewStyle = dwOldStyle & ~(WS_CAPTION | WS_THICKFRAME | WS_SYSMENU); ::SetWindowLong(hWnd, GWL_STYLE, dwNewStyle); // Remove the menu bar. - ::SetMenu(hWnd, NULL); + ::SetMenu(hWnd, goingFullscreen ? NULL : menu); - // Resize to full screen view. - ShowWindow(hwndMain, SW_MAXIMIZE); + // Resize to the appropriate view. + ShowWindow(hwndMain, goingFullscreen ? SW_MAXIMIZE : SW_RESTORE); - // Set full screen indicator. - g_Config.bFullScreen = true; + g_Config.bFullScreen = goingFullscreen; CorrectCursor(); bool showOSM = (g_Config.iInternalResolution == RESOLUTION_AUTO); @@ -369,8 +349,8 @@ namespace MainWindow if (showOSM) { ShowScreenResolution(); } - - ShowOwnedPopups(hwndMain, FALSE); + ShowOwnedPopups(hwndMain, goingFullscreen ? FALSE : TRUE); + W32Util::MakeTopMost(hwndMain, g_Config.bTopMost); g_inModeSwitch = false; Core_NotifyWindowHidden(false); @@ -777,7 +757,7 @@ namespace MainWindow windowTitle = title; } - BOOL Show(HINSTANCE hInstance, int nCmdShow) { + BOOL Show(HINSTANCE hInstance) { hInst = hInstance; // Store instance handle in our global variable. RECT rc = DetermineWindowRectangle(); @@ -819,10 +799,7 @@ namespace MainWindow hideCursor = true; SetTimer(hwndMain, TIMER_CURSORUPDATE, CURSORUPDATE_INTERVAL_MS, 0); - if (g_Config.bFullScreen) - SwitchToFullscreen(hwndMain); - - ShowWindow(hwndMain, nCmdShow); + ToggleFullscreen(hwndMain, g_Config.bFullScreen); W32Util::MakeTopMost(hwndMain, g_Config.bTopMost); @@ -1506,10 +1483,7 @@ namespace MainWindow case ID_OPTIONS_FULLSCREEN: g_Config.bFullScreen = !g_Config.bFullScreen; - if (g_Config.bFullScreen) - SwitchToFullscreen(hWnd); - else - SwitchToWindowed(hWnd); + ToggleFullscreen(hwndMain, g_Config.bFullScreen); break; diff --git a/Windows/WndMainWindow.h b/Windows/WndMainWindow.h index af47c050f5..a00d8b7b3d 100644 --- a/Windows/WndMainWindow.h +++ b/Windows/WndMainWindow.h @@ -49,7 +49,7 @@ namespace MainWindow }; void Init(HINSTANCE hInstance); - BOOL Show(HINSTANCE hInstance, int nCmdShow); + BOOL Show(HINSTANCE hInstance); void CreateDebugWindows(); void DestroyDebugWindows(); void Close(); @@ -63,8 +63,7 @@ namespace MainWindow HWND GetDisplayHWND(); void BrowseAndBoot(std::string defaultPath, bool browseDirectory = false); void SaveStateActionFinished(bool result, void *userdata); - void SwitchToFullscreen(HWND hWnd); - void SwitchToWindowed(HWND hWnd); + void ToggleFullscreen(HWND hWnd, bool goingFullscreen); void ToggleDebugConsoleVisibility(); void TranslateMenus(); void setTexScalingMultiplier(int level); diff --git a/Windows/main.cpp b/Windows/main.cpp index b670b4a564..6f1e88d001 100644 --- a/Windows/main.cpp +++ b/Windows/main.cpp @@ -374,7 +374,7 @@ int WINAPI WinMain(HINSTANCE _hInstance, HINSTANCE hPrevInstance, LPSTR szCmdLin g_hPopupMenus = LoadMenu(_hInstance, (LPCWSTR)IDR_POPUPMENUS); - MainWindow::Show(_hInstance, iCmdShow); + MainWindow::Show(_hInstance); HWND hwndMain = MainWindow::GetHWND(); HWND hwndDisplay = MainWindow::GetDisplayHWND();