Revision: 9919 https://osdn.net/projects/ttssh2/scm/svn/commits/9919 Author: nmaya Date: 2022-05-13 00:27:14 +0900 (Fri, 13 May 2022) Log Message: ----------- SSH 接続が切れたときに VT アイコンに戻らない問題を修正 ticket #43907 Ticket Links: ------------ https://osdn.net/projects/ttssh2/tracker/detail/43907 Modified Paths: -------------- branches/adjust_icon/teraterm/common/tttypes.h branches/adjust_icon/teraterm/teraterm/vtwin.cpp branches/adjust_icon/teraterm/ttpcmn/ttcmn.c branches/adjust_icon/ttssh2/ttxssh/ttxssh.c branches/adjust_icon/ttssh2/ttxssh/ttxssh.h -------------- next part -------------- Modified: branches/adjust_icon/teraterm/common/tttypes.h =================================================================== --- branches/adjust_icon/teraterm/common/tttypes.h 2022-05-12 14:03:48 UTC (rev 9918) +++ branches/adjust_icon/teraterm/common/tttypes.h 2022-05-12 15:27:14 UTC (rev 9919) @@ -348,8 +348,6 @@ } cygterm_t; /* TTTSet */ -typedef struct tttset TTTSet, *PTTSet; - struct tttset { /*------ VTSet --------*/ /* Tera Term home directory */ @@ -551,7 +549,6 @@ WORD CRSend_ini; WORD LocalEcho_ini; WORD UnicodeDecSpMapping; - HINSTANCE Instance; WORD VTIcon; WORD TEKIcon; WORD ScrollWindowClearScreen; @@ -648,11 +645,14 @@ wchar_t *ExeDirW; // ttermpro.exe \x82̂\xA0\x82\xE9\x83t\x83H\x83\x8B\x83_ wchar_t *LogDirW; // log\x82\xE2\x83_\x83\x93\x83v\x82\xF0\x92u\x82\xAD\x83t\x83H\x83\x8B\x83_ wchar_t *FileDirW; // \x83_\x83E\x83\x93\x83\x8D\x81[\x83h\x83p\x83X("%APPDATA%" \x93\x99\x82\xAA\x8A܂܂\xEA\x82\xE9,\x8Eg\x97p\x91O\x82Ɋ\xAB\x95ϐ\x94\x82\xF0\x93W\x8AJ\x82\xB7\x82邱\x82\xC6) + HINSTANCE PluginVTIocnInstance; + WORD PluginVTIocnID; - - void (*SetVTIcon)(TTTSet *ts, HINSTANCE Inst, WORD icon_id); + void (*SetVTIcon)(HINSTANCE hInstance, WORD IconID); }; +typedef struct tttset TTTSet, *PTTSet; + /* New Line modes */ #define IdCR 1 #define IdCRLF 2 Modified: branches/adjust_icon/teraterm/teraterm/vtwin.cpp =================================================================== --- branches/adjust_icon/teraterm/teraterm/vtwin.cpp 2022-05-12 14:03:48 UTC (rev 9918) +++ branches/adjust_icon/teraterm/teraterm/vtwin.cpp 2022-05-12 15:27:14 UTC (rev 9919) @@ -243,7 +243,7 @@ static void SetIcon(HINSTANCE hInst_, HWND hWnd, const wchar_t *icon_name, int dpi) { - // \x91傫\x82\xA2\x83A\x83C\x83R\x83\x93(32x32,\x83f\x83B\x83X\x83v\x83\x8C\x83C\x82̊g\x91嗦\x82\xAA100%(dpi=76)\x82̂Ƃ\xAB) + // \x91傫\x82\xA2\x83A\x83C\x83R\x83\x93(32x32,\x83f\x83B\x83X\x83v\x83\x8C\x83C\x82̊g\x91嗦\x82\xAA100%(dpi=96)\x82̂Ƃ\xAB) HICON icon = TTLoadIcon(hInst_, icon_name, 0, 0, dpi); icon = (HICON)::SendMessage(hWnd, WM_SETICON, ICON_BIG, (LPARAM)icon); if (icon != NULL) { @@ -250,7 +250,7 @@ DestroyIcon(icon); } - // \x91傫\x82\xA2\x83A\x83C\x83R\x83\x93(16x16,\x83f\x83B\x83X\x83v\x83\x8C\x83C\x82̊g\x91嗦\x82\xAA100%(dpi=76)\x82̂Ƃ\xAB) + // \x91傫\x82\xA2\x83A\x83C\x83R\x83\x93(16x16,\x83f\x83B\x83X\x83v\x83\x8C\x83C\x82̊g\x91嗦\x82\xAA100%(dpi=96)\x82̂Ƃ\xAB) icon = TTLoadIcon(hInst_, icon_name, 16, 16, dpi); icon = (HICON)::SendMessage(hWnd, WM_SETICON, ICON_SMALL, (LPARAM)icon); if (icon != NULL) { @@ -269,12 +269,19 @@ } } -static void SetVTIcon(TTTSet *ts, HINSTANCE inst, WORD icon_id) +static void SetVTIcon(HINSTANCE hInstance, WORD IconID) { - ts->Instance = inst; - ts->VTIcon = icon_id; + HINSTANCE inst; + WORD icon_id; + const int dpi = GetMonitorDpiFromWindow(HVTWin); - const int dpi = GetMonitorDpiFromWindow(HVTWin); + ts.PluginVTIocnInstance = hInstance; + ts.PluginVTIocnID = IconID; + + inst = (ts.PluginVTIocnInstance == NULL) ? hInst : hInstance; + icon_id = (ts.PluginVTIocnID != 0) ? IconID : + (ts.VTIcon != IdIconDefault) ? ts.VTIcon + : IDI_VT; SetIcon(inst, HVTWin, MAKEINTRESOURCEW(icon_id), dpi); } @@ -289,7 +296,6 @@ int CmdShow; BOOL isFirstInstance; m_hInst = hInstance; - ts.Instance = hInstance; CommInit(&cv); ts.SetVTIcon = SetVTIcon; @@ -457,10 +463,14 @@ RegDeviceNotify(HVTWin); { + HINSTANCE inst; + WORD icon_id; const int dpi = GetMonitorDpiFromWindow(m_hWnd); - const int icon_id = (ts.VTIcon != IdIconDefault) ? ts.VTIcon : IDI_VT; - const wchar_t *icon_name = MAKEINTRESOURCEW(icon_id); - SetIcon(m_hInst, m_hWnd, icon_name, dpi); + inst = (ts.PluginVTIocnInstance != NULL) ? ts.PluginVTIocnInstance : m_hInst; + icon_id = (ts.PluginVTIocnID != 0) ? ts.PluginVTIocnID + : (ts.VTIcon != IdIconDefault) ? ts.VTIcon + : IDI_VT; + SetIcon(inst, m_hWnd, MAKEINTRESOURCEW(icon_id), dpi); } SetCustomNotifyIcon( (HICON)LoadImage( @@ -5071,10 +5081,13 @@ ChangeCaret(); { - const int icon_id = (ts.VTIcon != IdIconDefault) ? ts.VTIcon : IDI_VT; - const wchar_t *icon_name = MAKEINTRESOURCEW(icon_id); - const HINSTANCE inst = ts.Instance; - SetIcon(inst, m_hWnd, icon_name, NewDPI); + HINSTANCE inst; + WORD icon_id; + inst = (ts.PluginVTIocnInstance != NULL) ? ts.PluginVTIocnInstance : hInst; + icon_id = (ts.PluginVTIocnID != 0) ? ts.PluginVTIocnID + : (ts.VTIcon != IdIconDefault) ? ts.VTIcon + : IDI_VT; + SetIcon(inst, m_hWnd, MAKEINTRESOURCEW(icon_id), NewDPI); } return TRUE; Modified: branches/adjust_icon/teraterm/ttpcmn/ttcmn.c =================================================================== --- branches/adjust_icon/teraterm/ttpcmn/ttcmn.c 2022-05-12 14:03:48 UTC (rev 9918) +++ branches/adjust_icon/teraterm/ttpcmn/ttcmn.c 2022-05-12 15:27:14 UTC (rev 9919) @@ -272,6 +272,9 @@ else { return FALSE; } + + ts->PluginVTIocnInstance = NULL; + ts->PluginVTIocnID = 0; } // \x90ݒ\xE8\x83t\x83@\x83C\x83\x8B\x82\xF0\x83f\x83B\x83X\x83N\x82ɕۑ\xB6\x82\xB5\x81ATera Term\x96{\x91̂\xF0\x8DċN\x93\xAE\x82\xB7\x82\xE9\x81B Modified: branches/adjust_icon/ttssh2/ttxssh/ttxssh.c =================================================================== --- branches/adjust_icon/ttssh2/ttxssh/ttxssh.c 2022-05-12 14:03:48 UTC (rev 9918) +++ branches/adjust_icon/ttssh2/ttxssh/ttxssh.c 2022-05-12 15:27:14 UTC (rev 9919) @@ -115,11 +115,6 @@ HANDLE hInst; /* Instance handle of TTXSSH.DLL */ -static HICON SecureLargeIcon = NULL; -static HICON SecureSmallIcon = NULL; -static HICON SecureNotifyIcon = NULL; -static HICON OldNotifyIcon = NULL; - static TInstVar *pvar; typedef struct { @@ -187,19 +182,7 @@ FWD_end(pvar); FWDUI_end(pvar); - if (pvar->OldLargeIcon != NULL) { - PostMessage(pvar->NotificationWindow, WM_SETICON, ICON_BIG, - (LPARAM) pvar->OldLargeIcon); - pvar->OldLargeIcon = NULL; - } - if (pvar->OldSmallIcon != NULL) { - PostMessage(pvar->NotificationWindow, WM_SETICON, ICON_SMALL, - (LPARAM) pvar->OldSmallIcon); - pvar->OldSmallIcon = NULL; - } - if (OldNotifyIcon) { - SetCustomNotifyIcon(OldNotifyIcon); - } + pvar->ts->SetVTIcon(NULL, 0); ssh_heartbeat_lock_finalize(); @@ -676,7 +659,7 @@ void notify_established_secure_connection(PTInstVar pvar) { - pvar->ts->SetVTIcon(pvar->ts, hInst, pvar->settings.IconID); + pvar->ts->SetVTIcon(hInst, pvar->settings.IconID); logputs(LOG_LEVEL_VERBOSE, "Entering secure mode"); } Modified: branches/adjust_icon/ttssh2/ttxssh/ttxssh.h =================================================================== --- branches/adjust_icon/ttssh2/ttxssh/ttxssh.h 2022-05-12 14:03:48 UTC (rev 9918) +++ branches/adjust_icon/ttssh2/ttxssh/ttxssh.h 2022-05-12 15:27:14 UTC (rev 9919) @@ -238,8 +238,8 @@ HWND NotificationWindow; unsigned int notification_msg; long notification_events; - HICON OldSmallIcon; - HICON OldLargeIcon; + HICON OldSmallIcon; // \x8Eg\x97p\x82\xB5\x82Ȃ\xA2 + HICON OldLargeIcon; // \x8Eg\x97p\x82\xB5\x82Ȃ\xA2 BOOL hostdlg_activated; BOOL hostdlg_Enabled;