summaryrefslogtreecommitdiffstats
path: root/src/virt-viewer-display.c
diff options
context:
space:
mode:
authorDaniel P. Berrange <berrange@redhat.com>2012-04-19 16:15:11 +0100
committerDaniel Berrange <berrange@minilan.home.berrange.com>2012-04-19 16:18:31 +0100
commitc1af3ab0cc3aad382f6bd396f62ae76f3052c553 (patch)
tree5d1829a4acdced2b36bad33fdad1cd65b514558c /src/virt-viewer-display.c
parentbe3ce01096feaca7d3a51ed07cc35b5b2a87633d (diff)
downloadvirt-viewer-c1af3ab0cc3aad382f6bd396f62ae76f3052c553.tar.gz
virt-viewer-c1af3ab0cc3aad382f6bd396f62ae76f3052c553.tar.xz
virt-viewer-c1af3ab0cc3aad382f6bd396f62ae76f3052c553.zip
Fix scaling of window to avoid integer truncation
Use round() instead of integer truncation when scaling the window, to avoid floating point precision problems on i386
Diffstat (limited to 'src/virt-viewer-display.c')
-rw-r--r--src/virt-viewer-display.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/virt-viewer-display.c b/src/virt-viewer-display.c
index 8cc079c..6d6052b 100644
--- a/src/virt-viewer-display.c
+++ b/src/virt-viewer-display.c
@@ -25,6 +25,7 @@
#include <config.h>
#include <locale.h>
+#include <math.h>
#include "virt-viewer-session.h"
#include "virt-viewer-display.h"
@@ -413,11 +414,11 @@ virt_viewer_display_size_allocate(GtkWidget *widget,
actualAspect = (double)width / (double)height;
if (actualAspect > desktopAspect) {
- child_allocation.width = height * desktopAspect;
+ child_allocation.width = round(height * desktopAspect);
child_allocation.height = height;
} else {
child_allocation.width = width;
- child_allocation.height = width / desktopAspect;
+ child_allocation.height = round(width / desktopAspect);
}
child_allocation.x = 0.5 * (width - child_allocation.width) + allocation->x + border_width;