mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-07-01 03:22: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:
@ -629,15 +629,6 @@ static bool find_and_raise_dialog(GtkFrontend *inst, enum DialogSlot slot)
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
* Return the window or icon title.
|
||||
*/
|
||||
static const char *gtkwin_get_title(TermWin *tw, bool icon)
|
||||
{
|
||||
GtkFrontend *inst = container_of(tw, GtkFrontend, termwin);
|
||||
return icon ? inst->icontitle : inst->wintitle;
|
||||
}
|
||||
|
||||
static void warn_on_close_callback(void *vctx, int result)
|
||||
{
|
||||
GtkFrontend *inst = (GtkFrontend *)vctx;
|
||||
@ -3330,15 +3321,6 @@ static void gtkwin_set_icon_title(TermWin *tw, const char *title)
|
||||
set_window_titles(inst);
|
||||
}
|
||||
|
||||
void set_title_and_icon(GtkFrontend *inst, char *title, char *icon)
|
||||
{
|
||||
sfree(inst->wintitle);
|
||||
inst->wintitle = dupstr(title);
|
||||
sfree(inst->icontitle);
|
||||
inst->icontitle = dupstr(icon);
|
||||
set_window_titles(inst);
|
||||
}
|
||||
|
||||
static void gtkwin_set_scrollbar(TermWin *tw, int total, int start, int page)
|
||||
{
|
||||
GtkFrontend *inst = container_of(tw, GtkFrontend, termwin);
|
||||
@ -4630,6 +4612,8 @@ void change_settings_menuitem(GtkMenuItem *item, gpointer data)
|
||||
ctx->inst = inst;
|
||||
ctx->newconf = conf_copy(inst->conf);
|
||||
|
||||
term_pre_reconfig(inst->term, ctx->newconf);
|
||||
|
||||
dialog = create_config_box(
|
||||
title, ctx->newconf, true,
|
||||
inst->backend ? backend_cfg_info(inst->backend) : 0,
|
||||
@ -4731,15 +4715,6 @@ static void after_change_settings_dialog(void *vctx, int retval)
|
||||
? 0 : 1);
|
||||
}
|
||||
|
||||
/*
|
||||
* Change the window title, if required.
|
||||
*/
|
||||
if (strcmp(conf_get_str(oldconf, CONF_wintitle),
|
||||
conf_get_str(newconf, CONF_wintitle)))
|
||||
win_set_title(&inst->termwin,
|
||||
conf_get_str(newconf, CONF_wintitle));
|
||||
set_window_titles(inst);
|
||||
|
||||
/*
|
||||
* Redo the whole tangled fonts and Unicode mess if
|
||||
* necessary.
|
||||
@ -5097,7 +5072,6 @@ static void start_backend(GtkFrontend *inst)
|
||||
{
|
||||
const struct BackendVtable *vt;
|
||||
char *error, *realhost;
|
||||
char *s;
|
||||
|
||||
vt = select_backend(inst->conf);
|
||||
|
||||
@ -5119,14 +5093,7 @@ static void start_backend(GtkFrontend *inst)
|
||||
return;
|
||||
}
|
||||
|
||||
s = conf_get_str(inst->conf, CONF_wintitle);
|
||||
if (s[0]) {
|
||||
set_title_and_icon(inst, s, s);
|
||||
} else {
|
||||
char *title = make_default_wintitle(realhost);
|
||||
set_title_and_icon(inst, title, title);
|
||||
sfree(title);
|
||||
}
|
||||
term_setup_window_titles(inst->term, realhost);
|
||||
sfree(realhost);
|
||||
|
||||
term_provide_backend(inst->term, inst->backend);
|
||||
@ -5190,7 +5157,6 @@ static const TermWinVtable gtk_termwin_vt = {
|
||||
.palette_reset = gtkwin_palette_reset,
|
||||
.get_pos = gtkwin_get_pos,
|
||||
.get_pixels = gtkwin_get_pixels,
|
||||
.get_title = gtkwin_get_title,
|
||||
};
|
||||
|
||||
void new_session_window(Conf *conf, const char *geometry_string)
|
||||
|
@ -245,9 +245,6 @@ GtkWidget *create_message_box(
|
||||
post_dialog_fn_t after, void *afterctx);
|
||||
#endif
|
||||
|
||||
/* Things gtkwin.c needs from {ptermm,uxputty}.c */
|
||||
char *make_default_wintitle(char *hostname);
|
||||
|
||||
/* gtkwin.c needs this special function in xkeysym.c */
|
||||
int keysym_to_unicode(int keysym);
|
||||
|
||||
|
@ -41,11 +41,6 @@ void cleanup_exit(int code)
|
||||
exit(code);
|
||||
}
|
||||
|
||||
char *make_default_wintitle(char *hostname)
|
||||
{
|
||||
return dupstr("pterm");
|
||||
}
|
||||
|
||||
void setup(bool single)
|
||||
{
|
||||
settings_set_default_protocol(-1);
|
||||
|
@ -56,11 +56,6 @@ void initial_config_box(Conf *conf, post_dialog_fn_t after, void *afterctx)
|
||||
const bool use_event_log = true, new_session = true, saved_sessions = true;
|
||||
const bool dup_check_launchable = true;
|
||||
|
||||
char *make_default_wintitle(char *hostname)
|
||||
{
|
||||
return dupcat(hostname, " - ", appname);
|
||||
}
|
||||
|
||||
/*
|
||||
* X11-forwarding-related things suitable for Gtk app.
|
||||
*/
|
||||
|
Reference in New Issue
Block a user