[virt-tools-list] [PATCH virt-viewer 3/4] window: Scale down desktop if it does not fit into client screen

Jonathon Jongsma jjongsma at redhat.com
Wed Jul 15 18:16:17 UTC 2015


This seems like a better approach to me.  ACK.

On Tue, 2015-07-14 at 16:13 +0200, Pavel Grunt wrote:
> According to the description of virt_viewer_window_resize():
>  This code attempts to resize the top level window to be large enough
>  to contain the entire display desktop at 1:1 ratio. If the local desktop
>  isn't large enough that it goes as large as possible and lets the display
>  scale down to fit, maintaining aspect ratio
> 
> The window should be scale down by changing the zoom, not by resizing
> the desktop.
> 
> Before this commit the spice-guest would be resized if it does not fit
> into the client's screen. This commit changes it, so a spice guest
> will not be resized but it will be scaled down.
> 
> Resolves:
> https://bugzilla.redhat.com/show_bug.cgi?id=1221501
> ---
>  src/virt-viewer-window.c | 24 ++++++------------------
>  1 file changed, 6 insertions(+), 18 deletions(-)
> 
> diff --git a/src/virt-viewer-window.c b/src/virt-viewer-window.c
> index 153e707..a851022 100644
> --- a/src/virt-viewer-window.c
> +++ b/src/virt-viewer-window.c
> @@ -430,7 +430,6 @@ virt_viewer_window_resize(VirtViewerWindow *self)
>  {
>      GdkRectangle fullscreen;
>      GdkScreen *screen;
> -    int width, height;
>      double desktopAspect;
>      double screenAspect;
>      guint desktopWidth, display_width;
> @@ -466,30 +465,19 @@ virt_viewer_window_resize(VirtViewerWindow *self)
>  
>      if ((display_width > fullscreen.width) ||
>          (display_height > fullscreen.height)) {
> +        gint new_zoom;
>          /* Doesn't fit native res, so go as large as possible
>             maintaining aspect ratio */
>          if (screenAspect > desktopAspect) {
> -            width = fullscreen.height * desktopAspect;
> -            height = fullscreen.height;
> +            new_zoom = NORMAL_ZOOM_LEVEL * fullscreen.height / desktopHeight;
>          } else {
> -            width = fullscreen.width;
> -            height = fullscreen.width / desktopAspect;
> +            new_zoom = NORMAL_ZOOM_LEVEL * fullscreen.width / desktopWidth;
>          }
> -        width *= (double) NORMAL_ZOOM_LEVEL / priv->zoomlevel;
> -        height *= (double) NORMAL_ZOOM_LEVEL / priv->zoomlevel;
> +        g_debug("scaling down, desktop does not fit into screen");
> +        virt_viewer_window_set_zoom_level(self, new_zoom);
>      } else {
> -        width = desktopWidth;
> -        height = desktopHeight;
> +        virt_viewer_window_queue_resize(self);
>      }
> -
> -    g_debug("Decided todo %dx%d (desktop is %dx%d, fullscreen is %dx%d",
> -              width, height, desktopWidth, desktopHeight,
> -              fullscreen.width, fullscreen.height);
> -
> -    virt_viewer_display_set_desktop_size(VIRT_VIEWER_DISPLAY(priv->display),
> -                                         width, height);
> -
> -    virt_viewer_window_queue_resize(self);
>  }
>  
>  static void





More information about the virt-tools-list mailing list