From 9427f9699d1072f4598753e77681b3a8b59a48a7 Mon Sep 17 00:00:00 2001 From: Simon Tatham Date: Thu, 3 Feb 2022 17:56:38 +0000 Subject: [PATCH] GTK: fix junk in window margin with fixed-size windows. When the window can't be resized for any reason, there will be extra space inside the drawing area that's not part of our standard width*font_width+2*window_border. We should include that in the backing surface and make sure we erase it to the background colour, otherwise it can end up containing unwanted visual junk. An example is the same case described in the previous commit: maximise the window and then start playing about with the font size. If you do this while running a full-screen application that displays text in the bottom line, it's easy to see that part of the previous display is left over and not cleared when the new font size leaves more space at the bottom than the old one. --- unix/window.c | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/unix/window.c b/unix/window.c index 9d46e96d..a8e73789 100644 --- a/unix/window.c +++ b/unix/window.c @@ -736,10 +736,8 @@ static void drawing_area_setup(GtkFrontend *inst, int width, int height) new_scale = 1; #endif - int new_backing_w = w * inst->font_width + 2*inst->window_border; - int new_backing_h = h * inst->font_height + 2*inst->window_border; - new_backing_w *= new_scale; - new_backing_h *= new_scale; + int new_backing_w = width * new_scale; + int new_backing_h = height * new_scale; if (inst->backing_w != new_backing_w || inst->backing_h != new_backing_h) inst->drawing_area_setup_needed = true; @@ -3754,16 +3752,12 @@ static void draw_stretch_after(GtkFrontend *inst, int x, int y, static void draw_backing_rect(GtkFrontend *inst) { - int w, h; - if (!win_setup_draw_ctx(&inst->termwin)) return; - w = inst->width * inst->font_width + 2*inst->window_border; - h = inst->height * inst->font_height + 2*inst->window_border; draw_set_colour(inst, 258, false); - draw_rectangle(inst, true, 0, 0, w, h); - draw_update(inst, 0, 0, w, h); + draw_rectangle(inst, true, 0, 0, inst->backing_w, inst->backing_h); + draw_update(inst, 0, 0, inst->backing_w, inst->backing_h); win_free_draw_ctx(&inst->termwin); }