[virt-tools-list] [PATCH virt-viewer] window: take zoom-level into account for display limits

Jonathon Jongsma jjongsma at redhat.com
Wed Jun 11 20:12:18 UTC 2014


On Wed, Jun 11, 2014 at 2:38 PM, Marc-André Lureau 
<marcandre.lureau at gmail.com> wrote:
> From: Marc-André Lureau <marcandre.lureau at redhat.com>
> 
> Fixes guest can not be resized to expected window size after zoom out.
> 
> https://bugzilla.redhat.com/show_bug.cgi?id=1105528
> ---
>  src/virt-viewer-window.c | 13 +++++++++----
>  1 file changed, 9 insertions(+), 4 deletions(-)
> 
> diff --git a/src/virt-viewer-window.c b/src/virt-viewer-window.c
> index a7ac120..22326e8 100644
> --- a/src/virt-viewer-window.c
> +++ b/src/virt-viewer-window.c
> @@ -405,8 +405,8 @@ virt_viewer_window_resize(VirtViewerWindow *self, 
> gboolean keep_win_size)
>      int width, height;
>      double desktopAspect;
>      double screenAspect;
> -    guint desktopWidth;
> -    guint desktopHeight;
> +    guint desktopWidth, display_width;
> +    guint desktopHeight, display_height;
>      VirtViewerWindowPrivate *priv = self->priv;
>  
>      if (priv->fullscreen)
> @@ -433,8 +433,11 @@ virt_viewer_window_resize(VirtViewerWindow 
> *self, gboolean keep_win_size)
>      desktopAspect = (double)desktopWidth / (double)desktopHeight;
>      screenAspect = (double)fullscreen.width / 
> (double)fullscreen.height;
>  
> -    if ((desktopWidth > fullscreen.width) ||
> -        (desktopHeight > fullscreen.height)) {
> +    display_width = desktopWidth * priv->zoomlevel / 100.0;
> +    display_height = desktopHeight * priv->zoomlevel / 100.0;
> +
> +    if ((display_width > fullscreen.width) ||
> +        (display_height > fullscreen.height)) {
>          /* Doesn't fit native res, so go as large as possible
>             maintaining aspect ratio */
>          if (screenAspect > desktopAspect) {
> @@ -444,6 +447,8 @@ virt_viewer_window_resize(VirtViewerWindow *self, 
> gboolean keep_win_size)
>              width = fullscreen.width;
>              height = fullscreen.width / desktopAspect;
>          }
> +        width *= 100.0 / priv->zoomlevel;
> +        height *= 100.0 / priv->zoomlevel;
>      } else {
>          width = desktopWidth;
>          height = desktopHeight;
> -- 
> 1.9.3
> 
> _______________________________________________
> virt-tools-list mailing list
> virt-tools-list at redhat.com
> https://www.redhat.com/mailman/listinfo/virt-tools-list


Looks fine. ACK.

(or you could simply scale the 'fullscreen' variable instead of 
unscaling and re-scaling the desktop width/height)

Jonathon







More information about the virt-tools-list mailing list