From 8b491946ef0d7f34b310faf5bf484f5a419887a2 Mon Sep 17 00:00:00 2001 From: Simon Tatham Date: Sat, 3 Oct 2015 12:27:47 +0100 Subject: [PATCH] Don't refresh backing store on a no-op configure event. Sometimes, we can get a "configure_area" event telling us that the drawing area has changed size to the same size it already was. This can happen when we change puzzle presets in a way that doesn't change the size, and also sometimes seems to happen as a side effect of changing the text in the status line. In that situation, it's a waste of effort - and can cause visible on-screen flicker - to throw away the window's backing image and pixmap and regenerate them from scratch. So now we detect a non-resize and avoid doing all that. The only thing we retain unconditionally in configure_area is the midend_force_redraw, because that's the place where a puzzle redraw is forced when changing presets or loading a new game. --- gtk.c | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/gtk.c b/gtk.c index 3e8df06..0189d26 100644 --- a/gtk.c +++ b/gtk.c @@ -1199,18 +1199,24 @@ static gint configure_area(GtkWidget *widget, frontend *fe = (frontend *)data; int x, y; - if (backing_store_ok(fe)) - teardown_backing_store(fe); - - x = fe->w = event->width; - y = fe->h = event->height; - midend_size(fe->me, &x, &y, TRUE); - fe->pw = x; - fe->ph = y; - fe->ox = (fe->w - fe->pw) / 2; - fe->oy = (fe->h - fe->ph) / 2; - - setup_backing_store(fe); + x = event->width; + y = event->height; + + if (x != fe->w || y != fe->h || !backing_store_ok(fe)) { + if (backing_store_ok(fe)) + teardown_backing_store(fe); + + fe->w = x; + fe->h = y; + midend_size(fe->me, &x, &y, TRUE); + fe->pw = x; + fe->ph = y; + fe->ox = (fe->w - fe->pw) / 2; + fe->oy = (fe->h - fe->ph) / 2; + + setup_backing_store(fe); + } + midend_force_redraw(fe->me); return TRUE; -- 2.30.2