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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




On Wed, Jun 11, 2014 at 2:38 PM, Marc-André Lureau <marcandre.lureau@xxxxxxxxx> wrote:
From: Marc-André Lureau <marcandre.lureau@xxxxxxxxxx>

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@xxxxxxxxxx
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




_______________________________________________
virt-tools-list mailing list
virt-tools-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/virt-tools-list





[Index of Archives]     [Linux Virtualization]     [KVM Development]     [CentOS Virtualization]     [Netdev]     [Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite Forum]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]     [Video 4 Linux]

  Powered by Linux