diff --git a/source/CmdLine.cpp b/source/CmdLine.cpp index 9e8268b2..9a196e98 100644 --- a/source/CmdLine.cpp +++ b/source/CmdLine.cpp @@ -199,16 +199,17 @@ bool ProcessCmdLine(LPSTR lpCmdLine) } else if (strcmp(lpCmdLine, "-f") == 0 || strcmp(lpCmdLine, "-full-screen") == 0) { - g_cmdLine.bSetFullScreen = true; + g_cmdLine.setFullScreen = 1; } else if (strcmp(lpCmdLine, "-no-full-screen") == 0) { - g_cmdLine.bSetFullScreen = false; + g_cmdLine.setFullScreen = 0; } #define CMD_FS_HEIGHT "-fs-height=" else if (strncmp(lpCmdLine, CMD_FS_HEIGHT, sizeof(CMD_FS_HEIGHT)-1) == 0) { - g_cmdLine.bSetFullScreen = true; // Implied. Can be overridden by "-no-full-screen" + if (g_cmdLine.setFullScreen < 0) // Not yet been specified on cmd line? + g_cmdLine.setFullScreen = 1; // Implicity set full-screen. NB. Can be overridden by "-no-full-screen" LPSTR lpTmp = lpCmdLine + sizeof(CMD_FS_HEIGHT)-1; bool bRes = false; diff --git a/source/CmdLine.h b/source/CmdLine.h index cce9b993..d8c21a05 100644 --- a/source/CmdLine.h +++ b/source/CmdLine.h @@ -12,9 +12,8 @@ struct CmdLine CmdLine() { bShutdown = false; - bSetFullScreen = false; + setFullScreen = -1; bBoot = false; - bChangedDisplayResolution = false; bSlot0LanguageCard = false; bSlot7EmptyOnExit = false; bSwapButtons0and1 = false; @@ -49,9 +48,8 @@ struct CmdLine } bool bShutdown; - bool bSetFullScreen; + int setFullScreen; // tristate: -1 (no cmd line specified), 0="-no-full-screen", 1="-full-screen" bool bBoot; - bool bChangedDisplayResolution; bool bSlot0LanguageCard; bool bSlotEmpty[NUM_SLOTS]; bool bSlot7EmptyOnExit; diff --git a/source/Windows/AppleWin.cpp b/source/Windows/AppleWin.cpp index dda970dc..3a8c0dd5 100644 --- a/source/Windows/AppleWin.cpp +++ b/source/Windows/AppleWin.cpp @@ -643,7 +643,7 @@ int APIENTRY WinMain(HINSTANCE passinstance, HINSTANCE, LPSTR lpCmdLine, int) if (g_bRestart) { - g_cmdLine.bSetFullScreen = g_bRestartFullScreen; + g_cmdLine.setFullScreen = g_bRestartFullScreen ? 1 : 0; g_bRestartFullScreen = false; MB_Reset(true); @@ -981,25 +981,10 @@ static void RepeatInitialization(void) } else { - if (g_cmdLine.bestWidth && g_cmdLine.bestHeight) - { - DEVMODE devMode; - memset(&devMode, 0, sizeof(devMode)); - devMode.dmSize = sizeof(devMode); - devMode.dmPelsWidth = g_cmdLine.bestWidth; - devMode.dmPelsHeight = g_cmdLine.bestHeight; - devMode.dmFields = DM_PELSWIDTH | DM_PELSHEIGHT; - - DWORD dwFlags = 0; - LONG res = ChangeDisplaySettings(&devMode, dwFlags); - if (res == 0) - g_cmdLine.bChangedDisplayResolution = true; - } - - if (g_cmdLine.bSetFullScreen) + if (g_cmdLine.setFullScreen > 0) { PostMessage(GetFrame().g_hFrameWindow, WM_USER_FULLSCREEN, 0, 0); - g_cmdLine.bSetFullScreen = false; + g_cmdLine.setFullScreen = 0; } if (g_cmdLine.bBoot) @@ -1012,8 +997,7 @@ static void RepeatInitialization(void) static void Shutdown(void) { - if (g_cmdLine.bChangedDisplayResolution) - ChangeDisplaySettings(NULL, 0); // restore default + ChangeDisplaySettings(NULL, 0); // restore default resolution // Release COM SysClk_UninitTimer(); diff --git a/source/Windows/Win32Frame.cpp b/source/Windows/Win32Frame.cpp index 4f2282d4..e4173b22 100644 --- a/source/Windows/Win32Frame.cpp +++ b/source/Windows/Win32Frame.cpp @@ -36,6 +36,8 @@ Win32Frame::Win32Frame() g_win_fullscreen_scale = 1; g_win_fullscreen_offsetx = 0; g_win_fullscreen_offsety = 0; + m_bestWidthForFullScreen = 0; + m_bestHeightForFullScreen = 0; btnfacebrush = (HBRUSH)0; btnfacepen = (HPEN)0; diff --git a/source/Windows/Win32Frame.h b/source/Windows/Win32Frame.h index 41070172..6ec88fb8 100644 --- a/source/Windows/Win32Frame.h +++ b/source/Windows/Win32Frame.h @@ -96,8 +96,8 @@ private: bool ConfirmReboot(bool bFromButtonUI); void ProcessDiskPopupMenu(HWND hwnd, POINT pt, const int iDrive); void RelayEvent(UINT message, WPARAM wparam, LPARAM lparam); - void SetFullScreenMode(); - void SetNormalMode(); + void SetFullScreenMode(void); + void SetNormalMode(void); void SetUsingCursor(BOOL bNewValue); void SetupTooltipControls(void); void FrameResizeWindow(int nNewScale); @@ -132,6 +132,8 @@ private: FULLSCREEN_SCALE_TYPE g_win_fullscreen_scale; int g_win_fullscreen_offsetx; int g_win_fullscreen_offsety; + UINT m_bestWidthForFullScreen; + UINT m_bestHeightForFullScreen; static const UINT MAX_DRAW_DEVICES = 10; char* draw_devices[MAX_DRAW_DEVICES]; diff --git a/source/Windows/WinFrame.cpp b/source/Windows/WinFrame.cpp index 6fe59df7..f8c70897 100644 --- a/source/Windows/WinFrame.cpp +++ b/source/Windows/WinFrame.cpp @@ -2107,7 +2107,7 @@ int Win32Frame::GetFullScreenOffsetY(void) return g_win_fullscreen_offsety; } -void Win32Frame::SetFullScreenMode () +void Win32Frame::SetFullScreenMode(void) { #ifdef NO_DIRECT_X @@ -2115,6 +2115,21 @@ void Win32Frame::SetFullScreenMode () #else // NO_DIRECT_X + if (m_bestWidthForFullScreen && m_bestHeightForFullScreen) + { + DEVMODE devMode; + memset(&devMode, 0, sizeof(devMode)); + devMode.dmSize = sizeof(devMode); + devMode.dmPelsWidth = m_bestWidthForFullScreen; + devMode.dmPelsHeight = m_bestHeightForFullScreen; + devMode.dmFields = DM_PELSWIDTH | DM_PELSHEIGHT; + + DWORD dwFlags = 0; + LONG res = ChangeDisplaySettings(&devMode, dwFlags); + } + + // + MONITORINFO monitor_info; FULLSCREEN_SCALE_TYPE width, height, scalex, scaley; int top, left; @@ -2158,8 +2173,10 @@ void Win32Frame::SetFullScreenMode () } //=========================================================================== -void Win32Frame::SetNormalMode () +void Win32Frame::SetNormalMode(void) { + ChangeDisplaySettings(NULL, 0); // restore default resolution + FullScreenRevealCursor(); // Do before clearing g_bIsFullScreen flag buttonover = -1; @@ -2682,6 +2699,9 @@ void Win32Frame::FrameUpdateApple2Type(void) bool Win32Frame::GetBestDisplayResolutionForFullScreen(UINT& bestWidth, UINT& bestHeight, UINT userSpecifiedHeight /*= 0*/) { + m_bestWidthForFullScreen = 0; + m_bestHeightForFullScreen = 0; + typedef std::vector< std::pair > VEC_PAIR; VEC_PAIR vecDisplayResolutions; @@ -2733,6 +2753,9 @@ bool Win32Frame::GetBestDisplayResolutionForFullScreen(UINT& bestWidth, UINT& be bestWidth = width; bestHeight = userSpecifiedHeight; + + m_bestWidthForFullScreen = bestWidth; + m_bestHeightForFullScreen = bestHeight; return true; } @@ -2760,5 +2783,8 @@ bool Win32Frame::GetBestDisplayResolutionForFullScreen(UINT& bestWidth, UINT& be bestWidth = tmpBestWidth; bestHeight = tmpBestHeight; + + m_bestWidthForFullScreen = bestWidth; + m_bestHeightForFullScreen = bestHeight; return true; }