diff options
author | Daniel P. Berrange <berrange@redhat.com> | 2012-04-19 16:15:11 +0100 |
---|---|---|
committer | Daniel Berrange <berrange@minilan.home.berrange.com> | 2012-04-19 16:18:31 +0100 |
commit | c1af3ab0cc3aad382f6bd396f62ae76f3052c553 (patch) | |
tree | 5d1829a4acdced2b36bad33fdad1cd65b514558c | |
parent | be3ce01096feaca7d3a51ed07cc35b5b2a87633d (diff) |
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
-rw-r--r-- | src/Makefile.am | 2 | ||||
-rw-r--r-- | src/virt-viewer-display.c | 5 |
2 files changed, 5 insertions, 2 deletions
diff --git a/src/Makefile.am b/src/Makefile.am index 1604b46..3f5f36f 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -55,6 +55,7 @@ virt_viewer_SOURCES = \ virt-viewer-main.c \ $(NULL) virt_viewer_LDFLAGS = \ + -lm \ $(GLIB2_LIBS) \ $(GTK_LIBS) \ $(LIBXML2_LIBS) \ @@ -87,6 +88,7 @@ remote_viewer_SOURCES = \ remote-viewer-main.c \ $(NULL) remote_viewer_LDFLAGS = \ + -lm \ $(GLIB2_LIBS) \ $(GTK_LIBS) \ $(LIBXML2_LIBS) \ 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; |