MCPcopy Create free account
hub / github.com/AppleWin/AppleWin / SetFullScreenMode

Method SetFullScreenMode

source/Windows/WinFrame.cpp:2736–2808  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2734}
2735
2736void Win32Frame::SetFullScreenMode(void)
2737{
2738#ifdef NO_DIRECT_X
2739
2740 return;
2741
2742#else // NO_DIRECT_X
2743
2744 if (m_bestWidthForFullScreen && m_bestHeightForFullScreen)
2745 {
2746 DEVMODE devMode;
2747 memset(&devMode, 0, sizeof(devMode));
2748 devMode.dmSize = sizeof(devMode);
2749 devMode.dmPelsWidth = m_bestWidthForFullScreen;
2750 devMode.dmPelsHeight = m_bestHeightForFullScreen;
2751 devMode.dmFields = DM_PELSWIDTH | DM_PELSHEIGHT;
2752
2753 uint32_t dwFlags = 0;
2754 LONG res = ChangeDisplaySettings(&devMode, dwFlags);
2755 m_changedDisplaySettings = true;
2756 }
2757
2758 //
2759
2760 MONITORINFO monitor_info;
2761 FULLSCREEN_SCALE_TYPE width, height, scalex, scaley;
2762 int top, left;
2763
2764 buttonover = -1;
2765
2766 g_main_window_saved_style = GetWindowLong(g_hFrameWindow, GWL_STYLE);
2767 g_main_window_saved_exstyle = GetWindowLong(g_hFrameWindow, GWL_EXSTYLE);
2768 GetWindowRect(g_hFrameWindow, &g_main_window_saved_rect);
2769 SetWindowLong(g_hFrameWindow, GWL_STYLE , g_main_window_saved_style & ~(WS_CAPTION | WS_THICKFRAME));
2770 SetWindowLong(g_hFrameWindow, GWL_EXSTYLE, g_main_window_saved_exstyle & ~(WS_EX_DLGMODALFRAME | WS_EX_WINDOWEDGE | WS_EX_CLIENTEDGE | WS_EX_STATICEDGE));
2771
2772 monitor_info.cbSize = sizeof(monitor_info);
2773 GetMonitorInfo(MonitorFromWindow(g_hFrameWindow, MONITOR_DEFAULTTONEAREST), &monitor_info);
2774
2775 left = monitor_info.rcMonitor.left;
2776 top = monitor_info.rcMonitor.top;
2777
2778 width = (FULLSCREEN_SCALE_TYPE)(monitor_info.rcMonitor.right - monitor_info.rcMonitor.left);
2779 height = (FULLSCREEN_SCALE_TYPE)(monitor_info.rcMonitor.bottom - monitor_info.rcMonitor.top );
2780
2781 scalex = width / GetVideo().GetFrameBufferBorderlessWidth();
2782 scaley = height / GetVideo().GetFrameBufferBorderlessHeight();
2783
2784 // Retain aspect ratio if user hasn't changed full-screen resolution (GH#1121)
2785 if (!GetFullScreenResolutionChangedByUser())
2786 {
2787 const int minimumScale = (scalex <= scaley) ? scalex : scaley;
2788 scalex = scaley = minimumScale;
2789 }
2790
2791 // NB. Separate x,y scaling is OK in full-screen mode
2792 // . eg. SHR 640x400 (scalex=2, scaley=3) => 1280x1200, which roughly gives a 4:3 aspect ratio for a resolution of 1600x1200
2793 g_win_fullscreen_offsetx = ((int)width - (int)(scalex * GetVideo().GetFrameBufferBorderlessWidth())) / 2;

Callers

nothing calls this directly

Tested by

no test coverage detected