From c681dc77dc8a2d7b9b8d12dc6291c2fe9eed692f Mon Sep 17 00:00:00 2001 From: david miller Date: Wed, 1 May 2019 19:11:35 -0400 Subject: [PATCH] Win32 fullscreen via alt-enter --- CMakeLists.txt | 2 +- core/windows/winmain.cpp | 51 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 52 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 9a757f3d0..80342e0d2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -158,6 +158,7 @@ if(${BUILD_COMPILER} EQUAL ${COMPILER_GCC}) # Add Clang if NOT WIN32 *FIXME* ${lzma_SRCS} ${pico_SRCS} ) + add_definitions(-D_7ZIP_ST -DCHD5_LZMA) endif() ### libosd.cmake ################################################################################ @@ -243,7 +244,6 @@ endif() include_directories ("${reicast_core_path}") -add_definitions(-D_7ZIP_ST -DCHD5_LZMA) diff --git a/core/windows/winmain.cpp b/core/windows/winmain.cpp index 27d651dd4..029ba1246 100644 --- a/core/windows/winmain.cpp +++ b/core/windows/winmain.cpp @@ -198,6 +198,10 @@ extern f32 mo_wheel_delta; // Keyboard static Win32KeyboardDevice keyboard(0); + +void ToggleFullscreen(); + + void UpdateInputState(u32 port) { /* @@ -331,6 +335,14 @@ LRESULT CALLBACK WndProc2(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) keyboard.keyboard_input(keycode, message == WM_KEYDOWN); } break; + + case WM_SYSKEYDOWN: + if (wParam == VK_RETURN) + if ((HIWORD(lParam) & KF_ALTDOWN)) + ToggleFullscreen(); + + break; + case WM_CHAR: keyboard.keyboard_character((char)wParam); return 0; @@ -388,6 +400,45 @@ void* libPvr_GetRenderSurface() return GetDC((HWND)window_win); } + +void ToggleFullscreen() +{ + static RECT rSaved; + static bool fullscreen=false; + HWND hWnd = (HWND)window_win; + + fullscreen = !fullscreen; + + + if (fullscreen) + { + GetWindowRect(hWnd, &rSaved); + + MONITORINFO mi = { sizeof(mi) }; + HMONITOR hmon = MonitorFromWindow(hWnd, MONITOR_DEFAULTTONEAREST); + if (GetMonitorInfo(hmon, &mi)) { + + SetWindowLongPtr(hWnd, GWL_EXSTYLE, WS_EX_APPWINDOW | WS_EX_TOPMOST); + SetWindowLongPtr(hWnd, GWL_STYLE, WS_POPUP | WS_VISIBLE); + + SetWindowPos(hWnd, HWND_TOPMOST, mi.rcMonitor.left, mi.rcMonitor.top, + mi.rcMonitor.right - mi.rcMonitor.left, mi.rcMonitor.bottom - mi.rcMonitor.top, + SWP_SHOWWINDOW|SWP_FRAMECHANGED|SWP_ASYNCWINDOWPOS); + } + } + else { + + SetWindowLongPtr(hWnd, GWL_EXSTYLE, WS_EX_APPWINDOW | WS_EX_TOPMOST); + SetWindowLongPtr(hWnd, GWL_STYLE, WS_VISIBLE | WS_OVERLAPPEDWINDOW | (window_maximized ? WS_MAXIMIZE : 0)); + + SetWindowPos(hWnd, NULL, rSaved.left, rSaved.top, + rSaved.right - rSaved.left, rSaved.bottom - rSaved.top, + SWP_SHOWWINDOW|SWP_FRAMECHANGED|SWP_ASYNCWINDOWPOS|SWP_NOZORDER); + } + +} + + BOOL CtrlHandler( DWORD fdwCtrlType ) { switch( fdwCtrlType )