1
0
mirror of https://git.tartarus.org/simon/putty.git synced 2025-01-10 09:58:01 +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,6 +1278,7 @@ gint key_event(GtkWidget *widget, GdkEventKey *event, gpointer data)
#ifdef KEY_EVENT_DIAGNOSTICS #ifdef KEY_EVENT_DIAGNOSTICS
debug(" - Ctrl->: increase font size\n"); debug(" - Ctrl->: increase font size\n");
#endif #endif
if (!inst->win_resize_pending)
change_font_size(inst, +1); change_font_size(inst, +1);
return true; return true;
} }
@ -1286,6 +1287,7 @@ gint key_event(GtkWidget *widget, GdkEventKey *event, gpointer data)
#ifdef KEY_EVENT_DIAGNOSTICS #ifdef KEY_EVENT_DIAGNOSTICS
debug(" - Ctrl-<: increase font size\n"); debug(" - Ctrl-<: increase font size\n");
#endif #endif
if (!inst->win_resize_pending)
change_font_size(inst, -1); change_font_size(inst, -1);
return true; 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) #if GTK_CHECK_VERSION(2,0,0)
/* /*
* Initial check: don't even try to resize a window if it's in one * 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 #endif
inst->win_resize_pending = true; inst->win_resize_pending = true;
inst->term_resize_notification_required = true; inst->term_resize_notification_required = from_terminal;
inst->win_resize_timeout = schedule_timer( inst->win_resize_timeout = schedule_timer(
WIN_RESIZE_TIMEOUT, gtkwin_timer, inst); 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) #if GTK_CHECK_VERSION(3,0,0)
char *colour_to_css(const GdkColor *col) char *colour_to_css(const GdkColor *col)
{ {
@ -4834,7 +4841,7 @@ static void after_change_settings_dialog(void *vctx, int retval)
conf_get_int(newconf, CONF_window_border) || conf_get_int(newconf, CONF_window_border) ||
need_size) { need_size) {
set_geom_hints(inst); set_geom_hints(inst);
win_request_resize(&inst->termwin, request_resize_internal(inst, false,
conf_get_int(newconf, CONF_width), conf_get_int(newconf, CONF_width),
conf_get_int(newconf, CONF_height)); conf_get_int(newconf, CONF_height));
} else { } else {
@ -4909,7 +4916,7 @@ static void change_font_size(GtkFrontend *inst, int increment)
} }
set_geom_hints(inst); set_geom_hints(inst);
win_request_resize(&inst->termwin, conf_get_int(inst->conf, CONF_width), request_resize_internal(inst, false, conf_get_int(inst->conf, CONF_width),
conf_get_int(inst->conf, CONF_height)); conf_get_int(inst->conf, CONF_height));
term_invalidate(inst->term); term_invalidate(inst->term);
gtk_widget_queue_draw(inst->area); gtk_widget_queue_draw(inst->area);