File virtview-git-spice-rounding.patch of Package virt-viewer

Subject: spice: avoid rounding issues when scaling up display
From: Marc-André Lureau marcandre.lureau@gmail.com Wed Oct 17 16:47:55 2012 +0200
Date: Wed Oct 17 16:50:14 2012 +0200:
Git: 435a542de205e4bf247b687b83b0742871204ea5

Fix some unwanted guest resize due to rounding issues (at least when
scaling up)

We may want to save the original remote desktop size, instead of
always checking widget requisition. That way zooming shouldn't resize
guest at all, but it seems tricky to handle that special case vs user
window resize that should trigger guest resize.

https://bugzilla.redhat.com/show_bug.cgi?id=856678

Index: virt-viewer-0.5.4/src/virt-viewer-display-spice.c
===================================================================
--- virt-viewer-0.5.4.orig/src/virt-viewer-display-spice.c
+++ virt-viewer-0.5.4/src/virt-viewer-display-spice.c
@@ -24,6 +24,7 @@
 
 #include <config.h>
 
+#include <math.h>
 #include <spice-audio.h>
 
 #include <glib/gi18n.h>
@@ -191,8 +192,8 @@ virt_viewer_display_spice_size_allocate(
     if (virt_viewer_display_get_zoom(VIRT_VIEWER_DISPLAY(self))) {
         zoom = virt_viewer_display_get_zoom_level(VIRT_VIEWER_DISPLAY(self));
 
-        dw /= ((double)zoom / 100.0);
-        dh /= ((double)zoom / 100.0);
+        dw = round(dw * 100 / zoom);
+        dh = round(dh * 100 / zoom);
     }
 
     g_object_get(self, "nth-display", &nth, NULL);
Index: virt-viewer-0.5.4/src/virt-viewer-display.c
===================================================================
--- virt-viewer-0.5.4.orig/src/virt-viewer-display.c
+++ virt-viewer-0.5.4/src/virt-viewer-display.c
@@ -354,8 +354,8 @@ virt_viewer_display_size_request(GtkWidg
 
     if (priv->dirty) {
         if (priv->zoom) {
-            requisition->width += priv->desktopWidth * priv->zoom_level / 100;
-            requisition->height += priv->desktopHeight * priv->zoom_level / 100;
+            requisition->width += round(priv->desktopWidth * priv->zoom_level / 100.0);
+            requisition->height += round(priv->desktopHeight * priv->zoom_level / 100.0);
         } else {
             requisition->width += priv->desktopWidth;
             requisition->height += priv->desktopHeight;
openSUSE Build Service is sponsored by