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

GTK: don't try to change font size in mid-window-resize.

If the user holds down Alt-> so that the key repeats, then a second
call to change_font_size can occur while the window resize from the
previous one has yet to complete. This leads to the new pixel size of
the window from resize #1 being interpreted in the light of the font
size from reesize #2, so that the two get out of step and the
_character_ size of the terminal changes as a result.

The simplest fix is to disallow starting a second font-size-based
window resize while the first is still in flight - which, now that the
'win_resize_pending' flag lives in window.c and not terminal.c, is
easy to achieve.
This commit is contained in:
Simon Tatham 2022-05-12 19:38:45 +01:00
parent 4da67d8fa6
commit 80a87df618

View File

@ -1278,7 +1278,8 @@ gint key_event(GtkWidget *widget, GdkEventKey *event, gpointer data)
#ifdef KEY_EVENT_DIAGNOSTICS
debug(" - Ctrl->: increase font size\n");
#endif
change_font_size(inst, +1);
if (!inst->win_resize_pending)
change_font_size(inst, +1);
return true;
}
if (event->keyval == GDK_KEY_less &&
@ -1286,7 +1287,8 @@ gint key_event(GtkWidget *widget, GdkEventKey *event, gpointer data)
#ifdef KEY_EVENT_DIAGNOSTICS
debug(" - Ctrl-<: increase font size\n");
#endif
change_font_size(inst, -1);
if (!inst->win_resize_pending)
change_font_size(inst, -1);
return true;
}
@ -2513,10 +2515,9 @@ static void gtkwin_timer(void *vctx, unsigned long now)
}
}
static void gtkwin_request_resize(TermWin *tw, int w, int h)
static void request_resize_internal(GtkFrontend *inst, bool from_terminal,
int w, int h)
{
GtkFrontend *inst = container_of(tw, GtkFrontend, termwin);
#if GTK_CHECK_VERSION(2,0,0)
/*
* Initial check: don't even try to resize a window if it's in one
@ -2648,11 +2649,17 @@ static void gtkwin_request_resize(TermWin *tw, int w, int h)
#endif
inst->win_resize_pending = true;
inst->term_resize_notification_required = true;
inst->term_resize_notification_required = from_terminal;
inst->win_resize_timeout = schedule_timer(
WIN_RESIZE_TIMEOUT, gtkwin_timer, inst);
}
static void gtkwin_request_resize(TermWin *tw, int w, int h)
{
GtkFrontend *inst = container_of(tw, GtkFrontend, termwin);
request_resize_internal(inst, true, w, h);
}
#if GTK_CHECK_VERSION(3,0,0)
char *colour_to_css(const GdkColor *col)
{
@ -4834,9 +4841,9 @@ static void after_change_settings_dialog(void *vctx, int retval)
conf_get_int(newconf, CONF_window_border) ||
need_size) {
set_geom_hints(inst);
win_request_resize(&inst->termwin,
conf_get_int(newconf, CONF_width),
conf_get_int(newconf, CONF_height));
request_resize_internal(inst, false,
conf_get_int(newconf, CONF_width),
conf_get_int(newconf, CONF_height));
} else {
/*
* The above will have caused a call to term_size() for
@ -4909,8 +4916,8 @@ static void change_font_size(GtkFrontend *inst, int increment)
}
set_geom_hints(inst);
win_request_resize(&inst->termwin, conf_get_int(inst->conf, CONF_width),
conf_get_int(inst->conf, CONF_height));
request_resize_internal(inst, false, conf_get_int(inst->conf, CONF_width),
conf_get_int(inst->conf, CONF_height));
term_invalidate(inst->term);
gtk_widget_queue_draw(inst->area);