From 90a9b82272446fdaebe71c966325fd7e670f75c6 Mon Sep 17 00:00:00 2001 From: Matthew Allum Date: Sat, 8 Jul 2006 21:57:07 +0100 Subject: [PATCH] Fix crash in Xephyr when running on host X with keymap width < 4 ( i.e xvnc ) --- hw/kdrive/ephyr/hostx.c | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/hw/kdrive/ephyr/hostx.c b/hw/kdrive/ephyr/hostx.c index ae776a7eb..32a46dcf4 100644 --- a/hw/kdrive/ephyr/hostx.c +++ b/hw/kdrive/ephyr/hostx.c @@ -669,7 +669,7 @@ void hostx_load_keymap(void) { KeySym *keymap; - int mapWidth, min_keycode, max_keycode; + int host_width, min_keycode, max_keycode, width; int i,j; XDisplayKeycodes(HostX.dpy, &min_keycode, &max_keycode); @@ -679,25 +679,21 @@ hostx_load_keymap(void) keymap = XGetKeyboardMapping(HostX.dpy, min_keycode, max_keycode - min_keycode + 1, - &mapWidth); + &host_width); /* Try and copy the hosts keymap into our keymap to avoid loads * of messing around. * * kdrive cannot can have more than 4 keysyms per keycode - * so we only copy the first 4 ( xorg has 6 per keycode ) + * so we only copy at most the first 4 ( xorg has 6 per keycode, XVNC 2 ) */ + width = (host_width > 4) ? 4 : host_width; for (i=0; i<(max_keycode - min_keycode+1); i++) - for (j=0; j<4; j++) - kdKeymap[ (i*4)+j ] = keymap[ (i*mapWidth) + j ]; + for (j=0; j 4) ? 4 : mapWidth; + kdKeymapWidth = width; XFree(keymap); }