ia64/xen-unstable
changeset 15076:16319e70f77d
[qemu patches] Update patches upto changeset 15036:dfbbb4d3b0dd.
Signed-off-by: Christian Limpach <Christian.Limpach@xensource.com>
Signed-off-by: Christian Limpach <Christian.Limpach@xensource.com>
author | Christian Limpach <Christian.Limpach@xensource.com> |
---|---|
date | Thu May 10 19:35:25 2007 +0100 (2007-05-10) |
parents | dfbbb4d3b0dd |
children | e19ddfa781c5 |
files | tools/ioemu/patches/series tools/ioemu/patches/vnc-keypad-handling tools/ioemu/patches/vnc-numpad-handling |
line diff
1.1 --- a/tools/ioemu/patches/series Thu May 10 19:33:05 2007 +0100 1.2 +++ b/tools/ioemu/patches/series Thu May 10 19:35:25 2007 +0100 1.3 @@ -77,3 +77,4 @@ qemu-cirrus-bounds-checks 1.4 qemu-block-device-bounds-checks 1.5 qemu-dma-null-pointer-check 1.6 vnc-fix-text-display-shift-key 1.7 +vnc-keypad-handling
2.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 2.2 +++ b/tools/ioemu/patches/vnc-keypad-handling Thu May 10 19:35:25 2007 +0100 2.3 @@ -0,0 +1,190 @@ 2.4 +# HG changeset patch 2.5 +# User Christian Limpach <Christian.Limpach@xensource.com> 2.6 +# Date 1178821985 -3600 2.7 +# Node ID dfbbb4d3b0dd2107cfee2b07fab6f33cefc4719c 2.8 +# Parent 23c4790512dbc889c4deed8ae1f8d54813c4b474 2.9 +[qemu] Fix keypad handling for VNC. 2.10 + 2.11 +Signed-off-by: Christian Limpach <Christian.Limpach@xensource.com> 2.12 + 2.13 +Index: ioemu/vnc.c 2.14 +=================================================================== 2.15 +--- ioemu.orig/vnc.c 2007-05-10 19:34:49.000000000 +0100 2.16 ++++ ioemu/vnc.c 2007-05-10 19:34:51.000000000 +0100 2.17 +@@ -909,6 +909,12 @@ 2.18 + } 2.19 + } 2.20 + 2.21 ++static void press_key(VncState *vs, int keysym) 2.22 ++{ 2.23 ++ kbd_put_keycode(keysym2scancode(vs->kbd_layout, keysym) & 0x7f); 2.24 ++ kbd_put_keycode(keysym2scancode(vs->kbd_layout, keysym) | 0x80); 2.25 ++} 2.26 ++ 2.27 + static void do_key_event(VncState *vs, int down, uint32_t sym) 2.28 + { 2.29 + int keycode; 2.30 +@@ -936,6 +942,28 @@ 2.31 + return; 2.32 + } 2.33 + break; 2.34 ++ case 0x45: /* NumLock */ 2.35 ++ if (!down) 2.36 ++ vs->modifiers_state[keycode] ^= 1; 2.37 ++ break; 2.38 ++ } 2.39 ++ 2.40 ++ if (keycodeIsKeypad(vs->kbd_layout, keycode)) { 2.41 ++ /* If the numlock state needs to change then simulate an additional 2.42 ++ keypress before sending this one. This will happen if the user 2.43 ++ toggles numlock away from the VNC window. 2.44 ++ */ 2.45 ++ if (keysymIsNumlock(vs->kbd_layout, sym & 0xFFFF)) { 2.46 ++ if (!vs->modifiers_state[0x45]) { 2.47 ++ vs->modifiers_state[0x45] = 1; 2.48 ++ press_key(vs, 0xff7f); 2.49 ++ } 2.50 ++ } else { 2.51 ++ if (vs->modifiers_state[0x45]) { 2.52 ++ vs->modifiers_state[0x45] = 0; 2.53 ++ press_key(vs, 0xff7f); 2.54 ++ } 2.55 ++ } 2.56 + } 2.57 + 2.58 + if (is_graphic_console()) { 2.59 +@@ -1427,6 +1455,7 @@ 2.60 + vs->kbd_layout = init_keyboard_layout(keyboard_layout); 2.61 + if (!vs->kbd_layout) 2.62 + exit(1); 2.63 ++ vs->modifiers_state[0x45] = 1; /* NumLock on - on boot */ 2.64 + 2.65 + vs->ds->data = NULL; 2.66 + vs->ds->dpy_update = vnc_dpy_update; 2.67 +Index: ioemu/keymaps.c 2.68 +=================================================================== 2.69 +--- ioemu.orig/keymaps.c 2007-05-10 19:34:49.000000000 +0100 2.70 ++++ ioemu/keymaps.c 2007-05-10 19:34:51.000000000 +0100 2.71 +@@ -32,6 +32,12 @@ 2.72 + return 0; 2.73 + } 2.74 + 2.75 ++struct key_range { 2.76 ++ int start; 2.77 ++ int end; 2.78 ++ struct key_range *next; 2.79 ++}; 2.80 ++ 2.81 + #define MAX_NORMAL_KEYCODE 512 2.82 + #define MAX_EXTRA_COUNT 256 2.83 + typedef struct { 2.84 +@@ -41,8 +47,34 @@ 2.85 + uint16_t keycode; 2.86 + } keysym2keycode_extra[MAX_EXTRA_COUNT]; 2.87 + int extra_count; 2.88 ++ struct key_range *keypad_range; 2.89 ++ struct key_range *numlock_range; 2.90 + } kbd_layout_t; 2.91 + 2.92 ++static void add_to_key_range(struct key_range **krp, int code) { 2.93 ++ struct key_range *kr; 2.94 ++ for (kr = *krp; kr; kr = kr->next) { 2.95 ++ if (code >= kr->start && code <= kr->end) 2.96 ++ break; 2.97 ++ if (code == kr->start - 1) { 2.98 ++ kr->start--; 2.99 ++ break; 2.100 ++ } 2.101 ++ if (code == kr->end + 1) { 2.102 ++ kr->end++; 2.103 ++ break; 2.104 ++ } 2.105 ++ } 2.106 ++ if (kr == NULL) { 2.107 ++ kr = qemu_mallocz(sizeof(*kr)); 2.108 ++ if (kr) { 2.109 ++ kr->start = kr->end = code; 2.110 ++ kr->next = *krp; 2.111 ++ *krp = kr; 2.112 ++ } 2.113 ++ } 2.114 ++} 2.115 ++ 2.116 + static kbd_layout_t *parse_keyboard_layout(const char *language, 2.117 + kbd_layout_t * k) 2.118 + { 2.119 +@@ -87,7 +119,15 @@ 2.120 + // fprintf(stderr, "Warning: unknown keysym %s\n", line); 2.121 + } else { 2.122 + const char *rest = end_of_keysym + 1; 2.123 +- int keycode = strtol(rest, NULL, 0); 2.124 ++ char *rest2; 2.125 ++ int keycode = strtol(rest, &rest2, 0); 2.126 ++ 2.127 ++ if (rest && strstr(rest, "numlock")) { 2.128 ++ add_to_key_range(&k->keypad_range, keycode); 2.129 ++ add_to_key_range(&k->numlock_range, keysym); 2.130 ++ fprintf(stderr, "keypad keysym %04x keycode %d\n", keysym, keycode); 2.131 ++ } 2.132 ++ 2.133 + /* if(keycode&0x80) 2.134 + keycode=(keycode<<8)^0x80e0; */ 2.135 + if (keysym < MAX_NORMAL_KEYCODE) { 2.136 +@@ -143,3 +183,25 @@ 2.137 + } 2.138 + return 0; 2.139 + } 2.140 ++ 2.141 ++static int keycodeIsKeypad(void *kbd_layout, int keycode) 2.142 ++{ 2.143 ++ kbd_layout_t *k = kbd_layout; 2.144 ++ struct key_range *kr; 2.145 ++ 2.146 ++ for (kr = k->keypad_range; kr; kr = kr->next) 2.147 ++ if (keycode >= kr->start && keycode <= kr->end) 2.148 ++ return 1; 2.149 ++ return 0; 2.150 ++} 2.151 ++ 2.152 ++static int keysymIsNumlock(void *kbd_layout, int keysym) 2.153 ++{ 2.154 ++ kbd_layout_t *k = kbd_layout; 2.155 ++ struct key_range *kr; 2.156 ++ 2.157 ++ for (kr = k->numlock_range; kr; kr = kr->next) 2.158 ++ if (keysym >= kr->start && keysym <= kr->end) 2.159 ++ return 1; 2.160 ++ return 0; 2.161 ++} 2.162 +Index: ioemu/vnc_keysym.h 2.163 +=================================================================== 2.164 +--- ioemu.orig/vnc_keysym.h 2007-05-10 19:34:49.000000000 +0100 2.165 ++++ ioemu/vnc_keysym.h 2007-05-10 19:34:51.000000000 +0100 2.166 +@@ -232,6 +232,19 @@ 2.167 + {"Home", 0xff50}, /* XK_Home */ 2.168 + {"End", 0xff57}, /* XK_End */ 2.169 + {"Scroll_Lock", 0xff14}, /* XK_Scroll_Lock */ 2.170 ++{"KP_Home", 0xff95}, 2.171 ++{"KP_Left", 0xff96}, 2.172 ++{"KP_Up", 0xff97}, 2.173 ++{"KP_Right", 0xff98}, 2.174 ++{"KP_Down", 0xff99}, 2.175 ++{"KP_Prior", 0xff9a}, 2.176 ++{"KP_Page_Up", 0xff9a}, 2.177 ++{"KP_Next", 0xff9b}, 2.178 ++{"KP_Page_Down", 0xff9b}, 2.179 ++{"KP_End", 0xff9c}, 2.180 ++{"KP_Begin", 0xff9d}, 2.181 ++{"KP_Insert", 0xff9e}, 2.182 ++{"KP_Delete", 0xff9f}, 2.183 + {"F1", 0xffbe}, /* XK_F1 */ 2.184 + {"F2", 0xffbf}, /* XK_F2 */ 2.185 + {"F3", 0xffc0}, /* XK_F3 */ 2.186 +@@ -259,6 +272,7 @@ 2.187 + {"KP_8", 0xffb8}, /* XK_KP_8 */ 2.188 + {"KP_9", 0xffb9}, /* XK_KP_9 */ 2.189 + {"KP_Add", 0xffab}, /* XK_KP_Add */ 2.190 ++{"KP_Separator", 0xffac},/* XK_KP_Separator */ 2.191 + {"KP_Decimal", 0xffae}, /* XK_KP_Decimal */ 2.192 + {"KP_Divide", 0xffaf}, /* XK_KP_Divide */ 2.193 + {"KP_Enter", 0xff8d}, /* XK_KP_Enter */
3.1 --- a/tools/ioemu/patches/vnc-numpad-handling Thu May 10 19:33:05 2007 +0100 3.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 3.3 @@ -1,236 +0,0 @@ 3.4 -# HG changeset patch 3.5 -# User Ewan Mellor <ewan@xensource.com> 3.6 -# Node ID c7f4a89eb054a1ad411da1e4cdc8aeda1a98c4fa 3.7 -# Parent 565cd8f32c70da8ae7dbaaeb9dff28aa8b6307e1 3.8 -Fix numpad handling in QEMU's VNC server. The keymaps that we have include 3.9 -information on which keys change depending upon the numlock setting, but 3.10 -this isn't being used. By forcing numlock on and off as necessary, when 3.11 -receiving these keysyms through the VNC connection, we ensure that the 3.12 -server's numlock status is the same as the client's. 3.13 - 3.14 -Signed-off-by: Ewan Mellor <ewan@xensource.com> 3.15 - 3.16 -Index: ioemu/keymaps.c 3.17 -=================================================================== 3.18 ---- ioemu.orig/keymaps.c 2006-12-06 23:41:30.000000000 +0000 3.19 -+++ ioemu/keymaps.c 2006-12-08 18:20:27.000000000 +0000 3.20 -@@ -36,8 +36,10 @@ 3.21 - #define MAX_EXTRA_COUNT 256 3.22 - typedef struct { 3.23 - uint16_t keysym2keycode[MAX_NORMAL_KEYCODE]; 3.24 -+ int keysym2numlock[MAX_NORMAL_KEYCODE]; 3.25 - struct { 3.26 - int keysym; 3.27 -+ int numlock; 3.28 - uint16_t keycode; 3.29 - } keysym2keycode_extra[MAX_EXTRA_COUNT]; 3.30 - int extra_count; 3.31 -@@ -50,6 +52,8 @@ 3.32 - char file_name[1024]; 3.33 - char line[1024]; 3.34 - int len; 3.35 -+ int *keycode2numlock; 3.36 -+ int i; 3.37 - 3.38 - snprintf(file_name, sizeof(file_name), 3.39 - "%s/keymaps/%s", bios_dir, language); 3.40 -@@ -63,6 +67,15 @@ 3.41 - "Could not read keymap file: '%s'\n", file_name); 3.42 - return 0; 3.43 - } 3.44 -+ 3.45 -+ /* Allocate a temporary map tracking which keycodes change when numlock is 3.46 -+ set. Keycodes are 16 bit, so 65536 is safe. */ 3.47 -+ keycode2numlock = malloc(65536 * sizeof(int)); 3.48 -+ if (!keycode2numlock) { 3.49 -+ perror("Could not read keymap file"); 3.50 -+ return 0; 3.51 -+ } 3.52 -+ 3.53 - for(;;) { 3.54 - if (fgets(line, 1024, f) == NULL) 3.55 - break; 3.56 -@@ -86,13 +99,19 @@ 3.57 - if (keysym == 0) { 3.58 - // fprintf(stderr, "Warning: unknown keysym %s\n", line); 3.59 - } else { 3.60 -- const char *rest = end_of_keysym + 1; 3.61 -- int keycode = strtol(rest, NULL, 0); 3.62 -+ char *rest = end_of_keysym + 1; 3.63 -+ int keycode = strtol(rest, &rest, 0); 3.64 -+ int numlock = (rest != NULL && 3.65 -+ strstr(rest, "numlock") != NULL); 3.66 -+ 3.67 -+ keycode2numlock[keycode] = numlock; 3.68 -+ 3.69 - /* if(keycode&0x80) 3.70 - keycode=(keycode<<8)^0x80e0; */ 3.71 - if (keysym < MAX_NORMAL_KEYCODE) { 3.72 - //fprintf(stderr,"Setting keysym %s (%d) to %d\n",line,keysym,keycode); 3.73 - k->keysym2keycode[keysym] = keycode; 3.74 -+ k->keysym2numlock[keysym] = numlock; 3.75 - } else { 3.76 - if (k->extra_count >= MAX_EXTRA_COUNT) { 3.77 - fprintf(stderr, 3.78 -@@ -107,6 +126,8 @@ 3.79 - keysym = keysym; 3.80 - k->keysym2keycode_extra[k->extra_count]. 3.81 - keycode = keycode; 3.82 -+ k->keysym2keycode_extra[k->extra_count]. 3.83 -+ numlock = numlock; 3.84 - k->extra_count++; 3.85 - } 3.86 - } 3.87 -@@ -115,6 +136,22 @@ 3.88 - } 3.89 - } 3.90 - fclose(f); 3.91 -+ 3.92 -+ for (i = 0; i < MAX_NORMAL_KEYCODE; i++) { 3.93 -+ if (k->keysym2numlock[i] != 1) { 3.94 -+ k->keysym2numlock[i] = -keycode2numlock[k->keysym2keycode[i]]; 3.95 -+ } 3.96 -+ } 3.97 -+ 3.98 -+ for (i = 0; i < k->extra_count; i++) { 3.99 -+ if (k->keysym2keycode_extra[i].numlock != 1) { 3.100 -+ k->keysym2keycode_extra[i].numlock = 3.101 -+ -keycode2numlock[k->keysym2keycode_extra[i].keycode]; 3.102 -+ } 3.103 -+ } 3.104 -+ 3.105 -+ free(keycode2numlock); 3.106 -+ 3.107 - return k; 3.108 - } 3.109 - 3.110 -@@ -143,3 +180,25 @@ 3.111 - } 3.112 - return 0; 3.113 - } 3.114 -+ 3.115 -+/** 3.116 -+ * Returns 1 if the given keysym requires numlock to be pressed, -1 if it 3.117 -+ * requires it to be cleared, and 0 otherwise. 3.118 -+ */ 3.119 -+static int keysym2numlock(void *kbd_layout, int keysym) 3.120 -+{ 3.121 -+ kbd_layout_t *k = kbd_layout; 3.122 -+ if (keysym < MAX_NORMAL_KEYCODE) { 3.123 -+ return k->keysym2numlock[keysym]; 3.124 -+ } else { 3.125 -+ int i; 3.126 -+#ifdef XK_ISO_Left_Tab 3.127 -+ if (keysym == XK_ISO_Left_Tab) 3.128 -+ keysym = XK_Tab; 3.129 -+#endif 3.130 -+ for (i = 0; i < k->extra_count; i++) 3.131 -+ if (k->keysym2keycode_extra[i].keysym == keysym) 3.132 -+ return k->keysym2keycode_extra[i].numlock; 3.133 -+ } 3.134 -+ return 0; 3.135 -+} 3.136 -Index: ioemu/vnc.c 3.137 -=================================================================== 3.138 ---- ioemu.orig/vnc.c 2006-12-08 18:18:26.000000000 +0000 3.139 -+++ ioemu/vnc.c 2006-12-08 18:19:43.000000000 +0000 3.140 -@@ -115,6 +115,7 @@ 3.141 - 3.142 - int ctl_keys; /* Ctrl+Alt starts calibration */ 3.143 - int shift_keys; /* Shift / CapsLock keys */ 3.144 -+ int numlock; 3.145 - }; 3.146 - 3.147 - #define DIRTY_PIXEL_BITS 64 3.148 -@@ -854,14 +855,40 @@ 3.149 - } 3.150 - } 3.151 - 3.152 -+static void press_key(VncState *vs, int keycode) 3.153 -+{ 3.154 -+ kbd_put_keycode(keysym2scancode(vs->kbd_layout, keycode) & 0x7f); 3.155 -+ kbd_put_keycode(keysym2scancode(vs->kbd_layout, keycode) | 0x80); 3.156 -+} 3.157 -+ 3.158 - static void do_key_event(VncState *vs, int down, uint32_t sym) 3.159 - { 3.160 - sym &= 0xFFFF; 3.161 - 3.162 - if (is_graphic_console()) { 3.163 - int keycode; 3.164 -+ int numlock; 3.165 - 3.166 - keycode = keysym2scancode(vs->kbd_layout, sym); 3.167 -+ numlock = keysym2numlock(vs->kbd_layout, sym); 3.168 -+ 3.169 -+ /* If the numlock state needs to change then simulate an additional 3.170 -+ keypress before sending this one. This will happen if the user 3.171 -+ toggles numlock away from the VNC window. 3.172 -+ */ 3.173 -+ if (numlock == 1) { 3.174 -+ if (!vs->numlock) { 3.175 -+ vs->numlock = 1; 3.176 -+ press_key(vs, XK_Num_Lock); 3.177 -+ } 3.178 -+ } 3.179 -+ else if (numlock == -1) { 3.180 -+ if (vs->numlock) { 3.181 -+ vs->numlock = 0; 3.182 -+ press_key(vs, XK_Num_Lock); 3.183 -+ } 3.184 -+ } 3.185 -+ 3.186 - if (keycode & 0x80) 3.187 - kbd_put_keycode(0xe0); 3.188 - if (down) 3.189 -@@ -932,6 +959,10 @@ 3.190 - vs->shift_keys ^= 2; 3.191 - break; 3.192 - 3.193 -+ case XK_Num_Lock: 3.194 -+ vs->numlock = !vs->numlock; 3.195 -+ break; 3.196 -+ 3.197 - case XK_1 ... XK_9: 3.198 - if ((vs->ctl_keys & 3) != 3) 3.199 - break; 3.200 -@@ -1355,6 +1386,7 @@ 3.201 - vs->lsock = -1; 3.202 - vs->csock = -1; 3.203 - vs->depth = 4; 3.204 -+ vs->numlock = 0; 3.205 - 3.206 - vs->ds = ds; 3.207 - 3.208 -Index: ioemu/vnc_keysym.h 3.209 -=================================================================== 3.210 ---- ioemu.orig/vnc_keysym.h 2006-12-08 18:17:01.000000000 +0000 3.211 -+++ ioemu/vnc_keysym.h 2006-12-08 18:19:43.000000000 +0000 3.212 -@@ -231,6 +231,19 @@ 3.213 - {"Home", 0xff50}, /* XK_Home */ 3.214 - {"End", 0xff57}, /* XK_End */ 3.215 - {"Scroll_Lock", 0xff14}, /* XK_Scroll_Lock */ 3.216 -+{"KP_Home", 0xff95}, 3.217 -+{"KP_Left", 0xff96}, 3.218 -+{"KP_Up", 0xff97}, 3.219 -+{"KP_Right", 0xff98}, 3.220 -+{"KP_Down", 0xff99}, 3.221 -+{"KP_Prior", 0xff9a}, 3.222 -+{"KP_Page_Up", 0xff9a}, 3.223 -+{"KP_Next", 0xff9b}, 3.224 -+{"KP_Page_Down", 0xff9b}, 3.225 -+{"KP_End", 0xff9c}, 3.226 -+{"KP_Begin", 0xff9d}, 3.227 -+{"KP_Insert", 0xff9e}, 3.228 -+{"KP_Delete", 0xff9f}, 3.229 - {"F1", 0xffbe}, /* XK_F1 */ 3.230 - {"F2", 0xffbf}, /* XK_F2 */ 3.231 - {"F3", 0xffc0}, /* XK_F3 */ 3.232 -@@ -258,6 +271,7 @@ 3.233 - {"KP_8", 0xffb8}, /* XK_KP_8 */ 3.234 - {"KP_9", 0xffb9}, /* XK_KP_9 */ 3.235 - {"KP_Add", 0xffab}, /* XK_KP_Add */ 3.236 -+{"KP_Separator", 0xffac},/* XK_KP_Separator */ 3.237 - {"KP_Decimal", 0xffae}, /* XK_KP_Decimal */ 3.238 - {"KP_Divide", 0xffaf}, /* XK_KP_Divide */ 3.239 - {"KP_Enter", 0xff8d}, /* XK_KP_Enter */