提交 3a0558b5 编写于 作者: G Gerd Hoffmann 提交者: Anthony Liguori

vnc: add no-lock-key-sync option

Add an option to disable the heuristics which try to keep
capslock and numlock state for guest and host in sync.
Signed-off-by: NGerd Hoffmann <kraxel@redhat.com>
Signed-off-by: NAnthony Liguori <aliguori@us.ibm.com>
上级 af821177
...@@ -1110,6 +1110,7 @@ static void vnc_disconnect_finish(VncState *vs) ...@@ -1110,6 +1110,7 @@ static void vnc_disconnect_finish(VncState *vs)
} }
vnc_remove_timer(vs->vd); vnc_remove_timer(vs->vd);
if (vs->vd->lock_key_sync)
qemu_remove_led_event_handler(vs->led); qemu_remove_led_event_handler(vs->led);
qemu_free(vs); qemu_free(vs);
} }
...@@ -1549,7 +1550,8 @@ static void do_key_event(VncState *vs, int down, int keycode, int sym) ...@@ -1549,7 +1550,8 @@ static void do_key_event(VncState *vs, int down, int keycode, int sym)
break; 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 /* If the numlock state needs to change then simulate an additional
keypress before sending this one. This will happen if the user keypress before sending this one. This will happen if the user
toggles numlock away from the VNC window. toggles numlock away from the VNC window.
...@@ -1567,7 +1569,8 @@ static void do_key_event(VncState *vs, int down, int keycode, int sym) ...@@ -1567,7 +1569,8 @@ static void do_key_event(VncState *vs, int down, int keycode, int sym)
} }
} }
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 /* If the capslock state needs to change then simulate an additional
keypress before sending this one. This will happen if the user keypress before sending this one. This will happen if the user
toggles capslock away from the VNC window. toggles capslock away from the VNC window.
...@@ -2430,6 +2433,7 @@ static void vnc_connect(VncDisplay *vd, int csock) ...@@ -2430,6 +2433,7 @@ static void vnc_connect(VncDisplay *vd, int csock)
vnc_flush(vs); vnc_flush(vs);
vnc_read_when(vs, protocol_version, 12); vnc_read_when(vs, protocol_version, 12);
reset_keys(vs); reset_keys(vs);
if (vs->vd->lock_key_sync)
vs->led = qemu_add_led_event_handler(kbd_leds, vs); vs->led = qemu_add_led_event_handler(kbd_leds, vs);
vnc_init_timer(vd); vnc_init_timer(vd);
...@@ -2551,6 +2555,7 @@ int vnc_display_open(DisplayState *ds, const char *display) ...@@ -2551,6 +2555,7 @@ int vnc_display_open(DisplayState *ds, const char *display)
int saslErr; int saslErr;
#endif #endif
int acl = 0; int acl = 0;
int lock_key_sync = 1;
if (!vnc_display) if (!vnc_display)
return -1; return -1;
...@@ -2568,6 +2573,8 @@ int vnc_display_open(DisplayState *ds, const char *display) ...@@ -2568,6 +2573,8 @@ int vnc_display_open(DisplayState *ds, const char *display)
password = 1; /* Require password auth */ password = 1; /* Require password auth */
} else if (strncmp(options, "reverse", 7) == 0) { } else if (strncmp(options, "reverse", 7) == 0) {
reverse = 1; reverse = 1;
} else if (strncmp(options, "no-lock-key-sync", 9) == 0) {
lock_key_sync = 0;
#ifdef CONFIG_VNC_SASL #ifdef CONFIG_VNC_SASL
} else if (strncmp(options, "sasl", 4) == 0) { } else if (strncmp(options, "sasl", 4) == 0) {
sasl = 1; /* Require SASL auth */ sasl = 1; /* Require SASL auth */
...@@ -2713,6 +2720,7 @@ int vnc_display_open(DisplayState *ds, const char *display) ...@@ -2713,6 +2720,7 @@ int vnc_display_open(DisplayState *ds, const char *display)
return -1; return -1;
} }
#endif #endif
vs->lock_key_sync = lock_key_sync;
if (reverse) { if (reverse) {
/* connect to viewer */ /* connect to viewer */
......
...@@ -99,6 +99,7 @@ struct VncDisplay ...@@ -99,6 +99,7 @@ struct VncDisplay
int lsock; int lsock;
DisplayState *ds; DisplayState *ds;
kbd_layout_t *kbd_layout; kbd_layout_t *kbd_layout;
int lock_key_sync;
struct VncSurface guest; /* guest visible surface (aka ds->surface) */ struct VncSurface guest; /* guest visible surface (aka ds->surface) */
DisplaySurface *server; /* vnc server surface */ DisplaySurface *server; /* vnc server surface */
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册