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

View File

@@ -651,5 +651,5 @@ void Snapshot_Shutdown()
Snapshot_SaveState(); 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
} }