diff options
author | Marc-André Lureau <marcandre.lureau@gmail.com> | 2012-10-17 16:47:55 +0200 |
---|---|---|
committer | Marc-André Lureau <marcandre.lureau@gmail.com> | 2012-10-17 16:50:14 +0200 |
commit | 435a542de205e4bf247b687b83b0742871204ea5 (patch) | |
tree | ac99149b8b061a5b7b3229f06c228373b6220a27 | |
parent | 143bc8a33f8b6b522dc96a3cabfa46deedb00bcc (diff) |
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
-rw-r--r-- | src/virt-viewer-display-spice.c | 5 | ||||
-rw-r--r-- | 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; |