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

Pavel Grunt pgrunt at redhat.com
Thu Jul 16 10:03:09 UTC 2015


Hi Jonathon,

On Wed, 2015-07-15 at 14:05 -0500, Jonathon Jongsma wrote:
> Hm, maybe not so fast.
> 
> After a little more testing, I found the following situation:
> 
> 1. zoom out a couple of times
> 2. now enlarge the window a bit so that the client resolution exceeds
> the size of the client monitor (you can only do this because you're
> zoomed out)
thanks to fix for https://bugzilla.redhat.com/show_bug.cgi?id=1105528
> 3. now click "View > Zoom > Normal size"
> 
> When running GNOME 3, after step #3 the window will be constrained to
> the size of the client monitor. This results in virt-viewer sending a
> new monitors config message down to the guest to adjust it to the size
> of the client monitor. But at the same time, the code below adjusts the
> zoom level to attempt to fit the larger desktop within the client
> monitor. Then we receive the monitors config update from the guest, and
> the window suddenly shrinks.
Probably virt_viewer_window_resize() should be called before the zoom changes
and also the height of the "top-menu" should be taken into account (desktop
height + top menu height > fullscreen height).

Pavel
> 
> So, the user was trying to return to 100% zoom, but the result was that
> the user is left with both a <100% zoom and a reduced guest resolution.
> That's pretty unexpected.
> 
> Jonathon
> 
> 
> On Wed, 2015-07-15 at 13:16 -0500, Jonathon Jongsma wrote:
> > 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
> > 
> > 
> > _______________________________________________
> > virt-tools-list mailing list
> > virt-tools-list at redhat.com
> > https://www.redhat.com/mailman/listinfo/virt-tools-list
> 
> 




More information about the virt-tools-list mailing list