[virt-tools-list] [PATCH virt-viewer] window: take zoom-level into account for display limits
Marc-André Lureau
marcandre.lureau at gmail.com
Wed Jun 11 19:38:22 UTC 2014
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
More information about the virt-tools-list
mailing list