diff -ur qemu-0.8.2/console.c qemu-0.8.2~/console.c
--- qemu-0.8.2/console.c	2006-07-23 01:23:34.000000000 +0800
+++ qemu-0.8.2~/console.c	2006-07-25 14:32:05.000000000 +0800
@@ -1032,11 +1032,21 @@
     return !active_console->text_console;
 }
 
+void set_color_table(DisplayState *ds) 
+{
+    int i, j;
+        for(j = 0; j < 2; j++) {
+            for(i = 0; i < 8; i++) {
+                color_table[j][i] = col_expand(ds, 
+                        vga_get_color(ds, color_table_rgb[j][i]));
+            }
+        }
+}
+
 CharDriverState *text_console_init(DisplayState *ds)
 {
     CharDriverState *chr;
     TextConsole *s;
-    int i,j;
     static int color_inited;
 
     chr = qemu_mallocz(sizeof(CharDriverState));
@@ -1058,12 +1068,7 @@
     
     if (!color_inited) {
         color_inited = 1;
-        for(j = 0; j < 2; j++) {
-            for(i = 0; i < 8; i++) {
-                color_table[j][i] = col_expand(s->ds, 
-                        vga_get_color(s->ds, color_table_rgb[j][i]));
-            }
-        }
+        set_color_table(ds);
     }
     s->y_displayed = 0;
     s->y_base = 0;
Only in qemu-0.8.2~: console.c.orig
Only in qemu-0.8.2~: cscope.out
diff -ur qemu-0.8.2/vl.h qemu-0.8.2~/vl.h
--- qemu-0.8.2/vl.h	2006-07-23 01:23:34.000000000 +0800
+++ qemu-0.8.2~/vl.h	2006-07-25 14:32:05.000000000 +0800
@@ -300,6 +300,7 @@
 int is_graphic_console(void);
 CharDriverState *text_console_init(DisplayState *ds);
 void console_select(unsigned int index);
+void set_color_table(DisplayState *ds);
 
 /* serial ports */
 
Only in qemu-0.8.2~: vl.h.orig
diff -ur qemu-0.8.2/vnc.c qemu-0.8.2~/vnc.c
--- qemu-0.8.2/vnc.c	2006-07-23 01:23:34.000000000 +0800
+++ qemu-0.8.2~/vnc.c	2006-07-25 14:37:07.000000000 +0800
@@ -31,6 +31,10 @@
 #include "vnc_keysym.h"
 #include "keymaps.c"
 
+#define XK_MISCELLANY
+#define XK_LATIN1
+#include <X11/keysymdef.h>
+
 typedef struct Buffer
 {
     size_t capacity;
@@ -71,6 +75,7 @@
     Buffer output;
     Buffer input;
     kbd_layout_t *kbd_layout;
+    int ctl_keys;               /* Ctrl+Alt starts calibration */
     /* current output mode information */
     VncWritePixels *write_pixels;
     VncSendHextileTile *send_hextile_tile;
@@ -175,10 +180,14 @@
 	exit(1);
     }
 
-    ds->depth = vs->depth * 8;
+    if (ds->depth != vs->depth * 8) {
+        ds->depth = vs->depth * 8;
+        set_color_table(ds);
+    }
     ds->width = w;
     ds->height = h;
     ds->linesize = w * vs->depth;
+
     if (vs->csock != -1 && vs->has_resize) {
 	vnc_write_u8(vs, 0);  /* msg id */
 	vnc_write_u8(vs, 0);
@@ -701,16 +710,71 @@
 
 static void do_key_event(VncState *vs, int down, uint32_t sym)
 {
-    int keycode;
+    sym &= 0xFFFF;
 
-    keycode = keysym2scancode(vs->kbd_layout, sym & 0xFFFF);
+    if(is_graphic_console()) {
+        int keycode;
+        keycode = keysym2scancode(vs->kbd_layout, sym);
+ 
+        if (keycode & 0x80)
+            kbd_put_keycode(0xe0);
+        if (down)
+            kbd_put_keycode(keycode & 0x7f);
+        else
+            kbd_put_keycode(keycode | 0x80);
+    } else if(down) {
+        int qemu_keysym = 0;
+        if (sym <= 128) /* normal ascii */
+            qemu_keysym = sym;
+        else {
+            switch(sym) {
+            case XK_Up: qemu_keysym = QEMU_KEY_UP; break;
+            case XK_Down: qemu_keysym = QEMU_KEY_DOWN; break;
+            case XK_Left: qemu_keysym = QEMU_KEY_LEFT; break;
+            case XK_Right: qemu_keysym = QEMU_KEY_RIGHT; break;
+            case XK_Home: qemu_keysym = QEMU_KEY_HOME; break;
+            case XK_End: qemu_keysym = QEMU_KEY_END; break;
+            case XK_Page_Up: qemu_keysym = QEMU_KEY_PAGEUP; break;
+            case XK_Page_Down: qemu_keysym = QEMU_KEY_PAGEDOWN; break;
+            case XK_BackSpace: qemu_keysym = QEMU_KEY_BACKSPACE; break;
+            case XK_Delete: qemu_keysym = QEMU_KEY_DELETE; break;
+            case XK_Return:
+            case XK_Linefeed: qemu_keysym = sym; break;
+            default: break;
+            }
+        }
+        if (qemu_keysym != 0)
+            kbd_put_keysym(qemu_keysym);
+    }
 
-    if (keycode & 0x80)
-	kbd_put_keycode(0xe0);
-    if (down)
-	kbd_put_keycode(keycode & 0x7f);
-    else
-	kbd_put_keycode(keycode | 0x80);
+    if(down) {
+        if(sym == XK_Control_L)
+            vs->ctl_keys |= 1;
+        else if(sym == XK_Alt_L)
+            vs->ctl_keys |= 2;
+    } else {
+        switch(sym) {
+        case XK_Control_L:
+            vs->ctl_keys &= ~1;
+            break;
+
+        case XK_Alt_L:
+            vs->ctl_keys &= ~2;
+            break;
+
+        case XK_1 ... XK_9:
+            if((vs->ctl_keys & 3) != 3)
+                break;
+
+            console_select(sym - XK_1);
+            if (is_graphic_console()) {
+                /* tell the vga console to redisplay itself */
+                vga_hw_invalidate();
+                vnc_dpy_update(vs->ds, 0, 0, vs->ds->width, vs->ds->height);
+            }
+            break;
+        }
+    }
 }
 
 static void key_event(VncState *vs, int down, uint32_t sym)
