1
0
mirror of https://git.tartarus.org/simon/putty.git synced 2025-05-09 21:52:10 -05:00

GTK: flush target Cairo surface in 'draw' handler

In 687efc3a5da1fb85c86a3c871b00a7234b97c2e9, Simon noted that when PuTTY
was running under X and using an RGB24 image surface as its backing
surface, it would fail to draw on its window.  Changing the backing
image to ARGB32 caused the problem to go away.

If you set GDK_BACKEND=x11 and GDK_RENDERING=image, then PuTTY's
gdk_window_create_similar_surface() returns an RGB24 image surface, and
it appears to have precisely the same problem.  Dumping the surfaces to
PNG files revealed that Cairo thought they had the right context.  But
xtruss didn't show any actual requests to write to the window.

So on a hunch approximately as well-informed as Simon's, I added a call
to cairo_flush(), to explicitly ask Cairo to flush its changes to the
underlying surface.  I would have hoped that GTK would do something like
this for us, but adding that call seems to have made things work
properly.  Like Simon, I have no idea if this is the correct fix, but it
seems like a reasonable one and the problem is no longer occurring for
me.
This commit is contained in:
Ben Harris 2025-04-30 23:27:43 +01:00
parent dae2febd85
commit c60b2832f4

View File

@ -953,6 +953,7 @@ static gint draw_area(GtkWidget *widget, cairo_t *cr, gpointer data)
if (inst->surface) {
cairo_set_source_surface(cr, inst->surface, 0, 0);
cairo_paint(cr);
cairo_surface_flush(cairo_get_target(cr));
}
return true;