Skip to content
This repository was archived by the owner on Sep 29, 2025. It is now read-only.

Commit 446723b

Browse files
authored
Merge pull request #1578 from reicast/z/win32-fullscreen
Win32 fullscreen via alt-enter
2 parents 1e04de0 + c681dc7 commit 446723b

File tree

2 files changed

+52
-1
lines changed

2 files changed

+52
-1
lines changed

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,7 @@ if(${BUILD_COMPILER} EQUAL ${COMPILER_GCC}) # Add Clang if NOT WIN32 *FIXME*
158158
${lzma_SRCS}
159159
${pico_SRCS}
160160
)
161+
add_definitions(-D_7ZIP_ST -DCHD5_LZMA)
161162
endif()
162163

163164
### libosd.cmake ################################################################################
@@ -243,7 +244,6 @@ endif()
243244

244245
include_directories ("${reicast_core_path}")
245246

246-
add_definitions(-D_7ZIP_ST -DCHD5_LZMA)
247247

248248

249249

core/windows/winmain.cpp

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,10 @@ extern f32 mo_wheel_delta;
198198
// Keyboard
199199
static Win32KeyboardDevice keyboard(0);
200200

201+
202+
void ToggleFullscreen();
203+
204+
201205
void UpdateInputState(u32 port)
202206
{
203207
/*
@@ -331,6 +335,14 @@ LRESULT CALLBACK WndProc2(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
331335
keyboard.keyboard_input(keycode, message == WM_KEYDOWN);
332336
}
333337
break;
338+
339+
case WM_SYSKEYDOWN:
340+
if (wParam == VK_RETURN)
341+
if ((HIWORD(lParam) & KF_ALTDOWN))
342+
ToggleFullscreen();
343+
344+
break;
345+
334346
case WM_CHAR:
335347
keyboard.keyboard_character((char)wParam);
336348
return 0;
@@ -388,6 +400,45 @@ void* libPvr_GetRenderSurface()
388400
return GetDC((HWND)window_win);
389401
}
390402

403+
404+
void ToggleFullscreen()
405+
{
406+
static RECT rSaved;
407+
static bool fullscreen=false;
408+
HWND hWnd = (HWND)window_win;
409+
410+
fullscreen = !fullscreen;
411+
412+
413+
if (fullscreen)
414+
{
415+
GetWindowRect(hWnd, &rSaved);
416+
417+
MONITORINFO mi = { sizeof(mi) };
418+
HMONITOR hmon = MonitorFromWindow(hWnd, MONITOR_DEFAULTTONEAREST);
419+
if (GetMonitorInfo(hmon, &mi)) {
420+
421+
SetWindowLongPtr(hWnd, GWL_EXSTYLE, WS_EX_APPWINDOW | WS_EX_TOPMOST);
422+
SetWindowLongPtr(hWnd, GWL_STYLE, WS_POPUP | WS_VISIBLE);
423+
424+
SetWindowPos(hWnd, HWND_TOPMOST, mi.rcMonitor.left, mi.rcMonitor.top,
425+
mi.rcMonitor.right - mi.rcMonitor.left, mi.rcMonitor.bottom - mi.rcMonitor.top,
426+
SWP_SHOWWINDOW|SWP_FRAMECHANGED|SWP_ASYNCWINDOWPOS);
427+
}
428+
}
429+
else {
430+
431+
SetWindowLongPtr(hWnd, GWL_EXSTYLE, WS_EX_APPWINDOW | WS_EX_TOPMOST);
432+
SetWindowLongPtr(hWnd, GWL_STYLE, WS_VISIBLE | WS_OVERLAPPEDWINDOW | (window_maximized ? WS_MAXIMIZE : 0));
433+
434+
SetWindowPos(hWnd, NULL, rSaved.left, rSaved.top,
435+
rSaved.right - rSaved.left, rSaved.bottom - rSaved.top,
436+
SWP_SHOWWINDOW|SWP_FRAMECHANGED|SWP_ASYNCWINDOWPOS|SWP_NOZORDER);
437+
}
438+
439+
}
440+
441+
391442
BOOL CtrlHandler( DWORD fdwCtrlType )
392443
{
393444
switch( fdwCtrlType )

0 commit comments

Comments
 (0)