[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: [virt-tools-list] [PATCH 10/12] Resize guest desktop with SPICE



On Tue, Dec 13, 2011 at 08:35:08PM +0100, Marc-André Lureau wrote:
> From: Marc-André Lureau <marcandre lureau gmail com>
> 
> This is the method we prefer, even though we can't keep aspect ratio.
> We could eventually support aspect ration in spice-gtk.
> ---
>  src/virt-viewer-display-spice.c |    4 ++++
>  src/virt-viewer-display.c       |   21 +++++++++++++++++++--
>  src/virt-viewer-display.h       |    2 ++
>  3 files changed, 25 insertions(+), 2 deletions(-)
> 
> diff --git a/src/virt-viewer-display-spice.c b/src/virt-viewer-display-spice.c
> index c73692d..a8fc899 100644
> --- a/src/virt-viewer-display-spice.c
> +++ b/src/virt-viewer-display-spice.c
> @@ -73,6 +73,8 @@ static void
>  virt_viewer_display_spice_init(VirtViewerDisplaySpice *self G_GNUC_UNUSED)
>  {
>  	self->priv = VIRT_VIEWER_DISPLAY_SPICE_GET_PRIVATE(self);
> +
> +	virt_viewer_display_set_maintain_aspect_ratio(VIRT_VIEWER_DISPLAY(self), FALSE);
>  }
>  
>  static void
> @@ -122,6 +124,7 @@ primary_create(SpiceChannel *channel G_GNUC_UNUSED,
>  	DEBUG_LOG("spice desktop resize %dx%d", width, height);
>  
>  	virt_viewer_display_set_desktop_size(display, width, height);
> +	virt_viewer_display_set_zoom_level(display, 100);
>  }
>  
>  
> @@ -180,6 +183,7 @@ virt_viewer_display_spice_new(SpiceChannel *channel,
>  		     "resize-guest", FALSE,
>  		     "scaling", TRUE,
>  		     "auto-clipboard", TRUE,
> +		     "resize-guest", TRUE,
>  		     NULL);
>  
>  	g_signal_connect(self->priv->display,
> diff --git a/src/virt-viewer-display.c b/src/virt-viewer-display.c
> index fe25a8e..4558f68 100644
> --- a/src/virt-viewer-display.c
> +++ b/src/virt-viewer-display.c
> @@ -40,6 +40,7 @@ struct _VirtViewerDisplayPrivate
>  	gboolean zoom;
>          gint nth_display;
>          gint show_hint;
> +        gboolean maintain_aspect_ratio;
>  };
>  
>  static void virt_viewer_display_size_request(GtkWidget *widget,
> @@ -219,6 +220,7 @@ virt_viewer_display_init(VirtViewerDisplay *display)
>  	display->priv->zoom_level = 100;
>  	display->priv->zoom = TRUE;
>  	display->priv->dirty = TRUE;
> +        display->priv->maintain_aspect_ratio = TRUE;
>  }
>  
>  GtkWidget*
> @@ -376,7 +378,13 @@ virt_viewer_display_size_allocate(GtkWidget *widget,
>  
>  	desktopAspect = (double)priv->desktopWidth / (double)priv->desktopHeight;
>  
> -	if (child && gtk_widget_get_visible(child)) {
> +	if (child &&
> +            gtk_widget_get_visible(child)) {
> +                if (!priv->maintain_aspect_ratio) {
> +                        gtk_widget_size_allocate(child, allocation);
> +                        goto end;
> +                }
> +
>  		border_width = gtk_container_get_border_width(GTK_CONTAINER(display));
>  
>  		width  = MAX(1, allocation->width - 2 * border_width);
> @@ -398,7 +406,7 @@ virt_viewer_display_size_allocate(GtkWidget *widget,
>  		gtk_widget_size_allocate(child, &child_allocation);
>  	}
>  
> -
> +end:
>  	/* This unsets the size request, so that the user can
>  	 * manually resize the window smaller again
>  	 */
> @@ -409,6 +417,15 @@ virt_viewer_display_size_allocate(GtkWidget *widget,
>  }
>  
>  
> +void virt_viewer_display_set_maintain_aspect_ratio(VirtViewerDisplay *display,
> +						   gboolean maintain)
> +{
> +	g_return_if_fail(VIRT_VIEWER_IS_DISPLAY(display));
> +
> +	display->priv->maintain_aspect_ratio = maintain;
> +}
> +
> +
>  void virt_viewer_display_set_desktop_size(VirtViewerDisplay *display,
>  					  guint width,
>  					  guint height)
> diff --git a/src/virt-viewer-display.h b/src/virt-viewer-display.h
> index d49dd67..49365ff 100644
> --- a/src/virt-viewer-display.h
> +++ b/src/virt-viewer-display.h
> @@ -84,6 +84,8 @@ GType virt_viewer_display_get_type(void);
>  
>  GtkWidget *virt_viewer_display_new(void);
>  
> +void virt_viewer_display_set_maintain_aspect_ratio(VirtViewerDisplay *display,
> +                                                   gboolean maintain);
>  void virt_viewer_display_set_desktop_size(VirtViewerDisplay *display,
>  					  guint width,
>  					  guint height);


Enabling guest resize is fine in principle, but we can't do it
unconditionally like this. We can to take into account that not
everyone has the guest agent installed, and also that if you don't
have the QXL card, the resize behaviour is unusably bad because
it jumps between a mere 3 guest resolutions

There should be a boolean property to enable guest initiated
resizes, we should default to false. In virt-viewer we can look
at the XML to figure out if SPICE is configured with QXL + guest
agent and enable it.  We can also add a CLI arg to force enablement.


Daniel
-- 
|: http://berrange.com      -o-    http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org              -o-             http://virt-manager.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org       -o-       http://live.gnome.org/gtk-vnc :|


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]