1
0
mirror of https://git.tartarus.org/simon/putty.git synced 2025-03-22 14:39:24 -05:00

GTK: remember to resize backing surface on a font change.

Changing the window's font size with Alt-< or Alt-> was not setting
any of the flags that make drawing_area_setup consider itself to have
been non-spuriously called, so the real window would enlarge without
the backing surface also doing so.
This commit is contained in:
Simon Tatham 2018-05-17 11:20:01 +01:00
parent 4467fa4d2a
commit 528513ddea

View File

@ -92,7 +92,7 @@ struct gui_data {
GtkWidget *window, *area, *sbar; GtkWidget *window, *area, *sbar;
gboolean sbar_visible; gboolean sbar_visible;
gboolean drawing_area_got_size, drawing_area_realised; gboolean drawing_area_got_size, drawing_area_realised;
gboolean drawing_area_setup_done; gboolean drawing_area_setup_needed;
GtkBox *hbox; GtkBox *hbox;
GtkAdjustment *sbar_adjust; GtkAdjustment *sbar_adjust;
GtkWidget *menu, *specialsmenu, *specialsitem1, *specialsitem2, GtkWidget *menu, *specialsmenu, *specialsitem1, *specialsitem2,
@ -646,26 +646,26 @@ static void drawing_area_setup(struct gui_data *inst, int width, int height)
inst->height = h; inst->height = h;
conf_set_int(inst->conf, CONF_width, inst->width); conf_set_int(inst->conf, CONF_width, inst->width);
conf_set_int(inst->conf, CONF_height, inst->height); conf_set_int(inst->conf, CONF_height, inst->height);
need_size = 1; inst->drawing_area_setup_needed = TRUE;
} }
#if GTK_CHECK_VERSION(3,10,0) #if GTK_CHECK_VERSION(3,10,0)
new_scale = gtk_widget_get_scale_factor(inst->area); new_scale = gtk_widget_get_scale_factor(inst->area);
if (new_scale != inst->scale)
inst->drawing_area_setup_needed = TRUE;
#else #else
new_scale = 1; new_scale = 1;
#endif #endif
/* /*
* If neither the terminal size nor the HiDPI scale factor has * This event might be spurious; some GTK setups have been known
* changed since the previous call to this function (and, in * to call it when nothing at all has changed. Check if we have
* particular, if there has at least _been_ a previous call to * any reason to proceed.
* this function), then, we can assume this event is spurious and
* do nothing further.
*/ */
if (inst->drawing_area_setup_done && if (!inst->drawing_area_setup_needed)
!need_size && new_scale == inst->scale)
return; return;
inst->drawing_area_setup_done = TRUE;
inst->drawing_area_setup_needed = FALSE;
inst->scale = new_scale; inst->scale = new_scale;
{ {
@ -734,7 +734,7 @@ static void area_realised(GtkWidget *widget, gpointer data)
inst->drawing_area_realised = TRUE; inst->drawing_area_realised = TRUE;
if (inst->drawing_area_realised && inst->drawing_area_got_size && if (inst->drawing_area_realised && inst->drawing_area_got_size &&
!inst->drawing_area_setup_done) inst->drawing_area_setup_needed)
drawing_area_setup_simple(inst); drawing_area_setup_simple(inst);
} }
@ -751,7 +751,7 @@ static void area_size_allocate(
#if GTK_CHECK_VERSION(3,10,0) #if GTK_CHECK_VERSION(3,10,0)
static void area_check_scale(struct gui_data *inst) static void area_check_scale(struct gui_data *inst)
{ {
if (inst->drawing_area_setup_done && if (!inst->drawing_area_setup_needed &&
inst->scale != gtk_widget_get_scale_factor(inst->area)) { inst->scale != gtk_widget_get_scale_factor(inst->area)) {
drawing_area_setup_simple(inst); drawing_area_setup_simple(inst);
if (inst->term) { if (inst->term) {
@ -4269,8 +4269,18 @@ char *setup_fonts_ucs(struct gui_data *inst)
inst->fonts[i] = fonts[i]; inst->fonts[i] = fonts[i];
} }
inst->font_width = inst->fonts[0]->width; if (inst->font_width != inst->fonts[0]->width ||
inst->font_height = inst->fonts[0]->height; inst->font_height != inst->fonts[0]->height) {
inst->font_width = inst->fonts[0]->width;
inst->font_height = inst->fonts[0]->height;
/*
* The font size has changed, so force the next call to
* drawing_area_setup to regenerate the backing surface.
*/
inst->drawing_area_setup_needed = TRUE;
}
inst->direct_to_font = init_ucs(&inst->ucsdata, inst->direct_to_font = init_ucs(&inst->ucsdata,
conf_get_str(inst->conf, CONF_line_codepage), conf_get_str(inst->conf, CONF_line_codepage),
@ -5119,6 +5129,7 @@ void new_session_window(Conf *conf, const char *geometry_string)
#if GTK_CHECK_VERSION(3,4,0) #if GTK_CHECK_VERSION(3,4,0)
inst->cumulative_scroll = 0.0; inst->cumulative_scroll = 0.0;
#endif #endif
inst->drawing_area_setup_needed = TRUE;
#ifndef NOT_X_WINDOWS #ifndef NOT_X_WINDOWS
inst->disp = get_x11_display(); inst->disp = get_x11_display();