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.

This commit is contained in:
OBattler
2019-11-02 16:18:18 +01:00
parent ee77bc1471
commit 7807548be6
4 changed files with 53 additions and 31 deletions

View File

@@ -8,7 +8,7 @@
* *
* Platform main support module for Windows. * 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, <http://pcem-emulator.co.uk/> * Authors: Sarah Walker, <http://pcem-emulator.co.uk/>
* Miran Grca, <mgrca8@gmail.com> * Miran Grca, <mgrca8@gmail.com>
@@ -197,11 +197,6 @@ set_language(int id)
/* Load the strings table for this ID. */ /* Load the strings table for this ID. */
LoadCommonStrings(); 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. */ /* For the Windows platform, this is the start of the application. */
int WINAPI int WINAPI
WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPSTR lpszArg, int nCmdShow) 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)) { if (! pc_init(argc, argw)) {
/* Detach from console. */ /* Detach from console. */
CreateConsole(0); CreateConsole(0);
if (source_hwnd)
PostMessage((HWND) (uintptr_t) source_hwnd, WM_SENDSDSTATUS, (WPARAM) 1, (LPARAM) hwndMain);
return(1); return(1);
} }
@@ -391,6 +398,8 @@ WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPSTR lpszArg, int nCmdShow)
/* Handle our GUI. */ /* Handle our GUI. */
i = ui_init(nCmdShow); i = ui_init(nCmdShow);
atexit(shutdown_notify);
return(i); return(i);
} }
@@ -428,6 +437,8 @@ do_stop(void)
plat_delay_ms(100); plat_delay_ms(100);
shutdown_notify();
pc_close(thMain); pc_close(thMain);
thMain = NULL; thMain = NULL;
@@ -627,7 +638,6 @@ plat_dir_check(wchar_t *path)
int int
plat_dir_create(wchar_t *path) plat_dir_create(wchar_t *path)
{ {
// return((int)CreateDirectory(path, NULL));
return((int)SHCreateDirectory(hwndMain, path)); return((int)SHCreateDirectory(hwndMain, path));
} }
@@ -696,10 +706,6 @@ plat_vidapi_name(int api)
break; break;
case 2: case 2:
#if 0
/* Direct3D is default. */
name = "d3d";
#endif
break; break;
case 3: case 3:
@@ -707,10 +713,6 @@ plat_vidapi_name(int api)
break; break;
#else #else
case 1: case 1:
#if 0
/* Direct3D is default. */
name = "d3d";
#endif
break; break;
case 2: case 2:

View File

@@ -8,7 +8,7 @@
* *
* Platform support defintions for Win32. * 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, <http://pcem-emulator.co.uk/> * Authors: Sarah Walker, <http://pcem-emulator.co.uk/>
* Miran Grca, <mgrca8@gmail.com> * Miran Grca, <mgrca8@gmail.com>
@@ -57,8 +57,8 @@
#define WM_SENDSTATUS 0x8895 #define WM_SENDSTATUS 0x8895
/* Settings status: WPARAM = 1 for open, 0 for closed. */ /* Settings status: WPARAM = 1 for open, 0 for closed. */
#define WM_SENDSSTATUS 0x8896 #define WM_SENDSSTATUS 0x8896
/* Emulator shut down. */ /* Emulator shut down status: WPARAM = 1 for user said yes, 0 for use said no. */
#define WM_SHUTDOWN_DONE 0x8897 #define WM_SENDSDSTATUS 0x8897
#ifdef USE_VNC #ifdef USE_VNC
#ifdef USE_D2D #ifdef USE_D2D

View File

@@ -8,7 +8,7 @@
* *
* Windows 86Box Settings dialog handler. * 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, <mgrca8@gmail.com> * Authors: Miran Grca, <mgrca8@gmail.com>
* David Hrdlička, <hrdlickadavid@outlook.com> * David Hrdlička, <hrdlickadavid@outlook.com>
@@ -4502,7 +4502,7 @@ win_settings_confirm(HWND hdlg, int button)
DestroyWindow(hwndChildDialog); DestroyWindow(hwndChildDialog);
EndDialog(hdlg, 0); EndDialog(hdlg, 0);
plat_pause(0); plat_pause(dopause);
win_settings_communicate_closure(); win_settings_communicate_closure();
return button ? TRUE : FALSE; return button ? TRUE : FALSE;
@@ -4555,7 +4555,7 @@ win_settings_main_proc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam)
case IDCANCEL: case IDCANCEL:
DestroyWindow(hwndChildDialog); DestroyWindow(hwndChildDialog);
EndDialog(hdlg, 0); EndDialog(hdlg, 0);
plat_pause(0); plat_pause(dopause);
win_settings_communicate_closure(); win_settings_communicate_closure();
return TRUE; return TRUE;
} }

View File

