From 12d72db5a8cd0241d8e73e4b827c46c6ea00da65 Mon Sep 17 00:00:00 2001 From: Gerd Hoffmann <kraxel@redhat.com> Date: Tue, 19 May 2009 10:25:02 +0200 Subject: [PATCH 06/14] vnc: fix multiple connections displaystate initialization Hi, Fixes bug 501263 and the screendump issues in autotest. cheers, Gerd >From 2652ec6ca5c6916ed975519e2310a0039427054c Mon Sep 17 00:00:00 2001 From: Gerd Hoffmann <kraxel@redhat.com> Date: Tue, 19 May 2009 09:33:56 +0200 Subject: [PATCH] vnc: fix displaystate initialization. The multiple vnc connections patch moved the displaystate initialization from the server initialization to the first vnc client connect. That had two unwanted side effects: (1) The first vnc client connecting gets a 0x0 screen advertised, instantly followed by a displayresize message for the actual screen size. Looks like some clients don't like that ... (2) There are users of the displaystate outside vnc (screendump monitor command for example) which will see a 0x0 displaystate in case no vnc client ever connected and get upset about that. This patch moves the displaystate setup from vnc_display_connect() back to the vnc_display_open() function. vnc_display_connect() handles only the setup of the new vnc client now. Message-ID: <4A126CDE.2040403@redhat.com> Signed-off-by: Eduardo Habkost <ehabkost@redhat.com> RH-Upstream-status: not-applicable Acked-by: Markus Armbruster <armbru@redhat.com> Acked-by: "Daniel P. Berrange" <berrange@redhat.com> Acked-by: john cooper <john.cooper@redhat.com> Depends: <49E74E46.1060107@redhat.com> Bugzilla: 503793 --- qemu/vnc.c | 31 +++++++++++++++++-------------- 1 files changed, 17 insertions(+), 14 deletions(-) diff --git a/qemu/vnc.c b/qemu/vnc.c index eca5d4d..31413f1 100644 --- a/qemu/vnc.c +++ b/qemu/vnc.c @@ -325,6 +325,7 @@ static void vnc_resize(VncState *vs, int w, int h) } if (vs->width != w || vs->height != h) { + VNC_DEBUG("%s/%d: %dx%d\n", __FUNCTION__, vs->csock, w, h); vs->width = w; vs->height = h; if (vs->csock != -1 && vs->has_resize) { @@ -345,6 +346,7 @@ static void vnc_dpy_resize(DisplayState *ds, int w, int h) VncDisplay *vd = ds->opaque; VncState *vs = vd->clients; + VNC_DEBUG("%s: %dx%d\n", __FUNCTION__, w, h); ds->width = w; ds->height = h; ds->linesize = w * ds->depth/8; @@ -1682,6 +1684,8 @@ static int protocol_client_init(VncState *vs, uint8_t *data, size_t len) char buf[1024]; int size; + VNC_DEBUG("%s/%d: %dx%d\n", __FUNCTION__, vs->csock, + vs->ds->width, vs->ds->height); vs->width = ds_get_width(vs->ds); vs->height = ds_get_height(vs->ds); vnc_write_u16(vs, ds_get_width(vs->ds)); @@ -2347,21 +2351,9 @@ static void vnc_connect(VncDisplay *vd, int csock) vs->ds = vd->ds; vs->ds->idle = 0; - if (vs->ds->depth != 32) { - /* - * We allways run with 32bpp internally. - * Easiest to handle with multiple clients, and - * this is what almost everybody uses anyway. - */ - vs->ds->depth = 32; - console_color_init(vs->ds); - } + vnc_colordepth(vs, vs->ds->depth); - if (vs->ds->width && vs->ds->height) { - vnc_resize(vs, vs->ds->width, vs->ds->height); - } else { - vnc_resize(vs, 640, 480); - } + vnc_resize(vs, vs->ds->width, vs->ds->height); vnc_write(vs, "RFB 003.008\n", 12); vnc_flush(vs); @@ -2423,6 +2415,17 @@ void vnc_display_init(DisplayState *ds) vs->ds->dpy_update = vnc_dpy_update; vs->ds->dpy_resize = vnc_dpy_resize; + if (vs->ds->depth != 32) { + /* + * We allways run with 32bpp internally. + * Easiest to handle with multiple clients, and + * this is what almost everybody uses anyway. + */ + vs->ds->depth = 32; + console_color_init(vs->ds); + } + vnc_dpy_resize(vs->ds, 640, 480); + if (!gcry_check_version (GCRYPT_VERSION)) { fprintf(stderr, "libgcrypt initialization error\n"); exit(1); -- 1.6.3.rc4.29.g8146