mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-06-30 19:12:48 -05:00
Move all window-title management into Terminal.
Previously, window title management happened in a bipartisan sort of way: front ends would choose their initial window title once they knew what host name they were connecting to, but then Terminal would override that later if the server set the window title by escape sequences. Now it's all done the same way round: the Terminal object is always where titles are invented, and they only propagate in one direction, from the Terminal to the TermWin. This allows us to avoid duplicating in multiple front ends the logic for what the initial window title should be. The frontend just has to make one initial call to term_setup_window_titles, to tell the terminal what hostname should go in the default title (if the Conf doesn't override even that). Thereafter, all it has to do is respond to the TermWin title-setting methods. Similarly, the logic that handles window-title changes as a result of the Change Settings dialog is also centralised into terminal.c. This involved introducing an extra term_pre_reconfig() call that each frontend can call to modify the Conf that will be used for the GUI configurer; that's where the code now lives that copies the current window title into there. (This also means that GTK PuTTY now behaves consistently with Windows PuTTY on that point; GTK's previous behaviour was less well thought out.) It also means there's no longer any need for Terminal to talk to the front end when a remote query wants to _find out_ the window title: the Terminal knows the answer already. So TermWin's get_title method can go.
This commit is contained in:
@ -253,7 +253,6 @@ static void wintw_palette_set(TermWin *, int n, int r, int g, int b);
|
||||
static void wintw_palette_reset(TermWin *);
|
||||
static void wintw_get_pos(TermWin *, int *x, int *y);
|
||||
static void wintw_get_pixels(TermWin *, int *x, int *y);
|
||||
static const char *wintw_get_title(TermWin *, bool icon);
|
||||
|
||||
static const TermWinVtable windows_termwin_vt = {
|
||||
.setup_draw_ctx = wintw_setup_draw_ctx,
|
||||
@ -282,7 +281,6 @@ static const TermWinVtable windows_termwin_vt = {
|
||||
.palette_reset = wintw_palette_reset,
|
||||
.get_pos = wintw_get_pos,
|
||||
.get_pixels = wintw_get_pixels,
|
||||
.get_title = wintw_get_title,
|
||||
};
|
||||
|
||||
static TermWin wintw[1];
|
||||
@ -361,7 +359,6 @@ static WinGuiSeat wgs = { .seat.vt = &win_seat_vt,
|
||||
static void start_backend(void)
|
||||
{
|
||||
const struct BackendVtable *vt;
|
||||
const char *title;
|
||||
char *error, *realhost;
|
||||
int i;
|
||||
|
||||
@ -395,16 +392,8 @@ static void start_backend(void)
|
||||
sfree(msg);
|
||||
exit(0);
|
||||
}
|
||||
window_name = icon_name = NULL;
|
||||
char *title_to_free = NULL;
|
||||
title = conf_get_str(conf, CONF_wintitle);
|
||||
if (!*title) {
|
||||
title_to_free = dupprintf("%s - %s", realhost, appname);
|
||||
title = title_to_free;
|
||||
}
|
||||
term_setup_window_titles(term, realhost);
|
||||
sfree(realhost);
|
||||
win_set_title(wintw, title);
|
||||
win_set_icon_title(wintw, title);
|
||||
|
||||
/*
|
||||
* Connect the terminal to the backend for resize purposes.
|
||||
@ -428,8 +417,6 @@ static void start_backend(void)
|
||||
}
|
||||
|
||||
session_closed = false;
|
||||
|
||||
sfree(title_to_free);
|
||||
}
|
||||
|
||||
static void close_session(void *ignored_context)
|
||||
@ -2328,14 +2315,7 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT message,
|
||||
else
|
||||
reconfiguring = true;
|
||||
|
||||
/*
|
||||
* Copy the current window title into the stored
|
||||
* previous configuration, so that doing nothing to
|
||||
* the window title field in the config box doesn't
|
||||
* reset the title to its startup state.
|
||||
*/
|
||||
conf_set_str(conf, CONF_wintitle, window_name);
|
||||
|
||||
term_pre_reconfig(term, conf);
|
||||
prev_conf = conf_copy(conf);
|
||||
|
||||
reconfig_result = do_reconfig(
|
||||
@ -2467,13 +2447,6 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT message,
|
||||
init_lvl = 2;
|
||||
}
|
||||
|
||||
win_set_title(wintw, conf_get_str(conf, CONF_wintitle));
|
||||
if (IsIconic(hwnd)) {
|
||||
SetWindowText(hwnd,
|
||||
conf_get_bool(conf, CONF_win_name_always) ?
|
||||
window_name : icon_name);
|
||||
}
|
||||
|
||||
{
|
||||
FontSpec *font = conf_get_fontspec(conf, CONF_font);
|
||||
FontSpec *prev_font = conf_get_fontspec(prev_conf,
|
||||
@ -5668,14 +5641,6 @@ static void wintw_get_pixels(TermWin *tw, int *x, int *y)
|
||||
*y = r.bottom - r.top;
|
||||
}
|
||||
|
||||
/*
|
||||
* Return the window or icon title.
|
||||
*/
|
||||
static const char *wintw_get_title(TermWin *tw, bool icon)
|
||||
{
|
||||
return icon ? icon_name : window_name;
|
||||
}
|
||||
|
||||
/*
|
||||
* See if we're in full-screen mode.
|
||||
*/
|
||||
|
Reference in New Issue
Block a user