Backport upstream patch to fix outdated screen state on screenshots.

Closes: #1031112.
This commit is contained in:
Dmitry Shachnev
2023-02-15 12:44:46 +03:00
parent 19ee51b827
commit edaf297d8b
2 changed files with 41 additions and 0 deletions

View File

@ -0,0 +1,40 @@
From: Emmanuele Bassi <ebassi@gnome.org>
Date: Sun, 12 Feb 2023 19:18:00 +0000
Subject: Mark surface as dirty before flushing it
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.
Bug: https://gitlab.gnome.org/GNOME/gtk/-/issues/5482
Bug-Debian: https://bugs.debian.org/1031112
Origin: upstream, 3.24.37, commit:fba09dbfc7
---
gdk/gdkpixbuf-drawable.c | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/gdk/gdkpixbuf-drawable.c b/gdk/gdkpixbuf-drawable.c
index e63c3a8..ee88abe 100644
--- a/gdk/gdkpixbuf-drawable.c
+++ b/gdk/gdkpixbuf-drawable.c
@@ -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)

View File

@ -23,3 +23,4 @@ reftest_compare_surfaces-Report-how-much-the-images-diffe.patch
reftests-Allow-minor-differences-to-be-tolerated.patch
window-focus-on-window-show-for-wayland-activation.patch
gdk-wayland-save-custom-xdg-activation-startup_id.patch
Mark-surface-as-dirty-before-flushing-it.patch