From e8c512a8986b79212898dc8004e11c785d32c17c Mon Sep 17 00:00:00 2001 From: Peter Date: Tue, 19 Mar 2013 22:11:01 +0000 Subject: [PATCH] Allow Windows users to hide the debug status lines with Shift-F10. --- doc/web/src/site/apt/operating.apt | 1 + src/adb.c | 9 +++++- src/win_console.c | 44 +++++++++++++++++++++++------- 3 files changed, 43 insertions(+), 11 deletions(-) diff --git a/doc/web/src/site/apt/operating.apt b/doc/web/src/site/apt/operating.apt index a91a28d..198da77 100644 --- a/doc/web/src/site/apt/operating.apt +++ b/doc/web/src/site/apt/operating.apt @@ -121,6 +121,7 @@ F8: Toggle pointer hiding on/off. F9: Invert the sense of the joystick. Shift-F9: Swap x and y joystick/paddle axes. F10: Attempt to change the a2vid_palette (only useful on 256-color displays) +Shift-F10: Toggle visibility of the debug status lines (on Windows only) F11: Full screen mode (on Mac OS X and Windows). F12: Alias of Pause/Break which is treated as Reset diff --git a/src/adb.c b/src/adb.c index 3d4c2ca..0e0a3a7 100644 --- a/src/adb.c +++ b/src/adb.c @@ -1776,7 +1776,14 @@ adb_physical_key_update(int a2code, int is_up) } break; case 0x0a: /* F10 - change a2vid paletter */ - change_a2vid_palette((g_a2vid_palette + 1) & 0xf); + if (SHIFT_DOWN) { +#ifdef WIN32 + extern void x_toggle_status_lines(); + x_toggle_status_lines(); +#endif + } else { + change_a2vid_palette((g_a2vid_palette + 1) & 0xf); + } break; case 0x0b: /* F11 - full screen */ g_fullscreen = !g_fullscreen; diff --git a/src/win_console.c b/src/win_console.c index d5b9cdb..6b20c39 100644 --- a/src/win_console.c +++ b/src/win_console.c @@ -36,6 +36,7 @@ extern HWND g_hwnd_main; extern char *g_status_ptrs[MAX_STATUS_LINES]; extern int g_win_status_debug; +extern int g_win_fullscreen_state; int win_nonblock_read_stdin(int fd, char *bufptr, int len) @@ -79,15 +80,37 @@ x_show_alert(int is_fatal, const char *str) return 0; } -void get_default_window_size(LPRECT rect) +void get_default_window_size(LPSIZE size) { - rect->left = 0; - rect->top = 0; - rect->bottom = X_A2_WINDOW_HEIGHT; + // Calculate the window client dimensions. + RECT rect; + rect.left = 0; + rect.top = 0; + rect.bottom = X_A2_WINDOW_HEIGHT; if (g_win_status_debug) - rect->bottom += (MAX_STATUS_LINES * 16) + 32; - rect->right = X_A2_WINDOW_WIDTH; - AdjustWindowRect(rect, WS_TILED | WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX, FALSE); + rect.bottom += (MAX_STATUS_LINES * 16); + rect.right = X_A2_WINDOW_WIDTH; + + // Calculate the window rectangle, which is the client area plus non-client area (e.g. frame and caption). + AdjustWindowRect(&rect, WS_TILED | WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX, FALSE); + + // Return the window size. + size->cx = rect.right - rect.left; + size->cy = rect.bottom - rect.top; +} + +void x_toggle_status_lines() +{ + SIZE size; + + if (!g_win_fullscreen_state) + { + g_win_status_debug = !g_win_status_debug; + + get_default_window_size(&size); + SetWindowPos(g_hwnd_main, NULL, 0, 0, size.cx, size.cy, SWP_NOMOVE | SWP_NOZORDER); + x_redraw_status_lines(); + } } int WINAPI WinMain ( @@ -105,6 +128,7 @@ main(int argc, char **argv) // InitCommonControls(); WNDCLASS wndclass; + SIZE size; RECT rect; wndclass.style = 0; @@ -125,15 +149,15 @@ main(int argc, char **argv) } // Create the window. - get_default_window_size(&rect); + get_default_window_size(&size); HWND hwnd = CreateWindowEx(WS_EX_ACCEPTFILES, "gsport", "GSport - Apple //gs Emulator", WS_TILED | WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX, CW_USEDEFAULT, CW_USEDEFAULT, - rect.right, rect.bottom, + size.cx, size.cy, NULL, NULL, GetModuleHandle(NULL), NULL); - printf("g_hwnd_main = %p, height = %d\n", hwnd, rect.bottom); + printf("g_hwnd_main = %p, height = %d\n", hwnd, size.cx); GetWindowRect(hwnd, &rect); printf("...rect is: %ld, %ld, %ld, %ld\n", rect.left, rect.top, rect.right, rect.bottom);