Refactor: move code for WM_CLOSE next to WM_DESTROY, and WM_KEYDOWN next to WM_CHAR

This commit is contained in:
tomcw 2018-07-31 18:17:42 +01:00
parent 898f30f08a
commit e4bd6162c5
2 changed files with 45 additions and 48 deletions

View File

@ -1095,25 +1095,29 @@ LRESULT CALLBACK FrameWndProc (
// Exit via DefWindowProc(), which does the default action for WM_CLOSE, which is to call DestroyWindow(), posting WM_DESTROY
break;
case WM_CHAR:
if ((g_nAppMode == MODE_RUNNING) || (g_nAppMode == MODE_STEPPING) || (g_nAppMode == MODE_LOGO))
{
if (!g_bDebuggerEatKey)
{
#if DEBUG_KEY_MESSAGES
LogOutput("WM_CHAR: %08X\n", wparam);
#endif
if (g_nAppMode != MODE_LOGO) // !MODE_LOGO - not emulating so don't pass to the VM's keyboard
KeybQueueKeypress(wparam, ASCII);
}
g_bDebuggerEatKey = false;
}
else if (g_nAppMode == MODE_DEBUG)
{
DebuggerInputConsoleChar((TCHAR)wparam);
}
break;
case WM_DESTROY:
LogFileOutput("WM_DESTROY\n");
DragAcceptFiles(window,0);
if (!g_bRestart) // GH#564: Only save-state on shutdown (not on a restart)
Snapshot_Shutdown();
DebugDestroy();
if (!g_bRestart) {
DiskDestroy();
ImageDestroy();
HD_Destroy();
}
PrintDestroy();
sg_SSC.CommDestroy();
CpuDestroy();
MemDestroy();
SpkrDestroy();
VideoDestroy();
MB_Destroy();
DeleteGdiObjects();
DIMouse::DirectInputUninit(window); // NB. do before window is destroyed
PostQuitMessage(0); // Post WM_QUIT message to the thread's message queue
LogFileOutput("WM_DESTROY (done)\n");
break;
case WM_CREATE:
LogFileOutput("WM_CREATE\n");
@ -1173,30 +1177,6 @@ LRESULT CALLBACK FrameWndProc (
break;
}
case WM_DESTROY:
LogFileOutput("WM_DESTROY\n");
DragAcceptFiles(window,0);
if (!g_bRestart) // GH#564: Only save-state on shutdown (not on a restart)
Snapshot_Shutdown();
DebugDestroy();
if (!g_bRestart) {
DiskDestroy();
ImageDestroy();
HD_Destroy();
}
PrintDestroy();
sg_SSC.CommDestroy();
CpuDestroy();
MemDestroy();
SpkrDestroy();
VideoDestroy();
MB_Destroy();
DeleteGdiObjects();
DIMouse::DirectInputUninit(window); // NB. do before window is destroyed
PostQuitMessage(0); // Post WM_QUIT message to the thread's message queue
LogFileOutput("WM_DESTROY (done)\n");
break;
case WM_DISPLAYCHANGE:
VideoReinitialize();
break;
@ -1421,6 +1401,26 @@ LRESULT CALLBACK FrameWndProc (
}
break;
case WM_CHAR:
if ((g_nAppMode == MODE_RUNNING) || (g_nAppMode == MODE_STEPPING) || (g_nAppMode == MODE_LOGO))
{
if (!g_bDebuggerEatKey)
{
#if DEBUG_KEY_MESSAGES
LogOutput("WM_CHAR: %08X\n", wparam);
#endif
if (g_nAppMode != MODE_LOGO) // !MODE_LOGO - not emulating so don't pass to the VM's keyboard
KeybQueueKeypress(wparam, ASCII);
}
g_bDebuggerEatKey = false;
}
else if (g_nAppMode == MODE_DEBUG)
{
DebuggerInputConsoleChar((TCHAR)wparam);
}
break;
case WM_KEYUP:
// Process is done in WM_KEYUP: VK_F1 VK_F2 VK_F3 VK_F4 VK_F5 VK_F6 VK_F7 VK_F8
if ((wparam >= VK_F1) && (wparam <= VK_F8) && (buttondown == (int)wparam-VK_F1))
@ -1795,10 +1795,7 @@ LRESULT CALLBACK FrameWndProc (
}
case WM_USER_RESTART:
// . Changed Apple computer type (][+ or //e)
// . Changed slot configuration
// . Changed disk speed (normal or enhanced)
// . Changed Freeze F8 rom setting
// Changed h/w config, eg. Apple computer type (][+ or //e), slot configuration, etc.
g_bRestart = true;
PostMessage(window,WM_CLOSE,0,0);
break;

View File

@ -651,5 +651,5 @@ void Snapshot_Shutdown()
Snapshot_SaveState();
bDone = true; // Debug flag: should only be called once, and never on a g_bRestart
bDone = true; // Debug flag: this func should only be called once, and never on a g_bRestart
}