Signed-off-by: Gerd Hoffmann <kra...@redhat.com>
---
 ui/vnc.c | 16 +++++++++++++---
 1 file changed, 13 insertions(+), 3 deletions(-)

diff --git a/ui/vnc.c b/ui/vnc.c
index cb1954c..283b93c 100644
--- a/ui/vnc.c
+++ b/ui/vnc.c
@@ -605,6 +605,17 @@ static void framebuffer_update_request(VncState *vs, int 
incremental,
 static void vnc_refresh(DisplayChangeListener *dcl);
 static int vnc_refresh_server_surface(VncDisplay *vd);
 
+static int vnc_width(VncDisplay *vd)
+{
+    return MIN(VNC_MAX_WIDTH, ROUND_UP(surface_width(vd->ds),
+                                       VNC_DIRTY_PIXELS_PER_BIT));
+}
+
+static int vnc_height(VncDisplay *vd)
+{
+    return MIN(VNC_MAX_HEIGHT, surface_height(vd->ds));
+}
+
 static void vnc_set_area_dirty(DECLARE_BITMAP(dirty[VNC_MAX_HEIGHT],
                                VNC_MAX_WIDTH / VNC_DIRTY_PIXELS_PER_BIT),
                                int width, int height,
@@ -715,9 +726,8 @@ static void vnc_dpy_switch(DisplayChangeListener *dcl,
     /* server surface */
     qemu_pixman_image_unref(vd->server);
     vd->ds = surface;
-    width = MIN(VNC_MAX_WIDTH, ROUND_UP(surface_width(vd->ds),
-                                        VNC_DIRTY_PIXELS_PER_BIT));
-    height = MIN(VNC_MAX_HEIGHT, surface_height(vd->ds));
+    width = vnc_width(vd);
+    height = vnc_height(vd);
     vd->server = pixman_image_create_bits(VNC_SERVER_FB_FORMAT,
                                           width, height, NULL, 0);
 
-- 
1.8.3.1


Reply via email to