src/video/x11/SDL_x11events.c
changeset 2325 c7bcf84ba1b9
parent 2324 3202e4826c57
child 2326 133562468ff2
     1.1 --- a/src/video/x11/SDL_x11events.c	Fri Mar 07 17:20:37 2008 +0000
     1.2 +++ b/src/video/x11/SDL_x11events.c	Fri Mar 07 20:54:11 2008 +0000
     1.3 @@ -1,3 +1,4 @@
     1.4 +#define DEBUG_XEVENTS
     1.5  /*
     1.6      SDL - Simple DirectMedia Layer
     1.7      Copyright (C) 1997-2006 Sam Lantinga
     1.8 @@ -40,6 +41,15 @@
     1.9      SDL_zero(xevent);           /* valgrind fix. --ryan. */
    1.10      XNextEvent(videodata->display, &xevent);
    1.11  
    1.12 +    /* filter events catchs XIM events and sends them to the correct
    1.13 +       handler */
    1.14 +    if (XFilterEvent(&xevent, None) == True) {
    1.15 +#ifdef DEBUG_XEVENTS
    1.16 +        printf("Filtered event of type = 0x%X\n", xevent.type);
    1.17 +#endif
    1.18 +        return;
    1.19 +    }
    1.20 +
    1.21      /* Send a SDL_SYSWMEVENT if the application wants them */
    1.22      if (SDL_ProcessEvents[SDL_SYSWMEVENT] == SDL_ENABLE) {
    1.23          SDL_SysWMmsg wmmsg;
    1.24 @@ -182,14 +192,14 @@
    1.25              KeyCode keycode = xevent.xkey.keycode;
    1.26              KeySym keysym = NoSymbol;
    1.27              char text[SDL_TEXTINPUTEVENT_TEXT_SIZE];
    1.28 -            Uint32 ucs4 = 0;
    1.29 +            Status status = 0;
    1.30  
    1.31  #ifdef DEBUG_XEVENTS
    1.32              printf("KeyPress (X11 keycode = 0x%X)\n", xevent.xkey.keycode);
    1.33  #endif
    1.34              SDL_SendKeyboardKey(videodata->keyboard, SDL_PRESSED,
    1.35                                  videodata->key_layout[keycode]);
    1.36 -#if 1
    1.37 +#if 0
    1.38              if (videodata->key_layout[keycode] == SDLK_UNKNOWN) {
    1.39                  int min_keycode, max_keycode;
    1.40                  XDisplayKeycodes(videodata->display, &min_keycode,
    1.41 @@ -201,9 +211,16 @@
    1.42                          XKeysymToString(keysym));
    1.43              }
    1.44  #endif
    1.45 -            /* Xutf8LookupString(), works for Latin-1 */
    1.46 +            /* */
    1.47              SDL_zero(text);
    1.48 +#ifdef X_HAVE_UTF8_STRING
    1.49 +            if (data->ic) {
    1.50 +                Xutf8LookupString(data->ic, &xevent.xkey, text, sizeof(text),
    1.51 +                                  &keysym, status);
    1.52 +            }
    1.53 +#else
    1.54              XLookupString(&xevent.xkey, text, sizeof(text), &keysym, NULL);
    1.55 +#endif
    1.56              if (*text) {
    1.57                  printf("Sending text event %s\n", text);
    1.58                  SDL_SendKeyboardText(videodata->keyboard, text);