Skip to contentSkip to conversation

VNC: send NewDesktopSize only when needed

PATCH New Eduardo Felipe 1 participant 1 message Dec 10, 2006

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 VNC: send NewDesktopSize only when needed

Hi,

Patch below makes VNC server send NewDesktopSize message only when necessary.

Without it UltraVNC client goes crazy, as it sends a SetPixelFormat message each time it receives a resize, which makes qemu VNC server trigger a new (unnecessary) resize, and so on...

Regards,

Index: vnc.c
===================================================================
RCS file: /sources/qemu/qemu/vnc.c,v
retrieving revision 1.8

vnc.c +0 -0
diff -u -r1.8 vnc.c
@@ -167,6 +167,7 @@
 

static void vnc_dpy_resize(DisplayState *ds, int w, int h) {

+    int size_changed;
    VncState *vs = ds->opaque;

    ds->data = realloc(ds->data, w * h * vs->depth);
@@ -178,10 +179,11 @@
    }

    ds->depth = vs->depth * 8;
+    size_changed = ds->width != w || ds->height != h;
    ds->width = w;
    ds->height = h;
    ds->linesize = w * vs->depth;
-    if (vs->csock != -1 && vs->has_resize) {
+    if (vs->csock != -1 && vs->has_resize && size_changed) {
	vnc_write_u8(vs, 0);  /* msg id */
	vnc_write_u8(vs, 0);
	vnc_write_u16(vs, 1); /* number of rects */