1
0
mirror of https://git.tartarus.org/simon/putty.git synced 2025-01-10 01:48:00 +00:00

Windows: avoid idempotent window title changes.

By testing on a platform slow enough to show the flicker, I happened
to notice that if your shell prompt resets the window title every time
it's displayed, this was actually resulting in a call to SetWindowText
every time, which caused the GUI to actually do work.

There's certainly no need for that! We can at least avoid bothering if
the new title is identical to the old one.
This commit is contained in:
Simon Tatham 2022-03-12 17:36:54 +00:00
parent 901667280a
commit 5de1df1b94

View File

@ -4758,16 +4758,26 @@ static int TranslateKey(UINT message, WPARAM wParam, LPARAM lParam,
static void wintw_set_title(TermWin *tw, const char *title, int codepage)
{
wchar_t *new_window_name = dup_mb_to_wc(codepage, 0, title);
if (!wcscmp(new_window_name, window_name)) {
sfree(new_window_name);
return;
}
sfree(window_name);
window_name = dup_mb_to_wc(codepage, 0, title);
window_name = new_window_name;
if (conf_get_bool(conf, CONF_win_name_always) || !IsIconic(wgs.term_hwnd))
SetWindowTextW(wgs.term_hwnd, window_name);
}
static void wintw_set_icon_title(TermWin *tw, const char *title, int codepage)
{
wchar_t *new_icon_name = dup_mb_to_wc(codepage, 0, title);
if (!wcscmp(new_icon_name, icon_name)) {
sfree(new_icon_name);
return;
}
sfree(icon_name);
icon_name = dup_mb_to_wc(codepage, 0, title);
icon_name = new_icon_name;
if (!conf_get_bool(conf, CONF_win_name_always) && IsIconic(wgs.term_hwnd))
SetWindowTextW(wgs.term_hwnd, icon_name);
}