gdk: Swap Cairo calls when reading back from a GdkWindow
authorEmmanuele Bassi <ebassi@gnome.org>
Sun, 26 Mar 2023 14:57:56 +0000 (15:57 +0100)
committerEmmanuele Bassi <ebassi@gnome.org>
Sun, 26 Mar 2023 14:57:56 +0000 (15:57 +0100)
First we flush the surface, then we mark it dirty.

Don't look at me: this makes sense in Cairo, apparently.

Fixes: #5691
gdk/gdkpixbuf-drawable.c

index ee88abe3b3d164e0106ca6eb3a9bb58a6cbbc960..e6fda26880b1eaa55f19db11626a5241fdfb6549 100644 (file)
@@ -104,16 +104,19 @@ gdk_pixbuf_get_from_window (GdkWindow *src,
    * by external applications.
    *
    * So be on the safe side and:
+   * - flush the Cairo state
    * - mark the surface as dirty, in case the GdkWindow was
    *   created from a foreign X11 surface
-   * - flush the Cairo state
+   *
+   * THE ORDER IS IMPORTANT. DO NOT CHANGE IT.
    *
    * For reference, see:
    * - https://bugzilla.gnome.org/show_bug.cgi?id=754952
    * - https://gitlab.gnome.org/GNOME/gtk/-/issues/4456
+   * - https://gitlab.gnome.org/GNOME/gtk/-/issues/5691
    */
-  cairo_surface_mark_dirty (surface);
   cairo_surface_flush (surface);
+  cairo_surface_mark_dirty (surface);
 
   if (cairo_surface_get_content (surface) & CAIRO_CONTENT_ALPHA)
     copy = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, width * scale, height * scale);