From 7807548be65a75a8811d8fd65de2c4fc3cb92931 Mon Sep 17 00:00:00 2001 From: OBattler Date: Sat, 2 Nov 2019 16:18:18 +0100 Subject: [PATCH] Reworked the behavior of the shutdown status message, and the virtual machine and manager window messages are now paused in case of a message box issued by a command from the manager. --- src/win/win.c | 32 +++++++++++++++++--------------- src/win/win.h | 6 +++--- src/win/win_settings.c | 6 +++--- src/win/win_ui.c | 40 ++++++++++++++++++++++++++++++---------- 4 files changed, 53 insertions(+), 31 deletions(-) diff --git a/src/win/win.c b/src/win/win.c index ac91ac436..8afaa3c27 100644 --- a/src/win/win.c +++ b/src/win/win.c @@ -8,7 +8,7 @@ * * Platform main support module for Windows. * - * Version: @(#)win.c 1.0.58 2019/10/19 + * Version: @(#)win.c 1.0.59 2019/11/02 * * Authors: Sarah Walker, * Miran Grca, @@ -197,11 +197,6 @@ set_language(int id) /* Load the strings table for this ID. */ LoadCommonStrings(); - -#if 0 - /* Update the menus for this ID. */ - MenuUpdate(); -#endif } } @@ -344,6 +339,14 @@ ProcessCommandLine(wchar_t ***argw) } +static void +shutdown_notify(void) +{ + if (source_hwnd) + PostMessage((HWND) (uintptr_t) source_hwnd, WM_SENDSDSTATUS, (WPARAM) 1, (LPARAM) hwndMain); +} + + /* For the Windows platform, this is the start of the application. */ int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPSTR lpszArg, int nCmdShow) @@ -381,6 +384,10 @@ WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPSTR lpszArg, int nCmdShow) if (! pc_init(argc, argw)) { /* Detach from console. */ CreateConsole(0); + + if (source_hwnd) + PostMessage((HWND) (uintptr_t) source_hwnd, WM_SENDSDSTATUS, (WPARAM) 1, (LPARAM) hwndMain); + return(1); } @@ -391,6 +398,8 @@ WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPSTR lpszArg, int nCmdShow) /* Handle our GUI. */ i = ui_init(nCmdShow); + atexit(shutdown_notify); + return(i); } @@ -428,6 +437,8 @@ do_stop(void) plat_delay_ms(100); + shutdown_notify(); + pc_close(thMain); thMain = NULL; @@ -627,7 +638,6 @@ plat_dir_check(wchar_t *path) int plat_dir_create(wchar_t *path) { - // return((int)CreateDirectory(path, NULL)); return((int)SHCreateDirectory(hwndMain, path)); } @@ -696,10 +706,6 @@ plat_vidapi_name(int api) break; case 2: -#if 0 - /* Direct3D is default. */ - name = "d3d"; -#endif break; case 3: @@ -707,10 +713,6 @@ plat_vidapi_name(int api) break; #else case 1: -#if 0 - /* Direct3D is default. */ - name = "d3d"; -#endif break; case 2: diff --git a/src/win/win.h b/src/win/win.h index 747c8c616..554e7b40e 100644 --- a/src/win/win.h +++ b/src/win/win.h @@ -8,7 +8,7 @@ * * Platform support defintions for Win32. * - * Version: @(#)win.h 1.0.26 2019/11/01 + * Version: @(#)win.h 1.0.27 2019/11/02 * * Authors: Sarah Walker, * Miran Grca, @@ -57,8 +57,8 @@ #define WM_SENDSTATUS 0x8895 /* Settings status: WPARAM = 1 for open, 0 for closed. */ #define WM_SENDSSTATUS 0x8896 -/* Emulator shut down. */ -#define WM_SHUTDOWN_DONE 0x8897 +/* Emulator shut down status: WPARAM = 1 for user said yes, 0 for use said no. */ +#define WM_SENDSDSTATUS 0x8897 #ifdef USE_VNC #ifdef USE_D2D diff --git a/src/win/win_settings.c b/src/win/win_settings.c index ab5a5baa8..7c60ec5b1 100644 --- a/src/win/win_settings.c +++ b/src/win/win_settings.c @@ -8,7 +8,7 @@ * * Windows 86Box Settings dialog handler. * - * Version: @(#)win_settings.c 1.0.57 2019/11/01 + * Version: @(#)win_settings.c 1.0.58 2019/11/02 * * Authors: Miran Grca, * David Hrdlička, @@ -4502,7 +4502,7 @@ win_settings_confirm(HWND hdlg, int button) DestroyWindow(hwndChildDialog); EndDialog(hdlg, 0); - plat_pause(0); + plat_pause(dopause); win_settings_communicate_closure(); return button ? TRUE : FALSE; @@ -4555,7 +4555,7 @@ win_settings_main_proc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam) case IDCANCEL: DestroyWindow(hwndChildDialog); EndDialog(hdlg, 0); - plat_pause(0); + plat_pause(dopause); win_settings_communicate_closure(); return TRUE; } diff --git a/src/win/win_ui.c b/src/win/win_ui.c index a23d74361..f15cea020 100644 --- a/src/win/win_ui.c +++ b/src/win/win_ui.c @@ -8,7 +8,7 @@ * * user Interface module for WinAPI on Windows. * - * Version: @(#)win_ui.c 1.0.41 2019/11/01 + * Version: @(#)win_ui.c 1.0.42 2019/11/02 * * Authors: Sarah Walker, * Miran Grca, @@ -64,7 +64,7 @@ WCHAR wopenfilestring[260]; /* Local data. */ static wchar_t wTitle[512]; static HHOOK hKeyboardHook; -static int hook_enabled = 0; +static int hook_enabled = 0, manager_wm = 0; static int save_window_pos = 0; @@ -309,8 +309,6 @@ MainWindowProcedure(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) case IDM_ACTION_EXIT: i = ui_msgbox(MBX_QUESTION_YN, (wchar_t *)IDS_2122); if (i == 0) { - if (source_hwnd) - PostMessage((HWND) (uintptr_t) source_hwnd, WM_SHUTDOWN_DONE, (WPARAM) 0, (LPARAM) hwndMain); UnhookWindowsHookEx(hKeyboardHook); KillTimer(hwnd, TIMER_1SEC); PostQuitMessage(0); @@ -673,8 +671,6 @@ MainWindowProcedure(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) case WM_CLOSE: i = ui_msgbox(MBX_QUESTION_YN, (wchar_t *)IDS_2122); if (i == 0) { - if (source_hwnd) - PostMessage((HWND) (uintptr_t) source_hwnd, WM_SHUTDOWN_DONE, (WPARAM) 0, (LPARAM) hwndMain); UnhookWindowsHookEx(hKeyboardHook); KillTimer(hwnd, TIMER_1SEC); PostQuitMessage(0); @@ -682,41 +678,65 @@ MainWindowProcedure(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) break; case WM_DESTROY: - if (source_hwnd) - PostMessage((HWND) (uintptr_t) source_hwnd, WM_SHUTDOWN_DONE, (WPARAM) 0, (LPARAM) hwndMain); UnhookWindowsHookEx(hKeyboardHook); KillTimer(hwnd, TIMER_1SEC); PostQuitMessage(0); break; case WM_SHOWSETTINGS: + if (manager_wm) + break; + manager_wm = 1; win_settings_open(hwnd); + manager_wm = 0; break; case WM_PAUSE: + if (manager_wm) + break; + manager_wm = 1; plat_pause(dopause ^ 1); CheckMenuItem(menuMain, IDM_ACTION_PAUSE, dopause ? MF_CHECKED : MF_UNCHECKED); + plat_pause(dopause); + manager_wm = 0; break; case WM_HARDRESET: + if (manager_wm) + break; + manager_wm = 1; + plat_pause(1); i = ui_msgbox(MBX_QUESTION_YN, (wchar_t *)IDS_2121); + plat_pause(dopause); if (i == 0) pc_reset(1); + manager_wm = 0; break; case WM_SHUTDOWN: + if (manager_wm) + break; + manager_wm = 1; + plat_pause(1); i = ui_msgbox(MBX_QUESTION_YN, (wchar_t *)IDS_2122); + plat_pause(dopause); if (i == 0) { - if (source_hwnd) - PostMessage((HWND) (uintptr_t) source_hwnd, WM_SHUTDOWN_DONE, (WPARAM) 0, (LPARAM) hwndMain); UnhookWindowsHookEx(hKeyboardHook); KillTimer(hwnd, TIMER_1SEC); PostQuitMessage(0); + } else { + if (source_hwnd) + PostMessage((HWND) (uintptr_t) source_hwnd, WM_SENDSDSTATUS, (WPARAM) 0, (LPARAM) hwndMain); } + manager_wm = 0; break; case WM_CTRLALTDEL: + if (manager_wm) + break; + manager_wm = 1; pc_reset(0); + manager_wm = 0; break; case WM_SYSCOMMAND: