vnc_colordepth(vs);
if (size_changed) {
if (vs->csock != -1 && vnc_has_feature(vs, VNC_FEATURE_RESIZE)) {
- vnc_write_u8(vs, 0); /* msg id */
+ vnc_write_u8(vs, VNC_MSG_SERVER_FRAMEBUFFER_UPDATE);
vnc_write_u8(vs, 0);
vnc_write_u16(vs, 1); /* number of rects */
vnc_framebuffer_update(vs, 0, 0, ds_get_width(ds), ds_get_height(ds),
static void vnc_copy(VncState *vs, int src_x, int src_y, int dst_x, int dst_y, int w, int h)
{
/* send bitblit op to the vnc client */
- vnc_write_u8(vs, 0); /* msg id */
+ vnc_write_u8(vs, VNC_MSG_SERVER_FRAMEBUFFER_UPDATE);
vnc_write_u8(vs, 0);
vnc_write_u16(vs, 1); /* number of rects */
vnc_framebuffer_update(vs, dst_x, dst_y, w, h, VNC_ENCODING_COPYRECT);
* send them to the client.
*/
n_rectangles = 0;
- vnc_write_u8(vs, 0); /* msg id */
+ vnc_write_u8(vs, VNC_MSG_SERVER_FRAMEBUFFER_UPDATE);
vnc_write_u8(vs, 0);
saved_offset = vs->output.offset;
vnc_write_u16(vs, 0);
switch (cmd) {
case AUD_CNOTIFY_DISABLE:
- vnc_write_u8(vs, 255);
- vnc_write_u8(vs, 1);
- vnc_write_u16(vs, 0);
+ vnc_write_u8(vs, VNC_MSG_SERVER_QEMU);
+ vnc_write_u8(vs, VNC_MSG_SERVER_QEMU_AUDIO);
+ vnc_write_u16(vs, VNC_MSG_SERVER_QEMU_AUDIO_END);
vnc_flush(vs);
break;
case AUD_CNOTIFY_ENABLE:
- vnc_write_u8(vs, 255);
- vnc_write_u8(vs, 1);
- vnc_write_u16(vs, 1);
+ vnc_write_u8(vs, VNC_MSG_SERVER_QEMU);
+ vnc_write_u8(vs, VNC_MSG_SERVER_QEMU_AUDIO);
+ vnc_write_u16(vs, VNC_MSG_SERVER_QEMU_AUDIO_BEGIN);
vnc_flush(vs);
break;
}
{
VncState *vs = opaque;
- vnc_write_u8(vs, 255);
- vnc_write_u8(vs, 1);
- vnc_write_u16(vs, 2);
+ vnc_write_u8(vs, VNC_MSG_SERVER_QEMU);
+ vnc_write_u8(vs, VNC_MSG_SERVER_QEMU_AUDIO);
+ vnc_write_u16(vs, VNC_MSG_SERVER_QEMU_AUDIO_DATA);
vnc_write_u32(vs, size);
vnc_write(vs, buf, size);
vnc_flush(vs);
static void audio_add(VncState *vs)
{
- Monitor *mon = cur_mon;
struct audio_capture_ops ops;
if (vs->audio_cap) {
- monitor_printf(mon, "audio already running\n");
+ monitor_printf(default_mon, "audio already running\n");
return;
}
vs->audio_cap = AUD_add_capture(&vs->as, &ops, vs);
if (!vs->audio_cap) {
- monitor_printf(mon, "Failed to add audio capture\n");
+ monitor_printf(default_mon, "Failed to add audio capture\n");
}
}
dcl->idle = 1;
}
+ qemu_remove_mouse_mode_change_notifier(&vs->mouse_mode_notifier);
vnc_remove_timer(vs->vd);
- qemu_remove_led_event_handler(vs->led);
+ if (vs->vd->lock_key_sync)
+ qemu_remove_led_event_handler(vs->led);
qemu_free(vs);
}
*/
void vnc_client_write(void *opaque)
{
- long ret;
VncState *vs = opaque;
#ifdef CONFIG_VNC_SASL
if (vs->sasl.conn &&
vs->sasl.runSSF &&
- !vs->sasl.waitWriteSSF)
- ret = vnc_client_write_sasl(vs);
- else
+ !vs->sasl.waitWriteSSF) {
+ vnc_client_write_sasl(vs);
+ } else
#endif /* CONFIG_VNC_SASL */
- ret = vnc_client_write_plain(vs);
+ vnc_client_write_plain(vs);
}
void vnc_read_when(VncState *vs, VncReadEvent *func, size_t expecting)
{
}
-static void check_pointer_type_change(VncState *vs, int absolute)
+static void check_pointer_type_change(Notifier *notifier)
{
+ VncState *vs = container_of(notifier, VncState, mouse_mode_notifier);
+ int absolute = kbd_mouse_is_absolute();
+
if (vnc_has_feature(vs, VNC_FEATURE_POINTER_TYPE_CHANGE) && vs->absolute != absolute) {
- vnc_write_u8(vs, 0);
+ vnc_write_u8(vs, VNC_MSG_SERVER_FRAMEBUFFER_UPDATE);
vnc_write_u8(vs, 0);
vnc_write_u16(vs, 1);
vnc_framebuffer_update(vs, absolute, 0,
dz = 1;
if (vs->absolute) {
- kbd_mouse_event(x * 0x7FFF / (ds_get_width(vs->ds) - 1),
- y * 0x7FFF / (ds_get_height(vs->ds) - 1),
+ kbd_mouse_event(ds_get_width(vs->ds) > 1 ?
+ x * 0x7FFF / (ds_get_width(vs->ds) - 1) : 0x4000,
+ ds_get_height(vs->ds) > 1 ?
+ y * 0x7FFF / (ds_get_height(vs->ds) - 1) : 0x4000,
dz, buttons);
} else if (vnc_has_feature(vs, VNC_FEATURE_POINTER_TYPE_CHANGE)) {
x -= 0x7FFF;
vs->last_x = x;
vs->last_y = y;
}
-
- check_pointer_type_change(vs, kbd_mouse_is_absolute());
}
static void reset_keys(VncState *vs)
break;
}
- if (keycode_is_keypad(vs->vd->kbd_layout, keycode)) {
+ if (vs->vd->lock_key_sync &&
+ keycode_is_keypad(vs->vd->kbd_layout, keycode)) {
/* If the numlock state needs to change then simulate an additional
keypress before sending this one. This will happen if the user
toggles numlock away from the VNC window.
}
}
- if ((sym >= 'A' && sym <= 'Z') || (sym >= 'a' && sym <= 'z')) {
+ if (vs->vd->lock_key_sync &&
+ ((sym >= 'A' && sym <= 'Z') || (sym >= 'a' && sym <= 'z'))) {
/* If the capslock state needs to change then simulate an additional
keypress before sending this one. This will happen if the user
toggles capslock away from the VNC window.
int x_position, int y_position,
int w, int h)
{
- if (x_position > ds_get_width(vs->ds))
- x_position = ds_get_width(vs->ds);
if (y_position > ds_get_height(vs->ds))
y_position = ds_get_height(vs->ds);
- if (x_position + w >= ds_get_width(vs->ds))
- w = ds_get_width(vs->ds) - x_position;
if (y_position + h >= ds_get_height(vs->ds))
h = ds_get_height(vs->ds) - y_position;
static void send_ext_key_event_ack(VncState *vs)
{
- vnc_write_u8(vs, 0);
+ vnc_write_u8(vs, VNC_MSG_SERVER_FRAMEBUFFER_UPDATE);
vnc_write_u8(vs, 0);
vnc_write_u16(vs, 1);
vnc_framebuffer_update(vs, 0, 0, ds_get_width(vs->ds), ds_get_height(vs->ds),
static void send_ext_audio_ack(VncState *vs)
{
- vnc_write_u8(vs, 0);
+ vnc_write_u8(vs, VNC_MSG_SERVER_FRAMEBUFFER_UPDATE);
vnc_write_u8(vs, 0);
vnc_write_u16(vs, 1);
vnc_framebuffer_update(vs, 0, 0, ds_get_width(vs->ds), ds_get_height(vs->ds),
break;
}
}
-
- check_pointer_type_change(vs, kbd_mouse_is_absolute());
}
static void set_pixel_conversion(VncState *vs)
{
if (vnc_has_feature(vs, VNC_FEATURE_WMVI)) {
/* Sending a WMVi message to notify the client*/
- vnc_write_u8(vs, 0); /* msg id */
+ vnc_write_u8(vs, VNC_MSG_SERVER_FRAMEBUFFER_UPDATE);
vnc_write_u8(vs, 0);
vnc_write_u16(vs, 1); /* number of rects */
vnc_framebuffer_update(vs, 0, 0, ds_get_width(vs->ds),
}
switch (data[0]) {
- case 0:
+ case VNC_MSG_CLIENT_SET_PIXEL_FORMAT:
if (len == 1)
return 20;
read_u16(data, 12), read_u8(data, 14),
read_u8(data, 15), read_u8(data, 16));
break;
- case 2:
+ case VNC_MSG_CLIENT_SET_ENCODINGS:
if (len == 1)
return 4;
set_encodings(vs, (int32_t *)(data + 4), limit);
break;
- case 3:
+ case VNC_MSG_CLIENT_FRAMEBUFFER_UPDATE_REQUEST:
if (len == 1)
return 10;
read_u8(data, 1), read_u16(data, 2), read_u16(data, 4),
read_u16(data, 6), read_u16(data, 8));
break;
- case 4:
+ case VNC_MSG_CLIENT_KEY_EVENT:
if (len == 1)
return 8;
key_event(vs, read_u8(data, 1), read_u32(data, 4));
break;
- case 5:
+ case VNC_MSG_CLIENT_POINTER_EVENT:
if (len == 1)
return 6;
pointer_event(vs, read_u8(data, 1), read_u16(data, 2), read_u16(data, 4));
break;
- case 6:
+ case VNC_MSG_CLIENT_CUT_TEXT:
if (len == 1)
return 8;
client_cut_text(vs, read_u32(data, 4), data + 8);
break;
- case 255:
+ case VNC_MSG_CLIENT_QEMU:
if (len == 1)
return 2;
switch (read_u8(data, 1)) {
- case 0:
+ case VNC_MSG_CLIENT_QEMU_EXT_KEY_EVENT:
if (len == 2)
return 12;
ext_key_event(vs, read_u16(data, 2),
read_u32(data, 4), read_u32(data, 8));
break;
- case 1:
+ case VNC_MSG_CLIENT_QEMU_AUDIO:
if (len == 2)
return 4;
switch (read_u16 (data, 2)) {
- case 0:
+ case VNC_MSG_CLIENT_QEMU_AUDIO_ENABLE:
audio_add(vs);
break;
- case 1:
+ case VNC_MSG_CLIENT_QEMU_AUDIO_DISABLE:
audio_del(vs);
break;
- case 2:
+ case VNC_MSG_CLIENT_QEMU_AUDIO_SET_FORMAT:
if (len == 4)
return 10;
switch (read_u8(data, 4)) {
vnc_flush(vs);
vnc_read_when(vs, protocol_version, 12);
reset_keys(vs);
- vs->led = qemu_add_led_event_handler(kbd_leds, vs);
+ if (vs->vd->lock_key_sync)
+ vs->led = qemu_add_led_event_handler(kbd_leds, vs);
+
+ vs->mouse_mode_notifier.notify = check_pointer_type_change;
+ qemu_add_mouse_mode_change_notifier(&vs->mouse_mode_notifier);
vnc_init_timer(vd);
int saslErr;
#endif
int acl = 0;
+ int lock_key_sync = 1;
if (!vnc_display)
return -1;
password = 1; /* Require password auth */
} else if (strncmp(options, "reverse", 7) == 0) {
reverse = 1;
+ } else if (strncmp(options, "no-lock-key-sync", 9) == 0) {
+ lock_key_sync = 0;
#ifdef CONFIG_VNC_SASL
} else if (strncmp(options, "sasl", 4) == 0) {
sasl = 1; /* Require SASL auth */
return -1;
}
#endif
+ vs->lock_key_sync = lock_key_sync;
if (reverse) {
/* connect to viewer */