From 08df2baad0e7d0d460d242f22aeaa9a6d7a1aae5 Mon Sep 17 00:00:00 2001 From: Peter Date: Thu, 16 May 2013 02:06:23 +0000 Subject: [PATCH] In the Win32 build only, allow the user to hide the console window since a typical end-user won't care about the contents. --- src/config.c | 14 ++++++++++++-- src/win_console.c | 15 ++++++++++++++- src/win_generic.c | 13 ++++++++++--- 3 files changed, 36 insertions(+), 6 deletions(-) diff --git a/src/config.c b/src/config.c index e947b5d..fc63cd8 100644 --- a/src/config.c +++ b/src/config.c @@ -93,7 +93,8 @@ extern char* g_printer_font_script; extern char* g_printer_font_ocra; extern int g_printer_timeout; #ifdef _WIN32 -extern int g_win_status_debug_request; +extern int g_win_show_console_request; +extern int g_win_status_debug_request; #endif extern int g_screen_index[]; @@ -278,6 +279,15 @@ Cfg_menu g_cfg_printer_menu[] = { { 0, 0, 0, 0, 0 }, }; +Cfg_menu g_cfg_debug_menu[] = { +{ "Debugging Options", g_cfg_debug_menu, 0, 0, CFGTYPE_MENU }, +{ "Status lines,0,Hide,1,Show", KNMP(g_win_status_debug_request), CFGTYPE_INT }, +{ "Console,0,Hide,1,Show", KNMP(g_win_show_console_request), CFGTYPE_INT }, +{ "", 0, 0, 0, 0 }, +{ "Back to Main Config", g_cfg_main_menu, 0, 0, CFGTYPE_MENU }, +{ 0, 0, 0, 0, 0 }, +}; + Cfg_menu g_cfg_main_menu[] = { { "GSport Configuration", g_cfg_main_menu, 0, 0, CFGTYPE_MENU }, { "Disk Configuration", g_cfg_disk_menu, 0, 0, CFGTYPE_MENU }, @@ -291,7 +301,7 @@ Cfg_menu g_cfg_main_menu[] = { { "Force X-windows display depth", KNMP(g_force_depth), CFGTYPE_INT }, #endif #ifdef _WIN32 -{ "Debug status lines,0,Hide,1,Show", KNMP(g_win_status_debug_request), CFGTYPE_INT }, +{ "Debugging Options", g_cfg_debug_menu, 0, 0, CFGTYPE_MENU }, #endif { "Auto-update configuration file,0,Manual,1,Immediately", KNMP(g_config_gsport_auto_update), CFGTYPE_INT }, diff --git a/src/win_console.c b/src/win_console.c index 9980627..3bb92f6 100644 --- a/src/win_console.c +++ b/src/win_console.c @@ -110,6 +110,16 @@ void x_toggle_status_lines() } } +void x_show_console(int show) +{ + HWND hWnd = ::GetConsoleWindow(); + if (hWnd) + ::ShowWindow(hWnd, show ? SW_SHOW : SW_HIDE); + + if (g_hwnd_main) + ::SetFocus(g_hwnd_main); +} + int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd) { return main(0,0); @@ -118,6 +128,10 @@ int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLin int main(int argc, char **argv) { + // Hide the console initially to reduce window flashing. We'll show the console later if needed. + x_show_console(0); + + // Register the window class. WNDCLASS wndclass; SIZE size; RECT rect; @@ -133,7 +147,6 @@ main(int argc, char **argv) wndclass.lpszMenuName = NULL; wndclass.lpszClassName = "gsport"; - // Register the window if(!RegisterClass(&wndclass)) { printf("Registering window failed\n"); exit(1); diff --git a/src/win_generic.c b/src/win_generic.c index 5e6dd66..c7483ae 100644 --- a/src/win_generic.c +++ b/src/win_generic.c @@ -44,6 +44,7 @@ extern int g_config_control_panel; extern void quitEmulator(); extern void x_toggle_status_lines(); +extern void x_show_console(int show); extern void x_check_input_events(); int g_win_capslock_down = 0; @@ -58,8 +59,10 @@ BITMAPINFO *g_bmapinfo_ptr = 0; volatile BITMAPINFOHEADER *g_bmaphdr_ptr = 0; // KEGS32 specific customisations -int g_win_status_debug = 1; // Current visibility of status lines. -int g_win_status_debug_request = 1; // Desired visibility of status lines. +int g_win_status_debug = 1; // Current visibility of status lines. +int g_win_status_debug_request = 1; // Desired visibility of status lines. +int g_win_show_console = 0; // Current visibility of console. +int g_win_show_console_request = 1; // Desired visibility of console. RECT g_main_window_saved_rect; int g_win_fullscreen_state = 0; @@ -373,7 +376,11 @@ check_input_events() if (g_win_status_debug_request != g_win_status_debug) x_toggle_status_lines(); - + if (g_win_show_console_request != g_win_show_console) + { + g_win_show_console = g_win_show_console_request; + x_show_console(g_win_show_console_request); + } } void