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
This commit is contained in:
Marc-André Lureau 2012-10-17 16:47:55 +02:00
parent 143bc8a33f
commit 435a542de2
2 changed files with 5 additions and 4 deletions

View File

@ -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);

View File

@ -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;