Finalized the Window Message protocol for communicating with the 86Box Manager.
This commit is contained in:
@@ -339,14 +339,6 @@ 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)
|
||||||
@@ -386,7 +378,7 @@ WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPSTR lpszArg, int nCmdShow)
|
|||||||
CreateConsole(0);
|
CreateConsole(0);
|
||||||
|
|
||||||
if (source_hwnd)
|
if (source_hwnd)
|
||||||
PostMessage((HWND) (uintptr_t) source_hwnd, WM_SENDSDSTATUS, (WPARAM) 1, (LPARAM) hwndMain);
|
PostMessage((HWND) (uintptr_t) source_hwnd, WM_HAS_SHUTDOWN, (WPARAM) 0, (LPARAM) hwndMain);
|
||||||
|
|
||||||
return(1);
|
return(1);
|
||||||
}
|
}
|
||||||
@@ -398,8 +390,6 @@ 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);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -437,7 +427,8 @@ do_stop(void)
|
|||||||
|
|
||||||
plat_delay_ms(100);
|
plat_delay_ms(100);
|
||||||
|
|
||||||
shutdown_notify();
|
if (source_hwnd)
|
||||||
|
PostMessage((HWND) (uintptr_t) source_hwnd, WM_HAS_SHUTDOWN, (WPARAM) 0, (LPARAM) hwndMain);
|
||||||
|
|
||||||
pc_close(thMain);
|
pc_close(thMain);
|
||||||
|
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
*
|
*
|
||||||
* Platform support defintions for Win32.
|
* Platform support defintions for Win32.
|
||||||
*
|
*
|
||||||
* Version: @(#)win.h 1.0.27 2019/11/02
|
* Version: @(#)win.h 1.0.28 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>
|
||||||
@@ -43,7 +43,12 @@
|
|||||||
#define SB_MENU_NAME L"StatusBarMenu"
|
#define SB_MENU_NAME L"StatusBarMenu"
|
||||||
#define FS_CLASS_NAME L"86BoxFullScreen"
|
#define FS_CLASS_NAME L"86BoxFullScreen"
|
||||||
|
|
||||||
/* Application-specific window messages. */
|
/* Application-specific window messages.
|
||||||
|
|
||||||
|
A dialog sends 0x8895 with WPARAM = 1 followed by 0x8896 with WPARAM = 1 on open,
|
||||||
|
and 0x8895 with WPARAM = <previous pause status> followed by 0x8896 with WPARAM = 0.
|
||||||
|
|
||||||
|
All shutdowns will send an 0x8897. */
|
||||||
#define WM_RESETD3D WM_USER
|
#define WM_RESETD3D WM_USER
|
||||||
#define WM_LEAVEFULLSCREEN WM_USER+1
|
#define WM_LEAVEFULLSCREEN WM_USER+1
|
||||||
#define WM_SAVESETTINGS 0x8888
|
#define WM_SAVESETTINGS 0x8888
|
||||||
@@ -55,10 +60,10 @@
|
|||||||
#define WM_CTRLALTDEL 0x8894
|
#define WM_CTRLALTDEL 0x8894
|
||||||
/* Pause/resume status: WPARAM = 1 for paused, 0 for resumed. */
|
/* Pause/resume status: WPARAM = 1 for paused, 0 for resumed. */
|
||||||
#define WM_SENDSTATUS 0x8895
|
#define WM_SENDSTATUS 0x8895
|
||||||
/* Settings status: WPARAM = 1 for open, 0 for closed. */
|
/* Dialog (Settings or message box) status: WPARAM = 1 for open, 0 for closed. */
|
||||||
#define WM_SENDSSTATUS 0x8896
|
#define WM_SENDDLGSTATUS 0x8896
|
||||||
/* Emulator shut down status: WPARAM = 1 for user said yes, 0 for use said no. */
|
/* The emulator has shut down. */
|
||||||
#define WM_SENDSDSTATUS 0x8897
|
#define WM_HAS_SHUTDOWN 0x8897
|
||||||
|
|
||||||
#ifdef USE_VNC
|
#ifdef USE_VNC
|
||||||
#ifdef USE_D2D
|
#ifdef USE_D2D
|
||||||
@@ -118,6 +123,9 @@ extern void win_mouse_close(void);
|
|||||||
extern void win_mouse_handle(LPARAM lParam, int infocus);
|
extern void win_mouse_handle(LPARAM lParam, int infocus);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
extern void win_notify_dlg_open(void);
|
||||||
|
extern void win_notify_dlg_closed(void);
|
||||||
|
|
||||||
extern LPARAM win_get_string(int id);
|
extern LPARAM win_get_string(int id);
|
||||||
|
|
||||||
extern intptr_t fdd_type_to_icon(int type);
|
extern intptr_t fdd_type_to_icon(int type);
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
*
|
*
|
||||||
* Windows 86Box Settings dialog handler.
|
* Windows 86Box Settings dialog handler.
|
||||||
*
|
*
|
||||||
* Version: @(#)win_settings.c 1.0.58 2019/11/02
|
* Version: @(#)win_settings.c 1.0.60 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>
|
||||||
@@ -4477,14 +4477,6 @@ win_settings_main_insert_categories(HWND hwndList)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
static void
|
|
||||||
win_settings_communicate_closure(void)
|
|
||||||
{
|
|
||||||
if (source_hwnd)
|
|
||||||
PostMessage((HWND) (uintptr_t) source_hwnd, WM_SENDSSTATUS, (WPARAM) 0, (LPARAM) hwndMain);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#if defined(__amd64__) || defined(__aarch64__)
|
#if defined(__amd64__) || defined(__aarch64__)
|
||||||
static LRESULT CALLBACK
|
static LRESULT CALLBACK
|
||||||
#else
|
#else
|
||||||
@@ -4502,8 +4494,7 @@ win_settings_confirm(HWND hdlg, int button)
|
|||||||
|
|
||||||
DestroyWindow(hwndChildDialog);
|
DestroyWindow(hwndChildDialog);
|
||||||
EndDialog(hdlg, 0);
|
EndDialog(hdlg, 0);
|
||||||
plat_pause(dopause);
|
win_notify_dlg_closed();
|
||||||
win_settings_communicate_closure();
|
|
||||||
|
|
||||||
return button ? TRUE : FALSE;
|
return button ? TRUE : FALSE;
|
||||||
} else
|
} else
|
||||||
@@ -4555,8 +4546,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(dopause);
|
win_notify_dlg_closed();
|
||||||
win_settings_communicate_closure();
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -4571,10 +4561,7 @@ win_settings_main_proc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam)
|
|||||||
void
|
void
|
||||||
win_settings_open_ex(HWND hwnd, int category)
|
win_settings_open_ex(HWND hwnd, int category)
|
||||||
{
|
{
|
||||||
plat_pause(1);
|
win_notify_dlg_open();
|
||||||
|
|
||||||
if (source_hwnd)
|
|
||||||
PostMessage((HWND) (uintptr_t) source_hwnd, WM_SENDSSTATUS, (WPARAM) 1, (LPARAM) hwndMain);
|
|
||||||
|
|
||||||
first_cat = category;
|
first_cat = category;
|
||||||
DialogBox(hinstance, (LPCWSTR)DLG_CONFIG, hwnd, win_settings_main_proc);
|
DialogBox(hinstance, (LPCWSTR)DLG_CONFIG, hwnd, win_settings_main_proc);
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
*
|
*
|
||||||
* user Interface module for WinAPI on Windows.
|
* user Interface module for WinAPI on Windows.
|
||||||
*
|
*
|
||||||
* Version: @(#)win_ui.c 1.0.43 2019/11/02
|
* Version: @(#)win_ui.c 1.0.44 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>
|
||||||
@@ -65,7 +65,7 @@ WCHAR wopenfilestring[260];
|
|||||||
static wchar_t wTitle[512];
|
static wchar_t wTitle[512];
|
||||||
static HHOOK hKeyboardHook;
|
static HHOOK hKeyboardHook;
|
||||||
static int hook_enabled = 0, manager_wm = 0;
|
static int hook_enabled = 0, manager_wm = 0;
|
||||||
static int save_window_pos = 0;
|
static int save_window_pos = 0, pause_state = 0;
|
||||||
|
|
||||||
|
|
||||||
static int vis = -1;
|
static int vis = -1;
|
||||||
@@ -270,6 +270,27 @@ LowLevelKeyboardProc(int nCode, WPARAM wParam, LPARAM lParam)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
win_notify_dlg_open(void)
|
||||||
|
{
|
||||||
|
manager_wm = 1;
|
||||||
|
pause_state = dopause;
|
||||||
|
plat_pause(1);
|
||||||
|
if (source_hwnd)
|
||||||
|
PostMessage((HWND) (uintptr_t) source_hwnd, WM_SENDDLGSTATUS, (WPARAM) 1, (LPARAM) hwndMain);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
win_notify_dlg_closed(void)
|
||||||
|
{
|
||||||
|
if (source_hwnd)
|
||||||
|
PostMessage((HWND) (uintptr_t) source_hwnd, WM_SENDDLGSTATUS, (WPARAM) 0, (LPARAM) hwndMain);
|
||||||
|
plat_pause(pause_state);
|
||||||
|
manager_wm = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static LRESULT CALLBACK
|
static LRESULT CALLBACK
|
||||||
MainWindowProcedure(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
|
MainWindowProcedure(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||||
{
|
{
|
||||||
@@ -297,13 +318,11 @@ MainWindowProcedure(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case IDM_ACTION_HRESET:
|
case IDM_ACTION_HRESET:
|
||||||
manager_wm = 1;
|
win_notify_dlg_open();
|
||||||
plat_pause(1);
|
|
||||||
i = ui_msgbox(MBX_QUESTION_YN, (wchar_t *)IDS_2121);
|
i = ui_msgbox(MBX_QUESTION_YN, (wchar_t *)IDS_2121);
|
||||||
if (i == 0)
|
if (i == 0)
|
||||||
pc_reset(1);
|
pc_reset(1);
|
||||||
plat_pause(dopause);
|
win_notify_dlg_closed();
|
||||||
manager_wm = 0;
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case IDM_ACTION_RESET_CAD:
|
case IDM_ACTION_RESET_CAD:
|
||||||
@@ -311,16 +330,14 @@ MainWindowProcedure(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case IDM_ACTION_EXIT:
|
case IDM_ACTION_EXIT:
|
||||||
manager_wm = 1;
|
win_notify_dlg_open();
|
||||||
plat_pause(1);
|
|
||||||
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) {
|
||||||
UnhookWindowsHookEx(hKeyboardHook);
|
UnhookWindowsHookEx(hKeyboardHook);
|
||||||
KillTimer(hwnd, TIMER_1SEC);
|
KillTimer(hwnd, TIMER_1SEC);
|
||||||
PostQuitMessage(0);
|
PostQuitMessage(0);
|
||||||
} else
|
}
|
||||||
plat_pause(dopause);
|
win_notify_dlg_closed();
|
||||||
manager_wm = 0;
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case IDM_ACTION_CTRL_ALT_ESC:
|
case IDM_ACTION_CTRL_ALT_ESC:
|
||||||
@@ -677,16 +694,14 @@ MainWindowProcedure(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
|
|||||||
return(0);
|
return(0);
|
||||||
|
|
||||||
case WM_CLOSE:
|
case WM_CLOSE:
|
||||||
manager_wm = 1;
|
win_notify_dlg_open();
|
||||||
plat_pause(1);
|
|
||||||
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) {
|
||||||
UnhookWindowsHookEx(hKeyboardHook);
|
UnhookWindowsHookEx(hKeyboardHook);
|
||||||
KillTimer(hwnd, TIMER_1SEC);
|
KillTimer(hwnd, TIMER_1SEC);
|
||||||
PostQuitMessage(0);
|
PostQuitMessage(0);
|
||||||
} else
|
}
|
||||||
plat_pause(dopause);
|
win_notify_dlg_closed();
|
||||||
manager_wm = 0;
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WM_DESTROY:
|
case WM_DESTROY:
|
||||||
@@ -709,38 +724,30 @@ MainWindowProcedure(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
|
|||||||
manager_wm = 1;
|
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;
|
manager_wm = 0;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WM_HARDRESET:
|
case WM_HARDRESET:
|
||||||
if (manager_wm)
|
if (manager_wm)
|
||||||
break;
|
break;
|
||||||
manager_wm = 1;
|
win_notify_dlg_open();
|
||||||
plat_pause(1);
|
|
||||||
i = ui_msgbox(MBX_QUESTION_YN, (wchar_t *)IDS_2121);
|
i = ui_msgbox(MBX_QUESTION_YN, (wchar_t *)IDS_2121);
|
||||||
if (i == 0)
|
if (i == 0)
|
||||||
pc_reset(1);
|
pc_reset(1);
|
||||||
plat_pause(dopause);
|
win_notify_dlg_closed();
|
||||||
manager_wm = 0;
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WM_SHUTDOWN:
|
case WM_SHUTDOWN:
|
||||||
if (manager_wm)
|
if (manager_wm)
|
||||||
break;
|
break;
|
||||||
manager_wm = 1;
|
win_notify_dlg_open();
|
||||||
plat_pause(1);
|
|
||||||
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) {
|
||||||
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);
|
|
||||||
plat_pause(dopause);
|
|
||||||
}
|
}
|
||||||
manager_wm = 0;
|
win_notify_dlg_closed();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WM_CTRLALTDEL:
|
case WM_CTRLALTDEL:
|
||||||
@@ -1071,7 +1078,13 @@ plat_pause(int p)
|
|||||||
p = get_vidpause();
|
p = get_vidpause();
|
||||||
|
|
||||||
/* If already so, done. */
|
/* If already so, done. */
|
||||||
if (dopause == p) return;
|
if (dopause == p) {
|
||||||
|
/* Send the WM to a manager if needed. */
|
||||||
|
if (source_hwnd)
|
||||||
|
PostMessage((HWND) (uintptr_t) source_hwnd, WM_SENDSTATUS, (WPARAM) !!dopause, (LPARAM) hwndMain);
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (p) {
|
if (p) {
|
||||||
wcscpy(oldtitle, ui_window_title(NULL));
|
wcscpy(oldtitle, ui_window_title(NULL));
|
||||||
|
|||||||
Reference in New Issue
Block a user