[virt-tools-list] [PATCH virt-viewer 1/2] virt-viewer-window: Make sure that minimum zoom level is lower than NORMAL_ZOOM_LEVEL

Jonathon Jongsma jjongsma at redhat.com
Tue Apr 21 20:32:08 UTC 2015


On Tue, 2015-04-21 at 20:48 +0200, Pavel Grunt wrote:
> The minimum size of the desktop is 100x100 if the minimum window size
> is greater than this, the zoom level is greater than NORMAL_ZOOM_LEVEL
> 
> related: rhbz#1206460
> ---
>  src/virt-viewer-window.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/src/virt-viewer-window.c b/src/virt-viewer-window.c
> index 18ae1bc..3820159 100644
> --- a/src/virt-viewer-window.c
> +++ b/src/virt-viewer-window.c
> @@ -1536,7 +1536,8 @@ virt_viewer_window_get_minimal_zoom_level(VirtViewerWindow *self)
>      height_ratio = (double) min_height / height;
>      zoom = ceil(10 * MAX(width_ratio, height_ratio));
>  
> -    return MAX(MIN_ZOOM_LEVEL, zoom * ZOOM_STEP);
> +    /* make sure that the returned zoom level is in the range from MIN_ZOOM_LEVEL to NORMAL_ZOOM_LEVEL */
> +    return MIN(MAX(MIN_ZOOM_LEVEL, zoom * ZOOM_STEP), NORMAL_ZOOM_LEVEL);
>  }
>  
>  /*


ACK to both. You could use the glib CLAMP() macro instead of MIN(MAX()),
if you'd like.




More information about the virt-tools-list mailing list