From a528b80cb09977806129249ea604aaef3830f3ec Mon Sep 17 00:00:00 2001 From: balrog Date: Tue, 30 Oct 2007 22:38:53 +0000 Subject: Miscellaneous VNC related fixes from Xen forwarded by Matthew Kent. git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3489 c046a42c-6fe2-441c-8c8c-71466251a162 --- vnc.c | 35 +++++++++++++++++++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-) (limited to 'vnc.c') diff --git a/vnc.c b/vnc.c index 72c8d1cceb..83d001161e 100644 --- a/vnc.c +++ b/vnc.c @@ -284,7 +284,10 @@ static void vnc_dpy_resize(DisplayState *ds, int w, int h) exit(1); } - ds->depth = vs->depth * 8; + if (ds->depth != vs->depth * 8) { + ds->depth = vs->depth * 8; + console_color_init(ds); + } size_changed = ds->width != w || ds->height != h; ds->width = w; ds->height = h; @@ -907,6 +910,12 @@ static void reset_keys(VncState *vs) } } +static void press_key(VncState *vs, int keysym) +{ + kbd_put_keycode(keysym2scancode(vs->kbd_layout, keysym) & 0x7f); + kbd_put_keycode(keysym2scancode(vs->kbd_layout, keysym) | 0x80); +} + static void do_key_event(VncState *vs, int down, uint32_t sym) { int keycode; @@ -934,6 +943,28 @@ static void do_key_event(VncState *vs, int down, uint32_t sym) return; } break; + case 0x45: /* NumLock */ + if (!down) + vs->modifiers_state[keycode] ^= 1; + break; + } + + if (keycode_is_keypad(vs->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 (keysym_is_numlock(vs->kbd_layout, sym & 0xFFFF)) { + if (!vs->modifiers_state[0x45]) { + vs->modifiers_state[0x45] = 1; + press_key(vs, 0xff7f); + } + } else { + if (vs->modifiers_state[0x45]) { + vs->modifiers_state[0x45] = 0; + press_key(vs, 0xff7f); + } + } } if (is_graphic_console()) { @@ -991,7 +1022,7 @@ static void do_key_event(VncState *vs, int down, uint32_t sym) static void key_event(VncState *vs, int down, uint32_t sym) { - if (sym >= 'A' && sym <= 'Z') + if (sym >= 'A' && sym <= 'Z' && is_graphic_console()) sym = sym - 'A' + 'a'; do_key_event(vs, down, sym); } -- cgit v1.2.3-55-g7522