From 251cffb638811b36779ea8364a63dd46b422dfbb Mon Sep 17 00:00:00 2001 From: Alexander Larsson Date: Thu, 9 Feb 2012 21:09:44 +0100 Subject: [PATCH] Fix transparency handling with non-double-buffered drawing Sometimes we need to read back the window content into our double buffer due to rendering a window with alpha when there is no implicit paint or it has been flushed due to non-db drawing before. However, in this case we can't use gdk_cairo_set_source_window as it might trigger an implicit paint flush as we detect what we think is a direct non-double buffered window draw operation, which will flush the implicit paint operation that we're just setting up. To fix this we use the raw gdk_window_ref_impl_surface operation to get the source surface. --- gdk/gdkwindow.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/gdk/gdkwindow.c b/gdk/gdkwindow.c index 1642424c67..d2a0f4f84b 100644 --- a/gdk/gdkwindow.c +++ b/gdk/gdkwindow.c @@ -2971,9 +2971,14 @@ gdk_window_begin_paint_region (GdkWindow *window, (implicit_paint && implicit_paint->flushed))) { cairo_t *cr = cairo_create (paint->surface); - gdk_cairo_set_source_window (cr, impl_window, - - (window->abs_x + clip_box.x), - - (window->abs_y + clip_box.y)); + /* We can't use gdk_cairo_set_source_window here, as that might + flush the implicit paint at an unfortunate time, since this + would be detected as a draw during non-expose time */ + cairo_surface_t *source_surface = gdk_window_ref_impl_surface (impl_window); + cairo_set_source_surface (cr, source_surface, + - (window->abs_x + clip_box.x), + - (window->abs_y + clip_box.y)); + cairo_surface_destroy (source_surface); cairo_paint (cr); cairo_destroy (cr); }