Mark surface as dirty before flushing it
authorEmmanuele Bassi <ebassi@gnome.org>
Sun, 12 Feb 2023 19:18:00 +0000 (19:18 +0000)
committerEmmanuele Bassi <ebassi@gnome.org>
Sun, 12 Feb 2023 19:19:25 +0000 (19:19 +0000)
If we're trying to read back the contents of a GdkWindow that was
created from a foreign windowing system surface, we are going to
forcibly mark it as dirty before flushing the Cairo state.

To avoid regressing any further in the future of the 3.x branch, let's
leave a comment.

Fixes: #5482
gdk/gdkpixbuf-drawable.c

index e63c3a8713d20c8cc0feda78e11c7407123f856d..ee88abe3b3d164e0106ca6eb3a9bb58a6cbbc960 100644 (file)
@@ -102,8 +102,17 @@ gdk_pixbuf_get_from_window (GdkWindow *src,
   /* We do not know what happened to this surface outside of GDK.
    * Especially for foreign windows, they will have been modified
    * by external applications.
+   *
    * So be on the safe side and:
+   * - mark the surface as dirty, in case the GdkWindow was
+   *   created from a foreign X11 surface
+   * - flush the Cairo state
+   *
+   * For reference, see:
+   * - https://bugzilla.gnome.org/show_bug.cgi?id=754952
+   * - https://gitlab.gnome.org/GNOME/gtk/-/issues/4456
    */
+  cairo_surface_mark_dirty (surface);
   cairo_surface_flush (surface);
 
   if (cairo_surface_get_content (surface) & CAIRO_CONTENT_ALPHA)