From 5de1df1b947076f3b9d2b8253a55aa93403c4ee2 Mon Sep 17 00:00:00 2001 From: Simon Tatham Date: Sat, 12 Mar 2022 17:36:54 +0000 Subject: [PATCH] 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. --- windows/window.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/windows/window.c b/windows/window.c index 1bc12fd7..5a350b97 100644 --- a/windows/window.c +++ b/windows/window.c @@ -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); }