[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[virt-tools-list] [PATCH virt-viewer] spice: avoid rounding issues when scaling up display



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
---
 src/virt-viewer-display-spice.c | 5 +++--
 src/virt-viewer-display.c       | 4 ++--
 2 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/src/virt-viewer-display-spice.c b/src/virt-viewer-display-spice.c
index 8845ee0..a035517 100644
--- a/src/virt-viewer-display-spice.c
+++ b/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(VirtViewerDisplaySpice *self,
     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);
diff --git a/src/virt-viewer-display.c b/src/virt-viewer-display.c
index fe7ce4f..e5cdeb7 100644
--- a/src/virt-viewer-display.c
+++ b/src/virt-viewer-display.c
@@ -354,8 +354,8 @@ virt_viewer_display_size_request(GtkWidget *widget,
 
     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;
-- 
1.7.11.7


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]