Index: Source/x11/XGServerEvent.m =================================================================== RCS file: /cvsroot/gnustep/gnustep/core/back/Source/x11/XGServerEvent.m,v retrieving revision 1.23 diff -a -u -r1.23 XGServerEvent.m --- Source/x11/XGServerEvent.m 31 Aug 2004 16:36:28 -0000 1.23 +++ Source/x11/XGServerEvent.m 3 Sep 2004 15:12:59 -0000 @@ -127,42 +127,28 @@ static void set_up_num_lock (void); -// checks if given keycode is set in bit vector -static inline int check_key (XEvent *xEvent, KeyCode key_code) -{ - return (key_code == 0) ? - 0 : (xEvent->xkeymap.key_vector[key_code / 8] & (1 << (key_code % 8))); -} - -// checks whether a GNUstep modifier is pressed when we're only able to check -// whether X keycodes are pressed +// checks whether a GNUstep modifier (key_sym) is pressed when we're only able +// to check whether X keycodes are pressed in xEvent->xkeymap; static int check_modifier (XEvent *xEvent, KeySym key_sym, XModifierKeymap *modmap) { - int m; - int c; - KeyCode key_code; - - // if key_sym is a modifier, check each of its keycodes - for (m=0; m<8; m++) - { - key_code = modmap->modifiermap[m * modmap->max_keypermod]; - if ((key_code != 0) - && XKeycodeToKeysym(xEvent->xkeymap.display, key_code, 0) == key_sym) - { - for (c=0; cmax_keypermod; c++) - { - if (check_key(xEvent, - modmap->modifiermap[m * modmap->max_keypermod + c])) + char *key_vector; + int by,bi; + + // implementation fails if key_sym is only accessible by a multi-key + // combination, however this is not expected for GNUstep modifier keys; + // to fix implementation, would need to first determine modifier state by + // a first-pass scann of the full key vector, then use the state in place + // of "0" below in XKeycodeToKeysym + key_vector = xEvent->xkeymap.key_vector; + for (by=0; by<32; by++) { + for (bi=0; bi<8; bi++) { + if ((key_vector[by] & (1 << bi)) && + (XKeycodeToKeysym(xEvent->xkeymap.display,by*8+bi,0)==key_sym)) return 1; - } - return 0; // no dice } } - // wasn't a modifier; just check the first keycode for this keysym, - // which ignores other possibilities but that's the best we can do - // w/o XtKeysymToKeycodeList - return check_key(xEvent, XKeysymToKeycode(xEvent->xkeymap.display, key_sym)); + return 0; } @implementation XGServer (EventOps) @@ -1554,10 +1540,30 @@ if (_is_keyboard_initialized == NO) initialize_keyboard (); + /* Process location */ + window = [XGServer _windowWithTag: [[NSApp keyWindow] windowNumber]]; + eventLocation.x = xEvent->xbutton.x; + if (window) + { + eventLocation.y = window->siz_hints.height - xEvent->xbutton.y; + } + else + { + eventLocation.y = xEvent->xbutton.y; + } + + /* Process characters */ + keys = [context->inputServer lookupStringForEvent: (XKeyEvent *)xEvent + window: window + keysym: &keysym]; + + /* Process keycode */ + keyCode = ((XKeyEvent *)xEvent)->keycode; + //ximKeyCode = XKeysymToKeycode([XGServer currentXDisplay],keysym); + /* Process NSFlagsChanged events. We can't use a switch because we are not comparing to constants. Make sure keyCode is not 0 since XIM events can potentially return 0 keyCodes. */ - keysym = XLookupKeysym((XKeyEvent *)xEvent, 0); if (keysym != NoSymbol) { if (keysym == _control_keysyms[0]) @@ -1613,27 +1619,6 @@ /* Process modifiers */ eventFlags = process_modifier_flags (xEvent->xkey.state); - /* Process location */ - window = [XGServer _windowWithTag: [[NSApp keyWindow] windowNumber]]; - eventLocation.x = xEvent->xbutton.x; - if (window) - { - eventLocation.y = window->siz_hints.height - xEvent->xbutton.y; - } - else - { - eventLocation.y = xEvent->xbutton.y; - } - - /* Process characters */ - keys = [context->inputServer lookupStringForEvent: (XKeyEvent *)xEvent - window: window - keysym: &keysym]; - - /* Process keycode */ - keyCode = ((XKeyEvent *)xEvent)->keycode; - //ximKeyCode = XKeysymToKeycode([XGServer currentXDisplay],keysym); - /* Add NSNumericPadKeyMask if the key is in the KeyPad */ if (IsKeypadKey (keysym)) eventFlags = eventFlags | NSNumericPadKeyMask;