SSH 接続が切れたときに VT アイコンに戻らない問題を修正
ticket #43907
@@ -348,8 +348,6 @@ | ||
348 | 348 | } cygterm_t; |
349 | 349 | |
350 | 350 | /* TTTSet */ |
351 | -typedef struct tttset TTTSet, *PTTSet; | |
352 | - | |
353 | 351 | struct tttset { |
354 | 352 | /*------ VTSet --------*/ |
355 | 353 | /* Tera Term home directory */ |
@@ -551,7 +549,6 @@ | ||
551 | 549 | WORD CRSend_ini; |
552 | 550 | WORD LocalEcho_ini; |
553 | 551 | WORD UnicodeDecSpMapping; |
554 | - HINSTANCE Instance; | |
555 | 552 | WORD VTIcon; |
556 | 553 | WORD TEKIcon; |
557 | 554 | WORD ScrollWindowClearScreen; |
@@ -648,11 +645,14 @@ | ||
648 | 645 | wchar_t *ExeDirW; // ttermpro.exe のあるフォルダ |
649 | 646 | wchar_t *LogDirW; // logやダンプを置くフォルダ |
650 | 647 | wchar_t *FileDirW; // ダウンロードパス("%APPDATA%" 等が含まれる,使用前に環境変数を展開すること) |
648 | + HINSTANCE PluginVTIocnInstance; | |
649 | + WORD PluginVTIocnID; | |
651 | 650 | |
652 | - | |
653 | - void (*SetVTIcon)(TTTSet *ts, HINSTANCE Inst, WORD icon_id); | |
651 | + void (*SetVTIcon)(HINSTANCE hInstance, WORD IconID); | |
654 | 652 | }; |
655 | 653 | |
654 | +typedef struct tttset TTTSet, *PTTSet; | |
655 | + | |
656 | 656 | /* New Line modes */ |
657 | 657 | #define IdCR 1 |
658 | 658 | #define IdCRLF 2 |
@@ -243,7 +243,7 @@ | ||
243 | 243 | |
244 | 244 | static void SetIcon(HINSTANCE hInst_, HWND hWnd, const wchar_t *icon_name, int dpi) |
245 | 245 | { |
246 | - // 大きいアイコン(32x32,ディスプレイの拡大率が100%(dpi=76)のとき) | |
246 | + // 大きいアイコン(32x32,ディスプレイの拡大率が100%(dpi=96)のとき) | |
247 | 247 | HICON icon = TTLoadIcon(hInst_, icon_name, 0, 0, dpi); |
248 | 248 | icon = (HICON)::SendMessage(hWnd, WM_SETICON, ICON_BIG, (LPARAM)icon); |
249 | 249 | if (icon != NULL) { |
@@ -250,7 +250,7 @@ | ||
250 | 250 | DestroyIcon(icon); |
251 | 251 | } |
252 | 252 | |
253 | - // 大きいアイコン(16x16,ディスプレイの拡大率が100%(dpi=76)のとき) | |
253 | + // 大きいアイコン(16x16,ディスプレイの拡大率が100%(dpi=96)のとき) | |
254 | 254 | icon = TTLoadIcon(hInst_, icon_name, 16, 16, dpi); |
255 | 255 | icon = (HICON)::SendMessage(hWnd, WM_SETICON, ICON_SMALL, (LPARAM)icon); |
256 | 256 | if (icon != NULL) { |
@@ -269,12 +269,19 @@ | ||
269 | 269 | } |
270 | 270 | } |
271 | 271 | |
272 | -static void SetVTIcon(TTTSet *ts, HINSTANCE inst, WORD icon_id) | |
272 | +static void SetVTIcon(HINSTANCE hInstance, WORD IconID) | |
273 | 273 | { |
274 | - ts->Instance = inst; | |
275 | - ts->VTIcon = icon_id; | |
274 | + HINSTANCE inst; | |
275 | + WORD icon_id; | |
276 | + const int dpi = GetMonitorDpiFromWindow(HVTWin); | |
276 | 277 | |
277 | - const int dpi = GetMonitorDpiFromWindow(HVTWin); | |
278 | + ts.PluginVTIocnInstance = hInstance; | |
279 | + ts.PluginVTIocnID = IconID; | |
280 | + | |
281 | + inst = (ts.PluginVTIocnInstance == NULL) ? hInst : hInstance; | |
282 | + icon_id = (ts.PluginVTIocnID != 0) ? IconID : | |
283 | + (ts.VTIcon != IdIconDefault) ? ts.VTIcon | |
284 | + : IDI_VT; | |
278 | 285 | SetIcon(inst, HVTWin, MAKEINTRESOURCEW(icon_id), dpi); |
279 | 286 | } |
280 | 287 |
@@ -289,7 +296,6 @@ | ||
289 | 296 | int CmdShow; |
290 | 297 | BOOL isFirstInstance; |
291 | 298 | m_hInst = hInstance; |
292 | - ts.Instance = hInstance; | |
293 | 299 | |
294 | 300 | CommInit(&cv); |
295 | 301 | ts.SetVTIcon = SetVTIcon; |
@@ -457,10 +463,14 @@ | ||
457 | 463 | RegDeviceNotify(HVTWin); |
458 | 464 | |
459 | 465 | { |
466 | + HINSTANCE inst; | |
467 | + WORD icon_id; | |
460 | 468 | const int dpi = GetMonitorDpiFromWindow(m_hWnd); |
461 | - const int icon_id = (ts.VTIcon != IdIconDefault) ? ts.VTIcon : IDI_VT; | |
462 | - const wchar_t *icon_name = MAKEINTRESOURCEW(icon_id); | |
463 | - SetIcon(m_hInst, m_hWnd, icon_name, dpi); | |
469 | + inst = (ts.PluginVTIocnInstance != NULL) ? ts.PluginVTIocnInstance : m_hInst; | |
470 | + icon_id = (ts.PluginVTIocnID != 0) ? ts.PluginVTIocnID | |
471 | + : (ts.VTIcon != IdIconDefault) ? ts.VTIcon | |
472 | + : IDI_VT; | |
473 | + SetIcon(inst, m_hWnd, MAKEINTRESOURCEW(icon_id), dpi); | |
464 | 474 | } |
465 | 475 | SetCustomNotifyIcon( |
466 | 476 | (HICON)LoadImage( |
@@ -5071,10 +5081,13 @@ | ||
5071 | 5081 | ChangeCaret(); |
5072 | 5082 | |
5073 | 5083 | { |
5074 | - const int icon_id = (ts.VTIcon != IdIconDefault) ? ts.VTIcon : IDI_VT; | |
5075 | - const wchar_t *icon_name = MAKEINTRESOURCEW(icon_id); | |
5076 | - const HINSTANCE inst = ts.Instance; | |
5077 | - SetIcon(inst, m_hWnd, icon_name, NewDPI); | |
5084 | + HINSTANCE inst; | |
5085 | + WORD icon_id; | |
5086 | + inst = (ts.PluginVTIocnInstance != NULL) ? ts.PluginVTIocnInstance : hInst; | |
5087 | + icon_id = (ts.PluginVTIocnID != 0) ? ts.PluginVTIocnID | |
5088 | + : (ts.VTIcon != IdIconDefault) ? ts.VTIcon | |
5089 | + : IDI_VT; | |
5090 | + SetIcon(inst, m_hWnd, MAKEINTRESOURCEW(icon_id), NewDPI); | |
5078 | 5091 | } |
5079 | 5092 | |
5080 | 5093 | return TRUE; |
@@ -272,6 +272,9 @@ | ||
272 | 272 | else { |
273 | 273 | return FALSE; |
274 | 274 | } |
275 | + | |
276 | + ts->PluginVTIocnInstance = NULL; | |
277 | + ts->PluginVTIocnID = 0; | |
275 | 278 | } |
276 | 279 | |
277 | 280 | // 設定ファイルをディスクに保存し、Tera Term本体を再起動する。 |
@@ -115,11 +115,6 @@ | ||
115 | 115 | |
116 | 116 | HANDLE hInst; /* Instance handle of TTXSSH.DLL */ |
117 | 117 | |
118 | -static HICON SecureLargeIcon = NULL; | |
119 | -static HICON SecureSmallIcon = NULL; | |
120 | -static HICON SecureNotifyIcon = NULL; | |
121 | -static HICON OldNotifyIcon = NULL; | |
122 | - | |
123 | 118 | static TInstVar *pvar; |
124 | 119 | |
125 | 120 | typedef struct { |
@@ -187,19 +182,7 @@ | ||
187 | 182 | FWD_end(pvar); |
188 | 183 | FWDUI_end(pvar); |
189 | 184 | |
190 | - if (pvar->OldLargeIcon != NULL) { | |
191 | - PostMessage(pvar->NotificationWindow, WM_SETICON, ICON_BIG, | |
192 | - (LPARAM) pvar->OldLargeIcon); | |
193 | - pvar->OldLargeIcon = NULL; | |
194 | - } | |
195 | - if (pvar->OldSmallIcon != NULL) { | |
196 | - PostMessage(pvar->NotificationWindow, WM_SETICON, ICON_SMALL, | |
197 | - (LPARAM) pvar->OldSmallIcon); | |
198 | - pvar->OldSmallIcon = NULL; | |
199 | - } | |
200 | - if (OldNotifyIcon) { | |
201 | - SetCustomNotifyIcon(OldNotifyIcon); | |
202 | - } | |
185 | + pvar->ts->SetVTIcon(NULL, 0); | |
203 | 186 | |
204 | 187 | ssh_heartbeat_lock_finalize(); |
205 | 188 |
@@ -676,7 +659,7 @@ | ||
676 | 659 | |
677 | 660 | void notify_established_secure_connection(PTInstVar pvar) |
678 | 661 | { |
679 | - pvar->ts->SetVTIcon(pvar->ts, hInst, pvar->settings.IconID); | |
662 | + pvar->ts->SetVTIcon(hInst, pvar->settings.IconID); | |
680 | 663 | |
681 | 664 | logputs(LOG_LEVEL_VERBOSE, "Entering secure mode"); |
682 | 665 | } |
@@ -238,8 +238,8 @@ | ||
238 | 238 | HWND NotificationWindow; |
239 | 239 | unsigned int notification_msg; |
240 | 240 | long notification_events; |
241 | - HICON OldSmallIcon; | |
242 | - HICON OldLargeIcon; | |
241 | + HICON OldSmallIcon; // 使用しない | |
242 | + HICON OldLargeIcon; // 使用しない | |
243 | 243 | |
244 | 244 | BOOL hostdlg_activated; |
245 | 245 | BOOL hostdlg_Enabled; |