Revision: 7914 https://osdn.net/projects/ttssh2/scm/svn/commits/7914 Author: zmatsuo Date: 2019-08-06 00:35:24 +0900 (Tue, 06 Aug 2019) Log Message: ----------- メッセージループ処理を見直した Modified Paths: -------------- trunk/doc/en/html/about/history.html trunk/doc/ja/html/about/history.html trunk/teraterm/teraterm/teraterm.cpp -------------- next part -------------- Modified: trunk/doc/en/html/about/history.html =================================================================== --- trunk/doc/en/html/about/history.html 2019-08-05 13:38:43 UTC (rev 7913) +++ trunk/doc/en/html/about/history.html 2019-08-05 15:35:24 UTC (rev 7914) @@ -45,6 +45,7 @@ <li>When UTF-8 characters received, 4-byte UTF-8 characters are miss-decorded.</li> <li>The plugin compiled before 4.103 can not called because the DLL's calling convention is changed in Tera Term 4.103. </li> <li>Displayed unspecified string font in IME changes, when you open the font setting dialog.</li> + <li><!-- [File]/[Send file..]\x82\xA9\x82\xE7\x91傫\x82ȃt\x83@\x83C\x83\x8B\x82\xF0\x82\xA4\x82܂\xAD\x91\x97\x90M\x82ł\xAB\x82Ȃ\xA2\x96\xE2\x91\xE8\x82\xF0\x8FC\x90\xB3\x82\xB5\x82\xBD\x81B4.103\x82ł̃G\x83\x93\x83o\x83O\x81B --></li> </ul> </li> Modified: trunk/doc/ja/html/about/history.html =================================================================== --- trunk/doc/ja/html/about/history.html 2019-08-05 13:38:43 UTC (rev 7913) +++ trunk/doc/ja/html/about/history.html 2019-08-05 15:35:24 UTC (rev 7914) @@ -41,11 +41,12 @@ </li> <li>\x83o\x83O\x8FC\x90\xB3 <ul> - <li>Active Window Tracking \x82\xF0\x97L\x8C\xF8\x8E\x9E\x81A\x83}\x83E\x83X\x83J\x81[\x83\\x83\x8B\x82\xAA Tera Term \x82̃E\x83B\x83\x93\x83h\x83E\x93\xE0\x82Ɉړ\xAE\x82\xB5\x82Ă\xE0\x81A\x83A\x83N\x83e\x83B\x83u\x82ɂȂ\xE7\x82Ȃ\xA2\x96\xE2\x91\xE8\x82\xF0\x8FC\x90\xB3\x81B4.103\x82ł̃G\x83\x93\x83o\x83O\x81B</li> - <li>UTF-8\x8E\xF3\x90M\x8E\x9E\x81A4byte\x82\xCCUTF-8\x82̃f\x83R\x81[\x83h\x82\xF0\x8C\xEB\x82\xC1\x82Ă\xA2\x82\xBD\x82̂ŏC\x90\xB3</li> + <li>Active Window Tracking \x82\xF0\x97L\x8C\xF8\x8E\x9E\x81A\x83}\x83E\x83X\x83J\x81[\x83\\x83\x8B\x82\xAA Tera Term \x82̃E\x83B\x83\x93\x83h\x83E\x93\xE0\x82Ɉړ\xAE\x82\xB5\x82Ă\xE0\x81A\x83A\x83N\x83e\x83B\x83u\x82ɂȂ\xE7\x82Ȃ\xA2\x96\xE2\x91\xE8\x82\xF0\x8FC\x90\xB3\x82\xB5\x82\xBD\x81B4.103\x82ł̃G\x83\x93\x83o\x83O\x81B</li> + <li>UTF-8\x8E\xF3\x90M\x8E\x9E\x81A4byte\x82\xCCUTF-8\x82̃f\x83R\x81[\x83h\x82\xF0\x8C\xEB\x82\xC1\x82Ă\xA2\x82\xBD\x82̂ŏC\x90\xB3\x82\xB5\x82\xBD\x81B</li> <li>Ver 4.103 \x82\xC5 DLL \x82̌Ăяo\x82\xB5\x8BK\x96\xF1\x82\xF0\x95ς\xA6\x82\xBD\x82\xB1\x82ƂŁA\x82\xBB\x82\xEA\x88ȑO\x82ɃR\x83\x93\x83p\x83C\x83\x8B\x82\xB3\x82ꂽ\x83v\x83\x89\x83O\x83C\x83\x93\x82\xAA\x8CĂяo\x82\xB9\x82Ȃ\xAD\x82Ȃ\xC1\x82Ă\xA2\x82\xBD\x96\xE2\x91\xE8\x82\xF0\x8FC\x90\xB3\x82\xB5\x82\xBD\x81B</li> - <li>IME\x82̖\xA2\x8Am\x92蕶\x8E\x9A\x82\xF0\x95\\x8E\xA6\x82\xB5\x82Ă\xA2\x82\xE9\x8F\xF3\x91ԂŃt\x83H\x83\x93\x83g\x91I\x91\xF0\x83_\x83C\x83A\x83\x8D\x83O\x82\xF0\x8Eg\x97p\x82\xB7\x82\xE9\x82\xC6IME\x82̃t\x83H\x83\x93\x83g\x82\xAA\x95ω\xBB\x82\xB7\x82\xE9\x96\xE2\x91\xE8\x82\xF0\x8FC\x90\xB3\x81B</li> + <li>IME\x82̖\xA2\x8Am\x92蕶\x8E\x9A\x82\xF0\x95\\x8E\xA6\x82\xB5\x82Ă\xA2\x82\xE9\x8F\xF3\x91ԂŃt\x83H\x83\x93\x83g\x91I\x91\xF0\x83_\x83C\x83A\x83\x8D\x83O\x82\xF0\x8Eg\x97p\x82\xB7\x82\xE9\x82\xC6IME\x82̃t\x83H\x83\x93\x83g\x82\xAA\x95ω\xBB\x82\xB7\x82\xE9\x96\xE2\x91\xE8\x82\xF0\x8FC\x90\xB3\x82\xB5\x82\xBD\x81B</li> <li><a href="../macro/command/filecopy.html">filecopy</a> \x83}\x83N\x83\x8D\x83R\x83}\x83\x93\x83h\x82̌\x8B\x89ʂ\xAA result \x83V\x83X\x83e\x83\x80\x95ϐ\x94\x82Ɋi\x94[\x82\xB3\x82\xEA\x82Ȃ\xA2\x82\xB1\x82Ƃ\xAA\x82\xA0\x82\xE9\x96\xE2\x91\xE8\x82\xF0\x8FC\x90\xB3\x82\xB5\x82\xBD\x81B</li> + <li>[File]/[Send file..]\x82\xA9\x82\xE7\x91傫\x82ȃt\x83@\x83C\x83\x8B\x82\xF0\x82\xA4\x82܂\xAD\x91\x97\x90M\x82ł\xAB\x82Ȃ\xA2\x96\xE2\x91\xE8\x82\xF0\x8FC\x90\xB3\x82\xB5\x82\xBD\x81B4.103\x82ł̃G\x83\x93\x83o\x83O\x81B</li> </ul> </li> Modified: trunk/teraterm/teraterm/teraterm.cpp =================================================================== --- trunk/teraterm/teraterm/teraterm.cpp 2019-08-05 13:38:43 UTC (rev 7913) +++ trunk/teraterm/teraterm/teraterm.cpp 2019-08-05 15:35:24 UTC (rev 7914) @@ -258,18 +258,51 @@ void RemoveModalHandle(HWND hWnd) { + (void)hWnd; hModalWnd = 0; } +static UINT nMsgLast; +static POINT ptCursorLast; + +/** + * idle\x8F\xF3\x91Ԃɓ\xFC\x82邩\x94\xBB\x92肷\x82\xE9 + */ +static BOOL IsIdleMessage(const MSG* pMsg) +{ + if (pMsg->message == WM_MOUSEMOVE || + pMsg->message == WM_NCMOUSEMOVE) + { + if (pMsg->message == nMsgLast && + pMsg->pt.x == ptCursorLast.x && + pMsg->pt.y == ptCursorLast.y) + { // \x93\xAF\x82\xB6\x88ʒu\x82\xBE\x82\xC1\x82\xBD\x82\xE7idle\x82ɂ͂\xA2\x82\xE7\x82Ȃ\xA2 + return FALSE; + } + + ptCursorLast = pMsg->pt; + nMsgLast = pMsg->message; + return TRUE; + } + + if (pMsg->message == WM_PAINT || + pMsg->message == 0x0118/*WM_SYSTIMER*/) + { + return FALSE; + } + + return TRUE; +} + int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPreInst, LPSTR lpszCmdLine, int nCmdShow) { + (void)hPreInst; + (void)lpszCmdLine; + (void)nCmdShow; #ifdef _DEBUG _CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF); #endif - - LONG lCount = 0; - DWORD SleepTick = 1; init(); hInst = hInstance; CVTWindow *m_pMainWnd = new CVTWindow(); @@ -279,47 +312,68 @@ SetDialogFont(ts.DialogFontName, ts.DialogFontPoint, ts.DialogFontCharSet, ts.UILanguageFile, "Tera Term", "DLG_SYSTEM_FONT"); + BOOL bIdle = TRUE; // idle\x8F\xF3\x91Ԃ\xA9? + LONG lCount = 0; MSG msg; - while (GetMessage(&msg, NULL, 0, 0)) { - if (hModalWnd != 0) { - if (IsDialogMessage(hModalWnd, &msg)) { - continue; + for (;;) { + // idle\x8F\xF3\x91ԂŃ\x81\x83b\x83Z\x81[\x83W\x82\xAA\x82Ȃ\xA2\x8Fꍇ + while (bIdle) { + if (::PeekMessage(&msg, NULL, NULL, NULL, PM_NOREMOVE) != FALSE) { + // \x83\x81\x83b\x83Z\x81[\x83W\x82\xAA\x91\xB6\x8D݂\xB7\x82\xE9 + break; } + + const BOOL continue_idle = OnIdle(lCount++); + if (!continue_idle) { + // FALSE\x82\xAA\x96߂\xC1\x82Ă\xAB\x82\xBD\x82\xE7idle\x8F\x88\x97\x9D\x82͕s\x97v + bIdle = FALSE; + break; + } } - bool message_processed = false; + // \x83\x81\x83b\x83Z\x81[\x83W\x82\xAA\x8B\xF3\x82ɂȂ\xE9\x82܂ŏ\x88\x97\x9D\x82\xB7\x82\xE9 + for(;;) { + // \x83\x81\x83b\x83Z\x81[\x83W\x82\xAA\x89\xBD\x82\xE0\x82Ȃ\xA2\x8Fꍇ\x81AGetMessage()\x82Ńu\x83\x8D\x83b\x83N\x82\xB7\x82邱\x82Ƃ\xAA\x82\xA0\x82\xE9 + if (::GetMessage(&msg, NULL, 0, 0) == FALSE) { + // WM_QUIT + goto exit_message_loop; + } - if (m_pMainWnd->m_hAccel != NULL) { - if (!MetaKey(ts.MetaKey)) { - // matakey\x82\xAA\x89\x9F\x82\xB3\x82\xEA\x82Ă\xA2\x82Ȃ\xA2 - if (TranslateAccelerator(m_pMainWnd->m_hWnd , m_pMainWnd->m_hAccel, &msg)) { - // \x83A\x83N\x83Z\x83\x89\x83\x8C\x81[\x83^\x81[\x83L\x81[\x82\xF0\x8F\x88\x97\x9D\x82\xB5\x82\xBD - message_processed = true; + if (hModalWnd == 0 || + ::IsDialogMessage(hModalWnd, &msg) == FALSE) + { + bool message_processed = false; + + if (m_pMainWnd->m_hAccel != NULL) { + if (!MetaKey(ts.MetaKey)) { + // matakey\x82\xAA\x89\x9F\x82\xB3\x82\xEA\x82Ă\xA2\x82Ȃ\xA2 + if (::TranslateAccelerator(m_pMainWnd->m_hWnd , m_pMainWnd->m_hAccel, &msg)) { + // \x83A\x83N\x83Z\x83\x89\x83\x8C\x81[\x83^\x81[\x83L\x81[\x82\xF0\x8F\x88\x97\x9D\x82\xB5\x82\xBD + message_processed = true; + } + } } + + if (!message_processed) { + ::TranslateMessage(&msg); + ::DispatchMessage(&msg); + } } - } - if (!message_processed) { - TranslateMessage(&msg); - DispatchMessage(&msg); - } - - while (!PeekMessage(&msg, NULL, NULL, NULL, PM_NOREMOVE)) { - // \x83\x81\x83b\x83Z\x81[\x83W\x82\xAA\x82Ȃ\xA2 - if (!OnIdle(lCount)) { - // idle\x95s\x97v - if (SleepTick < 500) { // \x8Dő\xE5 501ms\x96\xA2\x96\x9E - SleepTick += 2; - } + // idle\x8F\xF3\x91Ԃɓ\xFC\x82邩? + if (IsIdleMessage(&msg)) { + bIdle = TRUE; lCount = 0; - Sleep(SleepTick); - } else { - // \x97vidle - SleepTick = 0; - lCount++; } + + if (::PeekMessage(&msg, NULL, NULL, NULL, PM_NOREMOVE) == FALSE) { + // \x83\x81\x83b\x83Z\x81[\x83W\x82\xAA\x82Ȃ\xAD\x82Ȃ\xC1\x82\xBD + break; + } } } +exit_message_loop: + delete m_pMainWnd; m_pMainWnd = NULL; @@ -326,5 +380,5 @@ UnloadSpecialFont(); DLLExit(); - return msg.wParam; + return (int)msg.wParam; }