From 6e48f907dd205e374bd0ee6458fd525e3f205d3e Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Fri, 25 Dec 2015 19:18:32 -0800 Subject: [PATCH 1/3] Support minimize and maximize state. Fixes #6893. Minimize is mostly useful for tooling, and maximize is a more user-friendly way of specifying a fullscreen shortcut. --- Windows/MainWindow.cpp | 4 ++++ Windows/MainWindow.h | 1 + Windows/main.cpp | 10 ++++++++++ 3 files changed, 15 insertions(+) diff --git a/Windows/MainWindow.cpp b/Windows/MainWindow.cpp index d5933d1000..1c5e12b5f0 100644 --- a/Windows/MainWindow.cpp +++ b/Windows/MainWindow.cpp @@ -360,6 +360,10 @@ namespace MainWindow } } + void Minimize() { + ShowWindow(hwndMain, SW_MINIMIZE); + } + RECT DetermineWindowRectangle() { RECT rc; diff --git a/Windows/MainWindow.h b/Windows/MainWindow.h index d2459edfeb..c03b2b2687 100644 --- a/Windows/MainWindow.h +++ b/Windows/MainWindow.h @@ -62,6 +62,7 @@ namespace MainWindow HINSTANCE GetHInstance(); HWND GetDisplayHWND(); void ToggleFullscreen(HWND hWnd, bool goingFullscreen); + void Minimize(); void SendToggleFullscreen(bool fullscreen); // To be used off-thread void ToggleDebugConsoleVisibility(); void SetInternalResolution(int res = -1); diff --git a/Windows/main.cpp b/Windows/main.cpp index c4c79c809c..0d872e3b99 100644 --- a/Windows/main.cpp +++ b/Windows/main.cpp @@ -482,6 +482,11 @@ int WINAPI WinMain(HINSTANCE _hInstance, HINSTANCE hPrevInstance, LPSTR szCmdLin g_Config.bEnableLogging = true; #endif + if (iCmdShow == SW_MAXIMIZE) { + // Consider this to mean --fullscreen. + g_Config.bFullScreen = true; + } + LogManager::Init(); // Consider at least the following cases before changing this code: // - By default in Release, the console should be hidden by default even if logging is enabled. @@ -521,6 +526,11 @@ int WINAPI WinMain(HINSTANCE _hInstance, HINSTANCE hPrevInstance, LPSTR szCmdLin MainWindow::CreateDebugWindows(); + const bool minimized = iCmdShow == SW_MINIMIZE || iCmdShow == SW_SHOWMINIMIZED || iCmdShow == SW_SHOWMINNOACTIVE; + if (minimized) { + MainWindow::Minimize(); + } + // Emu thread is always running! EmuThread_Start(); InputDevice::BeginPolling(); From 82e41a1392a71f3f0cdf232f62826666c57524ab Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Fri, 25 Dec 2015 19:39:52 -0800 Subject: [PATCH 2/3] Make sure the config is saved on exit. May help #7724. --- UI/MainScreen.cpp | 2 ++ ext/native/base/PCMain.cpp | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/UI/MainScreen.cpp b/UI/MainScreen.cpp index e498e8b863..d7d726f514 100644 --- a/UI/MainScreen.cpp +++ b/UI/MainScreen.cpp @@ -1090,6 +1090,8 @@ UI::EventReturn MainScreen::OnExit(UI::EventParams &e) { #ifdef ANDROID_NDK_PROFILER moncleanup(); #endif + // However, let's make sure the config was saved, since it may not have been. + g_Config.Save(); exit(0); #endif diff --git a/ext/native/base/PCMain.cpp b/ext/native/base/PCMain.cpp index 702985e28b..3009521f29 100644 --- a/ext/native/base/PCMain.cpp +++ b/ext/native/base/PCMain.cpp @@ -879,15 +879,15 @@ int main(int argc, char *argv[]) { #ifndef _WIN32 delete joystick; #endif + NativeShutdownGraphics(); + NativeShutdown(); // Faster exit, thanks to the OS. Remove this if you want to debug shutdown // The speed difference is only really noticable on Linux. On Windows you do notice it though #ifndef MOBILE_DEVICE exit(0); #endif - NativeShutdownGraphics(); SDL_PauseAudio(1); SDL_CloseAudio(); - NativeShutdown(); #ifdef USING_EGL EGL_Close(); #endif From b811dfc51bd97daf8c9b52443cece1fbe78d9b13 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Fri, 25 Dec 2015 19:41:17 -0800 Subject: [PATCH 3/3] Actually, might as well on all platforms. --- UI/MainScreen.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/UI/MainScreen.cpp b/UI/MainScreen.cpp index d7d726f514..168953b29e 100644 --- a/UI/MainScreen.cpp +++ b/UI/MainScreen.cpp @@ -1085,13 +1085,14 @@ UI::EventReturn MainScreen::OnExit(UI::EventParams &e) { // Request the framework to exit cleanly. System_SendMessage("finish", ""); + // However, let's make sure the config was saved, since it may not have been. + g_Config.Save(); + // We shouldn't call NativeShutdown here at all, it should be done by the framework. #ifdef ANDROID #ifdef ANDROID_NDK_PROFILER moncleanup(); #endif - // However, let's make sure the config was saved, since it may not have been. - g_Config.Save(); exit(0); #endif