[Spice-devel] [PATCH spice-gtk] spice-widget: Fix invalidate region in case of image is scaled

Frediano Ziglio fziglio at redhat.com
Mon Oct 14 10:54:43 UTC 2019


In case the drawing on the screen is scaled the scaling required to
invalidate a slightly bigger region.
This is due to the interpolation done during the resize.
So if scaling is performed invalidate also the adjacent pixels.

This fixes https://gitlab.freedesktop.org/spice/spice-gtk/issues/19.

Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
---
 src/spice-widget.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/src/spice-widget.c b/src/spice-widget.c
index d73e02f2..9d6899c0 100644
--- a/src/spice-widget.c
+++ b/src/spice-widget.c
@@ -2847,6 +2847,14 @@ static void invalidate(SpiceChannel *channel,
                               &display_x, &display_y,
                               NULL, NULL);
 
+    gint scale_factor = gtk_widget_get_scale_factor(GTK_WIDGET(display));
+    if (s * scale_factor > 1) {
+        rect.x -= 1;
+        rect.y -= 1;
+        rect.width += 2;
+        rect.height += 2;
+    }
+
     x1 = floor ((rect.x - d->area.x) * s);
     y1 = floor ((rect.y - d->area.y) * s);
     x2 = ceil ((rect.x - d->area.x + rect.width) * s);
-- 
2.21.0



More information about the Spice-devel mailing list