@@ -8,7 +8,7 @@
* *
* user Interface module for WinAPI on Windows. * 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, <http://pcem-emulator.co.uk/> * Authors: Sarah Walker, <http://pcem-emulator.co.uk/>
* Miran Grca, <mgrca8@gmail.com> * Miran Grca, <mgrca8@gmail.com>
@@ -64,7 +64,7 @@ WCHAR wopenfilestring[260];
/* Local data. */ /* Local data. */
static wchar_t wTitle[512]; static wchar_t wTitle[512];
static HHOOK hKeyboardHook; static HHOOK hKeyboardHook;
static int hook_enabled = 0; static int hook_enabled = 0, manager_wm = 0;
static int save_window_pos = 0; static int save_window_pos = 0;
@@ -309,8 +309,6 @@ MainWindowProcedure(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
case IDM_ACTION_EXIT: case IDM_ACTION_EXIT:
i = ui_msgbox(MBX_QUESTION_YN, (wchar_t *)IDS_2122); i = ui_msgbox(MBX_QUESTION_YN, (wchar_t *)IDS_2122);
if (i == 0) { if (i == 0) {
if (source_hwnd)
PostMessage((HWND) (uintptr_t) source_hwnd, WM_SHUTDOWN_DONE, (WPARAM) 0, (LPARAM) hwndMain);
UnhookWindowsHookEx(hKeyboardHook); UnhookWindowsHookEx(hKeyboardHook);
KillTimer(hwnd, TIMER_1SEC); KillTimer(hwnd, TIMER_1SEC);
PostQuitMessage(0); PostQuitMessage(0);
@@ -673,8 +671,6 @@ MainWindowProcedure(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
case WM_CLOSE: case WM_CLOSE:
i = ui_msgbox(MBX_QUESTION_YN, (wchar_t *)IDS_2122); i = ui_msgbox(MBX_QUESTION_YN, (wchar_t *)IDS_2122);
if (i == 0) { if (i == 0) {
if (source_hwnd)
PostMessage((HWND) (uintptr_t) source_hwnd, WM_SHUTDOWN_DONE, (WPARAM) 0, (LPARAM) hwndMain);
UnhookWindowsHookEx(hKeyboardHook); UnhookWindowsHookEx(hKeyboardHook);
KillTimer(hwnd, TIMER_1SEC); KillTimer(hwnd, TIMER_1SEC);
PostQuitMessage(0); PostQuitMessage(0);
@@ -682,41 +678,65 @@ MainWindowProcedure(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
break; break;
case WM_DESTROY: case WM_DESTROY:
if (source_hwnd)
PostMessage((HWND) (uintptr_t) source_hwnd, WM_SHUTDOWN_DONE, (WPARAM) 0, (LPARAM) hwndMain);
UnhookWindowsHookEx(hKeyboardHook); UnhookWindowsHookEx(hKeyboardHook);
KillTimer(hwnd, TIMER_1SEC); KillTimer(hwnd, TIMER_1SEC);
PostQuitMessage(0); PostQuitMessage(0);
break; break;
case WM_SHOWSETTINGS: case WM_SHOWSETTINGS:
if (manager_wm)
break;
manager_wm = 1;
win_settings_open(hwnd); win_settings_open(hwnd);
manager_wm = 0;
break; break;
case WM_PAUSE: case WM_PAUSE:
if (manager_wm)
break;
manager_wm = 1;
plat_pause(dopause ^ 1); plat_pause(dopause ^ 1);
CheckMenuItem(menuMain, IDM_ACTION_PAUSE, dopause ? MF_CHECKED : MF_UNCHECKED); CheckMenuItem(menuMain, IDM_ACTION_PAUSE, dopause ? MF_CHECKED : MF_UNCHECKED);
plat_pause(dopause);
manager_wm = 0;
break; break;
case WM_HARDRESET: case WM_HARDRESET:
if (manager_wm)
break;
manager_wm = 1;
plat_pause(1);
i = ui_msgbox(MBX_QUESTION_YN, (wchar_t *)IDS_2121); i = ui_msgbox(MBX_QUESTION_YN, (wchar_t *)IDS_2121);
plat_pause(dopause);
if (i == 0) if (i == 0)
pc_reset(1); pc_reset(1);
manager_wm = 0;
break; break;
case WM_SHUTDOWN: case WM_SHUTDOWN:
if (manager_wm)
break;
manager_wm = 1;
plat_pause(1);
i = ui_msgbox(MBX_QUESTION_YN, (wchar_t *)IDS_2122); i = ui_msgbox(MBX_QUESTION_YN, (wchar_t *)IDS_2122);
plat_pause(dopause);
if (i == 0) { if (i == 0) {
if (source_hwnd)
PostMessage((HWND) (uintptr_t) source_hwnd, WM_SHUTDOWN_DONE, (WPARAM) 0, (LPARAM) hwndMain);
UnhookWindowsHookEx(hKeyboardHook); UnhookWindowsHookEx(hKeyboardHook);
KillTimer(hwnd, TIMER_1SEC); KillTimer(hwnd, TIMER_1SEC);
PostQuitMessage(0); PostQuitMessage(0);
} else {
if (source_hwnd)
PostMessage((HWND) (uintptr_t) source_hwnd, WM_SENDSDSTATUS, (WPARAM) 0, (LPARAM) hwndMain);
} }
manager_wm = 0;
break; break;
case WM_CTRLALTDEL: case WM_CTRLALTDEL:
if (manager_wm)
break;
manager_wm = 1;
pc_reset(0); pc_reset(0);
manager_wm = 0;
break; break;
case WM_SYSCOMMAND: case WM_SYSCOMMAND: