vnc.c (b44486dfb9447c88e4b216e730adcc780190852c) | vnc.c (a54f0d2ba3094ca43e85a465c7c4ae58c589efc4) |
---|---|
1/* 2 * QEMU VNC display driver 3 * 4 * Copyright (C) 2006 Anthony Liguori <anthony@codemonkey.ws> 5 * Copyright (C) 2006 Fabrice Bellard 6 * Copyright (C) 2009 Red Hat, Inc 7 * 8 * Permission is hereby granted, free of charge, to any person obtaining a copy --- 1217 unchanged lines hidden (view full) --- 1226 qemu_remove_mouse_mode_change_notifier(&vs->mouse_mode_notifier); 1227 } 1228 QTAILQ_REMOVE(&vs->vd->clients, vs, next); 1229 if (QTAILQ_EMPTY(&vs->vd->clients)) { 1230 /* last client gone */ 1231 vnc_update_server_surface(vs->vd); 1232 } 1233 | 1/* 2 * QEMU VNC display driver 3 * 4 * Copyright (C) 2006 Anthony Liguori <anthony@codemonkey.ws> 5 * Copyright (C) 2006 Fabrice Bellard 6 * Copyright (C) 2009 Red Hat, Inc 7 * 8 * Permission is hereby granted, free of charge, to any person obtaining a copy --- 1217 unchanged lines hidden (view full) --- 1226 qemu_remove_mouse_mode_change_notifier(&vs->mouse_mode_notifier); 1227 } 1228 QTAILQ_REMOVE(&vs->vd->clients, vs, next); 1229 if (QTAILQ_EMPTY(&vs->vd->clients)) { 1230 /* last client gone */ 1231 vnc_update_server_surface(vs->vd); 1232 } 1233 |
1234 if (vs->vd->lock_key_sync) 1235 qemu_remove_led_event_handler(vs->led); | |
1236 vnc_unlock_output(vs); 1237 1238 qemu_mutex_destroy(&vs->output_mutex); 1239 if (vs->bh != NULL) { 1240 qemu_bh_delete(vs->bh); 1241 } 1242 buffer_free(&vs->jobs_buffer); 1243 --- 416 unchanged lines hidden (view full) --- 1660{ 1661 int keycode = keysym2scancode(vs->vd->kbd_layout, keysym) & SCANCODE_KEYMASK; 1662 qemu_input_event_send_key_number(vs->vd->dcl.con, keycode, true); 1663 qemu_input_event_send_key_delay(vs->vd->key_delay_ms); 1664 qemu_input_event_send_key_number(vs->vd->dcl.con, keycode, false); 1665 qemu_input_event_send_key_delay(vs->vd->key_delay_ms); 1666} 1667 | 1234 vnc_unlock_output(vs); 1235 1236 qemu_mutex_destroy(&vs->output_mutex); 1237 if (vs->bh != NULL) { 1238 qemu_bh_delete(vs->bh); 1239 } 1240 buffer_free(&vs->jobs_buffer); 1241 --- 416 unchanged lines hidden (view full) --- 1658{ 1659 int keycode = keysym2scancode(vs->vd->kbd_layout, keysym) & SCANCODE_KEYMASK; 1660 qemu_input_event_send_key_number(vs->vd->dcl.con, keycode, true); 1661 qemu_input_event_send_key_delay(vs->vd->key_delay_ms); 1662 qemu_input_event_send_key_number(vs->vd->dcl.con, keycode, false); 1663 qemu_input_event_send_key_delay(vs->vd->key_delay_ms); 1664} 1665 |
1668static int current_led_state(VncState *vs) 1669{ 1670 int ledstate = 0; 1671 1672 if (vs->modifiers_state[0x46]) { 1673 ledstate |= QEMU_SCROLL_LOCK_LED; 1674 } 1675 if (vs->modifiers_state[0x45]) { 1676 ledstate |= QEMU_NUM_LOCK_LED; 1677 } 1678 if (vs->modifiers_state[0x3a]) { 1679 ledstate |= QEMU_CAPS_LOCK_LED; 1680 } 1681 1682 return ledstate; 1683} 1684 | |
1685static void vnc_led_state_change(VncState *vs) 1686{ | 1666static void vnc_led_state_change(VncState *vs) 1667{ |
1687 int ledstate = 0; 1688 | |
1689 if (!vnc_has_feature(vs, VNC_FEATURE_LED_STATE)) { 1690 return; 1691 } 1692 | 1668 if (!vnc_has_feature(vs, VNC_FEATURE_LED_STATE)) { 1669 return; 1670 } 1671 |
1693 ledstate = current_led_state(vs); | |
1694 vnc_lock_output(vs); 1695 vnc_write_u8(vs, VNC_MSG_SERVER_FRAMEBUFFER_UPDATE); 1696 vnc_write_u8(vs, 0); 1697 vnc_write_u16(vs, 1); 1698 vnc_framebuffer_update(vs, 0, 0, 1, 1, VNC_ENCODING_LED_STATE); | 1672 vnc_lock_output(vs); 1673 vnc_write_u8(vs, VNC_MSG_SERVER_FRAMEBUFFER_UPDATE); 1674 vnc_write_u8(vs, 0); 1675 vnc_write_u16(vs, 1); 1676 vnc_framebuffer_update(vs, 0, 0, 1, 1, VNC_ENCODING_LED_STATE); |
1699 vnc_write_u8(vs, ledstate); | 1677 vnc_write_u8(vs, vs->vd->ledstate); |
1700 vnc_unlock_output(vs); 1701 vnc_flush(vs); 1702} 1703 1704static void kbd_leds(void *opaque, int ledstate) 1705{ | 1678 vnc_unlock_output(vs); 1679 vnc_flush(vs); 1680} 1681 1682static void kbd_leds(void *opaque, int ledstate) 1683{ |
1706 VncState *vs = opaque; 1707 int caps, num, scr; 1708 bool has_changed = (ledstate != current_led_state(vs)); | 1684 VncDisplay *vd = opaque; 1685 VncState *client; |
1709 1710 trace_vnc_key_guest_leds((ledstate & QEMU_CAPS_LOCK_LED), 1711 (ledstate & QEMU_NUM_LOCK_LED), 1712 (ledstate & QEMU_SCROLL_LOCK_LED)); 1713 | 1686 1687 trace_vnc_key_guest_leds((ledstate & QEMU_CAPS_LOCK_LED), 1688 (ledstate & QEMU_NUM_LOCK_LED), 1689 (ledstate & QEMU_SCROLL_LOCK_LED)); 1690 |
1714 caps = ledstate & QEMU_CAPS_LOCK_LED ? 1 : 0; 1715 num = ledstate & QEMU_NUM_LOCK_LED ? 1 : 0; 1716 scr = ledstate & QEMU_SCROLL_LOCK_LED ? 1 : 0; 1717 1718 if (vs->modifiers_state[0x3a] != caps) { 1719 vs->modifiers_state[0x3a] = caps; | 1691 if (ledstate == vd->ledstate) { 1692 return; |
1720 } | 1693 } |
1721 if (vs->modifiers_state[0x45] != num) { 1722 vs->modifiers_state[0x45] = num; 1723 } 1724 if (vs->modifiers_state[0x46] != scr) { 1725 vs->modifiers_state[0x46] = scr; 1726 } | |
1727 | 1694 |
1728 /* Sending the current led state message to the client */ 1729 if (has_changed) { 1730 vnc_led_state_change(vs); | 1695 vd->ledstate = ledstate; 1696 1697 QTAILQ_FOREACH(client, &vd->clients, next) { 1698 vnc_led_state_change(client); |
1731 } 1732} 1733 1734static void do_key_event(VncState *vs, int down, int keycode, int sym) 1735{ 1736 /* QEMU console switch */ 1737 switch(keycode) { 1738 case 0x2a: /* Left Shift */ --- 1343 unchanged lines hidden (view full) --- 3082 } 3083} 3084 3085void vnc_start_protocol(VncState *vs) 3086{ 3087 vnc_write(vs, "RFB 003.008\n", 12); 3088 vnc_flush(vs); 3089 vnc_read_when(vs, protocol_version, 12); | 1699 } 1700} 1701 1702static void do_key_event(VncState *vs, int down, int keycode, int sym) 1703{ 1704 /* QEMU console switch */ 1705 switch(keycode) { 1706 case 0x2a: /* Left Shift */ --- 1343 unchanged lines hidden (view full) --- 3050 } 3051} 3052 3053void vnc_start_protocol(VncState *vs) 3054{ 3055 vnc_write(vs, "RFB 003.008\n", 12); 3056 vnc_flush(vs); 3057 vnc_read_when(vs, protocol_version, 12); |
3090 if (vs->vd->lock_key_sync) 3091 vs->led = qemu_add_led_event_handler(kbd_leds, vs); | |
3092 3093 vs->mouse_mode_notifier.notify = check_pointer_type_change; 3094 qemu_add_mouse_mode_change_notifier(&vs->mouse_mode_notifier); 3095} 3096 3097static gboolean vnc_listen_io(QIOChannel *ioc, 3098 GIOCondition condition, 3099 void *opaque) --- 90 unchanged lines hidden (view full) --- 3190 vd->auth = VNC_AUTH_INVALID; 3191 vd->subauth = VNC_AUTH_INVALID; 3192 if (vd->tlscreds) { 3193 object_unparent(OBJECT(vd->tlscreds)); 3194 vd->tlscreds = NULL; 3195 } 3196 g_free(vd->tlsaclname); 3197 vd->tlsaclname = NULL; | 3058 3059 vs->mouse_mode_notifier.notify = check_pointer_type_change; 3060 qemu_add_mouse_mode_change_notifier(&vs->mouse_mode_notifier); 3061} 3062 3063static gboolean vnc_listen_io(QIOChannel *ioc, 3064 GIOCondition condition, 3065 void *opaque) --- 90 unchanged lines hidden (view full) --- 3156 vd->auth = VNC_AUTH_INVALID; 3157 vd->subauth = VNC_AUTH_INVALID; 3158 if (vd->tlscreds) { 3159 object_unparent(OBJECT(vd->tlscreds)); 3160 vd->tlscreds = NULL; 3161 } 3162 g_free(vd->tlsaclname); 3163 vd->tlsaclname = NULL; |
3164 if (vd->lock_key_sync) { 3165 qemu_remove_led_event_handler(vd->led); 3166 } |
|
3198} 3199 3200int vnc_display_password(const char *id, const char *password) 3201{ 3202 VncDisplay *vd = vnc_display_find(id); 3203 3204 if (!vd) { 3205 return -EINVAL; --- 551 unchanged lines hidden (view full) --- 3757#ifdef CONFIG_VNC_SASL 3758 if ((saslErr = sasl_server_init(NULL, "qemu")) != SASL_OK) { 3759 error_setg(errp, "Failed to initialize SASL auth: %s", 3760 sasl_errstring(saslErr, NULL, NULL)); 3761 goto fail; 3762 } 3763#endif 3764 vd->lock_key_sync = lock_key_sync; | 3167} 3168 3169int vnc_display_password(const char *id, const char *password) 3170{ 3171 VncDisplay *vd = vnc_display_find(id); 3172 3173 if (!vd) { 3174 return -EINVAL; --- 551 unchanged lines hidden (view full) --- 3726#ifdef CONFIG_VNC_SASL 3727 if ((saslErr = sasl_server_init(NULL, "qemu")) != SASL_OK) { 3728 error_setg(errp, "Failed to initialize SASL auth: %s", 3729 sasl_errstring(saslErr, NULL, NULL)); 3730 goto fail; 3731 } 3732#endif 3733 vd->lock_key_sync = lock_key_sync; |
3734 if (lock_key_sync) { 3735 vd->led = qemu_add_led_event_handler(kbd_leds, vd); 3736 } 3737 vd->ledstate = 0; |
|
3765 vd->key_delay_ms = key_delay_ms; 3766 3767 device_id = qemu_opt_get(opts, "display"); 3768 if (device_id) { 3769 int head = qemu_opt_get_number(opts, "head", 0); 3770 Error *err = NULL; 3771 3772 con = qemu_console_lookup_by_device_name(device_id, head, &err); --- 142 unchanged lines hidden --- | 3738 vd->key_delay_ms = key_delay_ms; 3739 3740 device_id = qemu_opt_get(opts, "display"); 3741 if (device_id) { 3742 int head = qemu_opt_get_number(opts, "head", 0); 3743 Error *err = NULL; 3744 3745 con = qemu_console_lookup_by_device_name(device_id, head, &err); --- 142 unchanged lines hidden --- |