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

Christophe Fergeau cfergeau at redhat.com
Wed Dec 14 10:48:55 UTC 2011


ACK

On Tue, Dec 13, 2011 at 08:35:08PM +0100, Marc-André Lureau wrote:
> From: Marc-André Lureau <marcandre.lureau at 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);
> -- 
> 1.7.7.3
> 
> _______________________________________________
> virt-tools-list mailing list
> virt-tools-list at redhat.com
> https://www.redhat.com/mailman/listinfo/virt-tools-list
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/virt-tools-list/attachments/20111214/d945001d/attachment.sig>


More information about the virt-tools-list mailing list