xen/ioemu-vnc-resize.patch

64 lines
2.1 KiB
Diff
Raw Normal View History

Index: xen-3.3.1-testing/tools/ioemu-remote/vnc.c
===================================================================
--- xen-3.3.1-testing.orig/tools/ioemu-remote/vnc.c
+++ xen-3.3.1-testing/tools/ioemu-remote/vnc.c
@@ -352,6 +352,11 @@ static void vnc_dpy_update(DisplayState
{
VncState *vs = ds->opaque;
+ x = MIN(x, vs->width);
+ y = MIN(y, vs->height);
+ w = MIN(w, vs->width - x);
+ h = MIN(h, vs->height - y);
+
set_bits_in_row(vs, vs->dirty_row, x, y, w, h);
}
@@ -419,9 +424,13 @@ static void vnc_dpy_resize_shared(Displa
size_changed = ds->width != w || ds->height != h;
ds->width = w;
ds->height = h;
- if (vs->csock != -1 && vs->has_resize && size_changed) {
+ if (size_changed) {
vs->width = ds->width;
vs->height = ds->height;
+ VNC_DEBUG("vs->width = %d, vs->height = %d\n",
+ ds->width, ds->height);
+ }
+ if (vs->csock != -1 && vs->has_resize && size_changed) {
if (vs->update_requested) {
vnc_write_u8(vs, 0); /* msg id */
vnc_write_u8(vs, 0);
@@ -1808,6 +1817,31 @@ static int protocol_client_msg(VncState
}
set_encodings(vs, (int32_t *)(data + 4), limit);
+
+ /*
+ * The initialization of a VNC connection can race with xenfb changing
+ * the resolution. This happens when the VNC connection is already
+ * established, but the client has not yet advertised has_resize, so it
+ * won't get notified of the switch.
+ *
+ * Therefore we resend the resolution as soon as the client has sent its
+ * encodings.
+ */
+ if (vs->has_resize) {
+ /* Resize the VNC window */
+ vnc_write_u8(vs, 0); /* msg id */
+ vnc_write_u8(vs, 0);
+ vnc_write_u16(vs, 1); /* number of rects */
+ vnc_framebuffer_update(vs, 0, 0, vs->ds->width, vs->ds->height, -223);
+
+ /* Ensure that the new area is updated */
+ vnc_write_u8(vs, 0); /* msg id */
+ vnc_write_u8(vs, 0);
+ vnc_write_u16(vs, 1); /* number of rects */
+ send_framebuffer_update(vs, 0, 0, vs->ds->width, vs->ds->height);
+
+ vnc_flush(vs);
+ }
break;
case 3:
if (len == 1)