From e88c7192891482065200b6e7b1f3bdb263145f84 Mon Sep 17 00:00:00 2001 From: Alexander Larsson Date: Thu, 30 Aug 2012 19:29:46 +0200 Subject: [PATCH 2/2] Add only_downscale property When this is enabled we never scale displays larger than their actual size. https://bugs.freedesktop.org/show_bug.cgi?id=54277 --- gtk/spice-widget-priv.h | 1 + gtk/spice-widget.c | 24 ++++++++++++++++++++++-- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/gtk/spice-widget-priv.h b/gtk/spice-widget-priv.h index 7d59359..4ed5fbc 100644 --- a/gtk/spice-widget-priv.h +++ b/gtk/spice-widget-priv.h @@ -67,6 +67,7 @@ struct _SpiceDisplayPrivate { bool convert; bool have_mitshm; gboolean allow_scaling; + gboolean only_downscale; gboolean disable_inputs; /* TODO: make a display object instead? */ diff --git a/gtk/spice-widget.c b/gtk/spice-widget.c index fa890a7..118daac 100644 --- a/gtk/spice-widget.c +++ b/gtk/spice-widget.c @@ -100,6 +100,7 @@ enum { PROP_RESIZE_GUEST, PROP_AUTO_CLIPBOARD, PROP_SCALING, + PROP_ONLY_DOWNSCALE, PROP_DISABLE_INPUTS, PROP_ZOOM_LEVEL, PROP_MONITOR_ID, @@ -170,10 +171,13 @@ static void spice_display_get_property(GObject *object, break; case PROP_SCALING: g_value_set_boolean(value, d->allow_scaling); - break; + break; + case PROP_ONLY_DOWNSCALE: + g_value_set_boolean(value, d->only_downscale); + break; case PROP_DISABLE_INPUTS: g_value_set_boolean(value, d->disable_inputs); - break; + break; case PROP_ZOOM_LEVEL: g_value_set_int(value, d->zoom_level); break; @@ -335,6 +339,10 @@ static void spice_display_set_property(GObject *object, d->allow_scaling = g_value_get_boolean(value); scaling_updated(display); break; + case PROP_ONLY_DOWNSCALE: + d->only_downscale = g_value_get_boolean(value); + scaling_updated(display); + break; case PROP_AUTO_CLIPBOARD: g_object_set(d->gtk_session, "auto-clipboard", g_value_get_boolean(value), NULL); @@ -1627,6 +1635,15 @@ static void spice_display_class_init(SpiceDisplayClass *klass) (gobject_class, PROP_SCALING, g_param_spec_boolean("scaling", "Scaling", "Whether we should use scaling", + TRUE, + G_PARAM_READWRITE | + G_PARAM_CONSTRUCT | + G_PARAM_STATIC_STRINGS)); + + g_object_class_install_property + (gobject_class, PROP_ONLY_DOWNSCALE, + g_param_spec_boolean("only-downscale", "Only Downscale", + "If scaling, only scale down, never up", FALSE, G_PARAM_READWRITE | G_PARAM_CONSTRUCT | @@ -1994,6 +2011,9 @@ void spice_display_get_scaling(SpiceDisplay *display, } else { s = MIN ((double)ww / (double)fbw, (double)wh / (double)fbh); + if (d->only_downscale && s >= 1.0) + s = 1.0; + /* Round to int size */ w = floor (fbw * s + 0.5); h = floor (fbh * s + 0.5); -- 1.7.11.4