[virt-tools-list] [PATCH virt-viewer 1/4] virt-viewer-window: Change zoom with respect to real zoom

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


OK.

(by the way, didn't you submit a similar patch a while back? What ever
happened to that one? or is this the same one?)


On Tue, 2015-07-14 at 16:13 +0200, Pavel Grunt wrote:
> The zoom can be changed by resizing the window (VNC / Spice without
> the agent). It is necessary to recalculate the zoom level before
> changing it, otherwise zoom operations will not work correctly.
> 
> Resolves:
> https://bugs.freedesktop.org/show_bug.cgi?id=90582
> ---
>  src/virt-viewer-window.c | 20 +++++++++++++++++---
>  1 file changed, 17 insertions(+), 3 deletions(-)
> 
> diff --git a/src/virt-viewer-window.c b/src/virt-viewer-window.c
> index d67fbc1..71e6575 100644
> --- a/src/virt-viewer-window.c
> +++ b/src/virt-viewer-window.c
> @@ -368,19 +368,32 @@ virt_viewer_window_desktop_resize(VirtViewerDisplay *display G_GNUC_UNUSED,
>      virt_viewer_window_resize(self, FALSE);
>  }
>  
> +static gint
> +virt_viewer_window_get_real_zoom_level(VirtViewerWindow *self)
> +{
> +    GtkAllocation allocation;
> +    guint width, height;
> +
> +    gtk_widget_get_allocation(GTK_WIDGET(self->priv->display), &allocation);
> +    virt_viewer_display_get_desktop_size(self->priv->display, &width, &height);
> +
> +    return round((double) NORMAL_ZOOM_LEVEL * allocation.width / width);
> +}
>  
>  G_MODULE_EXPORT void
>  virt_viewer_window_menu_view_zoom_out(GtkWidget *menu G_GNUC_UNUSED,
>                                        VirtViewerWindow *self)
>  {
> -    virt_viewer_window_set_zoom_level(self, self->priv->zoomlevel - ZOOM_STEP);
> +    virt_viewer_window_set_zoom_level(self,
> +                                      virt_viewer_window_get_real_zoom_level(self) - ZOOM_STEP);
>  }
>  
>  G_MODULE_EXPORT void
>  virt_viewer_window_menu_view_zoom_in(GtkWidget *menu G_GNUC_UNUSED,
>                                       VirtViewerWindow *self)
>  {
> -    virt_viewer_window_set_zoom_level(self, self->priv->zoomlevel + ZOOM_STEP);
> +    virt_viewer_window_set_zoom_level(self,
> +                                      virt_viewer_window_get_real_zoom_level(self) + ZOOM_STEP);
>  }
>  
>  G_MODULE_EXPORT void
> @@ -1471,7 +1484,8 @@ virt_viewer_window_set_zoom_level(VirtViewerWindow *self, gint zoom_level)
>          priv->zoomlevel = min_zoom;
>      }
>  
> -    if (priv->zoomlevel == virt_viewer_display_get_zoom_level(priv->display)) {
> +    if (priv->zoomlevel == virt_viewer_display_get_zoom_level(priv->display) &&
> +        priv->zoomlevel == virt_viewer_window_get_real_zoom_level(self)) {
>          g_debug("Zoom level not changed, using: %d", priv->zoomlevel);
>          return;
>      }





More information about the virt-tools-list mailing list