ia64/xen-unstable

changeset 10807:3e07ec30c445

[qemu] Add access to the monito vt over VNC.
Recognize ctrl+alt+1/2/3 to switch among screens.

Signed-off-by: Yang Xiaowei <xiaowei.yang@intel.com>
Signed-off-by: Christian Limpach <Christian.Limpach@xensource.com>
author chris@kneesaa.uk.xensource.com
date Wed Jul 26 14:52:47 2006 +0100 (2006-07-26)
parents 4c2a281cd1e7
children b4d5a36e380b
files tools/ioemu/patches/series tools/ioemu/patches/vnc-access-monitor-vt tools/ioemu/vnc.c
line diff
     1.1 --- a/tools/ioemu/patches/series	Wed Jul 26 14:38:00 2006 +0100
     1.2 +++ b/tools/ioemu/patches/series	Wed Jul 26 14:52:47 2006 +0100
     1.3 @@ -33,3 +33,4 @@ vnc-cleanup
     1.4  vnc-fixes
     1.5  vnc-start-vncviewer
     1.6  vnc-title-domain-name
     1.7 +vnc-access-monitor-vt
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/tools/ioemu/patches/vnc-access-monitor-vt	Wed Jul 26 14:52:47 2006 +0100
     2.3 @@ -0,0 +1,112 @@
     2.4 +Index: ioemu/vnc.c
     2.5 +===================================================================
     2.6 +--- ioemu.orig/vnc.c	2006-07-26 14:33:57.906165040 +0100
     2.7 ++++ ioemu/vnc.c	2006-07-26 14:44:09.972552689 +0100
     2.8 +@@ -32,6 +32,10 @@
     2.9 + #include "vnc_keysym.h"
    2.10 + #include "keymaps.c"
    2.11 + 
    2.12 ++#define XK_MISCELLANY
    2.13 ++#define XK_LATIN1
    2.14 ++#include <X11/keysymdef.h>
    2.15 ++
    2.16 + typedef struct Buffer
    2.17 + {
    2.18 +     size_t capacity;
    2.19 +@@ -64,6 +68,7 @@
    2.20 +     Buffer output;
    2.21 +     Buffer input;
    2.22 +     kbd_layout_t *kbd_layout;
    2.23 ++    int ctl_keys;               /* Ctrl+Alt starts calibration */
    2.24 + 
    2.25 +     VncReadEvent *read_handler;
    2.26 +     size_t read_handler_expect;
    2.27 +@@ -679,16 +684,80 @@
    2.28 + 
    2.29 + static void do_key_event(VncState *vs, int down, uint32_t sym)
    2.30 + {
    2.31 +-    int keycode;
    2.32 ++    sym &= 0xFFFF;
    2.33 + 
    2.34 +-    keycode = keysym2scancode(vs->kbd_layout, sym & 0xFFFF);
    2.35 ++    if (is_graphic_console()) {
    2.36 ++	int keycode;
    2.37 + 
    2.38 +-    if (keycode & 0x80)
    2.39 +-	kbd_put_keycode(0xe0);
    2.40 +-    if (down)
    2.41 +-	kbd_put_keycode(keycode & 0x7f);
    2.42 +-    else
    2.43 +-	kbd_put_keycode(keycode | 0x80);
    2.44 ++	keycode = keysym2scancode(vs->kbd_layout, sym);
    2.45 ++	if (keycode & 0x80)
    2.46 ++	    kbd_put_keycode(0xe0);
    2.47 ++	if (down)
    2.48 ++	    kbd_put_keycode(keycode & 0x7f);
    2.49 ++	else
    2.50 ++	    kbd_put_keycode(keycode | 0x80);
    2.51 ++    } else if (down) {
    2.52 ++	int qemu_keysym = 0;
    2.53 ++
    2.54 ++	if (sym <= 128) /* normal ascii */
    2.55 ++	    qemu_keysym = sym;
    2.56 ++	else {
    2.57 ++	    switch (sym) {
    2.58 ++	    case XK_Up: qemu_keysym = QEMU_KEY_UP; break;
    2.59 ++	    case XK_Down: qemu_keysym = QEMU_KEY_DOWN; break;
    2.60 ++	    case XK_Left: qemu_keysym = QEMU_KEY_LEFT; break;
    2.61 ++	    case XK_Right: qemu_keysym = QEMU_KEY_RIGHT; break;
    2.62 ++	    case XK_Home: qemu_keysym = QEMU_KEY_HOME; break;
    2.63 ++	    case XK_End: qemu_keysym = QEMU_KEY_END; break;
    2.64 ++	    case XK_Page_Up: qemu_keysym = QEMU_KEY_PAGEUP; break;
    2.65 ++	    case XK_Page_Down: qemu_keysym = QEMU_KEY_PAGEDOWN; break;
    2.66 ++	    case XK_BackSpace: qemu_keysym = QEMU_KEY_BACKSPACE; break;
    2.67 ++	    case XK_Delete: qemu_keysym = QEMU_KEY_DELETE; break;
    2.68 ++	    case XK_Return:
    2.69 ++	    case XK_Linefeed: qemu_keysym = sym; break;
    2.70 ++	    default: break;
    2.71 ++	    }
    2.72 ++	}
    2.73 ++	if (qemu_keysym != 0)
    2.74 ++	    kbd_put_keysym(qemu_keysym);
    2.75 ++    }
    2.76 ++
    2.77 ++    if (down) {
    2.78 ++	switch (sym) {
    2.79 ++	case XK_Control_L:
    2.80 ++	    vs->ctl_keys |= 1;
    2.81 ++	    break;
    2.82 ++
    2.83 ++	case XK_Alt_L:
    2.84 ++	    vs->ctl_keys |= 2;
    2.85 ++	    break;
    2.86 ++
    2.87 ++	default:
    2.88 ++	    break;
    2.89 ++	}
    2.90 ++    } else {
    2.91 ++	switch (sym) {
    2.92 ++	case XK_Control_L:
    2.93 ++	    vs->ctl_keys &= ~1;
    2.94 ++	    break;
    2.95 ++
    2.96 ++	case XK_Alt_L:
    2.97 ++	    vs->ctl_keys &= ~2;
    2.98 ++	    break;
    2.99 ++
   2.100 ++	case XK_1 ... XK_9:
   2.101 ++	    if ((vs->ctl_keys & 3) != 3)
   2.102 ++		break;
   2.103 ++
   2.104 ++	    console_select(sym - XK_1);
   2.105 ++	    if (is_graphic_console()) {
   2.106 ++		/* tell the vga console to redisplay itself */
   2.107 ++		vga_hw_invalidate();
   2.108 ++		vnc_dpy_update(vs->ds, 0, 0, vs->ds->width, vs->ds->height);
   2.109 ++	    }
   2.110 ++	    break;
   2.111 ++	}
   2.112 ++    }
   2.113 + }
   2.114 + 
   2.115 + static void key_event(VncState *vs, int down, uint32_t sym)
     3.1 --- a/tools/ioemu/vnc.c	Wed Jul 26 14:38:00 2006 +0100
     3.2 +++ b/tools/ioemu/vnc.c	Wed Jul 26 14:52:47 2006 +0100
     3.3 @@ -32,6 +32,10 @@
     3.4  #include "vnc_keysym.h"
     3.5  #include "keymaps.c"
     3.6  
     3.7 +#define XK_MISCELLANY
     3.8 +#define XK_LATIN1
     3.9 +#include <X11/keysymdef.h>
    3.10 +
    3.11  typedef struct Buffer
    3.12  {
    3.13      size_t capacity;
    3.14 @@ -64,6 +68,7 @@ struct VncState
    3.15      Buffer output;
    3.16      Buffer input;
    3.17      kbd_layout_t *kbd_layout;
    3.18 +    int ctl_keys;               /* Ctrl+Alt starts calibration */
    3.19  
    3.20      VncReadEvent *read_handler;
    3.21      size_t read_handler_expect;
    3.22 @@ -679,16 +684,80 @@ static void pointer_event(VncState *vs, 
    3.23  
    3.24  static void do_key_event(VncState *vs, int down, uint32_t sym)
    3.25  {
    3.26 -    int keycode;
    3.27 -
    3.28 -    keycode = keysym2scancode(vs->kbd_layout, sym & 0xFFFF);
    3.29 +    sym &= 0xFFFF;
    3.30  
    3.31 -    if (keycode & 0x80)
    3.32 -	kbd_put_keycode(0xe0);
    3.33 -    if (down)
    3.34 -	kbd_put_keycode(keycode & 0x7f);
    3.35 -    else
    3.36 -	kbd_put_keycode(keycode | 0x80);
    3.37 +    if (is_graphic_console()) {
    3.38 +	int keycode;
    3.39 +
    3.40 +	keycode = keysym2scancode(vs->kbd_layout, sym);
    3.41 +	if (keycode & 0x80)
    3.42 +	    kbd_put_keycode(0xe0);
    3.43 +	if (down)
    3.44 +	    kbd_put_keycode(keycode & 0x7f);
    3.45 +	else
    3.46 +	    kbd_put_keycode(keycode | 0x80);
    3.47 +    } else if (down) {
    3.48 +	int qemu_keysym = 0;
    3.49 +
    3.50 +	if (sym <= 128) /* normal ascii */
    3.51 +	    qemu_keysym = sym;
    3.52 +	else {
    3.53 +	    switch (sym) {
    3.54 +	    case XK_Up: qemu_keysym = QEMU_KEY_UP; break;
    3.55 +	    case XK_Down: qemu_keysym = QEMU_KEY_DOWN; break;
    3.56 +	    case XK_Left: qemu_keysym = QEMU_KEY_LEFT; break;
    3.57 +	    case XK_Right: qemu_keysym = QEMU_KEY_RIGHT; break;
    3.58 +	    case XK_Home: qemu_keysym = QEMU_KEY_HOME; break;
    3.59 +	    case XK_End: qemu_keysym = QEMU_KEY_END; break;
    3.60 +	    case XK_Page_Up: qemu_keysym = QEMU_KEY_PAGEUP; break;
    3.61 +	    case XK_Page_Down: qemu_keysym = QEMU_KEY_PAGEDOWN; break;
    3.62 +	    case XK_BackSpace: qemu_keysym = QEMU_KEY_BACKSPACE; break;
    3.63 +	    case XK_Delete: qemu_keysym = QEMU_KEY_DELETE; break;
    3.64 +	    case XK_Return:
    3.65 +	    case XK_Linefeed: qemu_keysym = sym; break;
    3.66 +	    default: break;
    3.67 +	    }
    3.68 +	}
    3.69 +	if (qemu_keysym != 0)
    3.70 +	    kbd_put_keysym(qemu_keysym);
    3.71 +    }
    3.72 +
    3.73 +    if (down) {
    3.74 +	switch (sym) {
    3.75 +	case XK_Control_L:
    3.76 +	    vs->ctl_keys |= 1;
    3.77 +	    break;
    3.78 +
    3.79 +	case XK_Alt_L:
    3.80 +	    vs->ctl_keys |= 2;
    3.81 +	    break;
    3.82 +
    3.83 +	default:
    3.84 +	    break;
    3.85 +	}
    3.86 +    } else {
    3.87 +	switch (sym) {
    3.88 +	case XK_Control_L:
    3.89 +	    vs->ctl_keys &= ~1;
    3.90 +	    break;
    3.91 +
    3.92 +	case XK_Alt_L:
    3.93 +	    vs->ctl_keys &= ~2;
    3.94 +	    break;
    3.95 +
    3.96 +	case XK_1 ... XK_9:
    3.97 +	    if ((vs->ctl_keys & 3) != 3)
    3.98 +		break;
    3.99 +
   3.100 +	    console_select(sym - XK_1);
   3.101 +	    if (is_graphic_console()) {
   3.102 +		/* tell the vga console to redisplay itself */
   3.103 +		vga_hw_invalidate();
   3.104 +		vnc_dpy_update(vs->ds, 0, 0, vs->ds->width, vs->ds->height);
   3.105 +	    }
   3.106 +	    break;
   3.107 +	}
   3.108 +    }
   3.109  }
   3.110  
   3.111  static void key_event(VncState *vs, int down, uint32_t sym)