aboutsummaryrefslogtreecommitdiffstats
path: root/tools/ioemu/vnc.c
diff options
context:
space:
mode:
authorChristian Limpach <Christian.Limpach@xensource.com>2007-05-10 19:33:05 +0100
committerChristian Limpach <Christian.Limpach@xensource.com>2007-05-10 19:33:05 +0100
commit548309d6a23fe242a3112ce7c23574058c36f434 (patch)
treea8eeee47176c1ebcd9211c06330fda3966acd1e4 /tools/ioemu/vnc.c
parent369bafdb1c1dcd2b323206befd7fc4ac5e20816f (diff)
downloadxen-548309d6a23fe242a3112ce7c23574058c36f434.tar.gz
xen-548309d6a23fe242a3112ce7c23574058c36f434.tar.bz2
xen-548309d6a23fe242a3112ce7c23574058c36f434.zip
[qemu] Fix keypad handling for VNC.
Signed-off-by: Christian Limpach <Christian.Limpach@xensource.com>
Diffstat (limited to 'tools/ioemu/vnc.c')
-rw-r--r--tools/ioemu/vnc.c29
1 files changed, 29 insertions, 0 deletions
diff --git a/tools/ioemu/vnc.c b/tools/ioemu/vnc.c
index 46f1682e63..524da36cc2 100644
--- a/tools/ioemu/vnc.c
+++ b/tools/ioemu/vnc.c
@@ -909,6 +909,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;
@@ -936,6 +942,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 (keycodeIsKeypad(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 (keysymIsNumlock(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()) {
@@ -1427,6 +1455,7 @@ int vnc_display_init(DisplayState *ds, const char *arg, int find_unused)
vs->kbd_layout = init_keyboard_layout(keyboard_layout);
if (!vs->kbd_layout)
exit(1);
+ vs->modifiers_state[0x45] = 1; /* NumLock on - on boot */
vs->ds->data = NULL;
vs->ds->dpy_update = vnc_dpy_update;