Mercurial > sdl-ios-xcode
diff src/video/x11/SDL_x11events.c @ 2325:c7bcf84ba1b9
Next version of internationalized input for X11. On my machine (famous last words :-) with a US English keyboard and locale I can compose ` and e and get a text
input event with the character รจ. You still get the keypress keyrelease events for the individual keys that go into composing the character.
author | Bob Pendleton <bob@pendleton.com> |
---|---|
date | Fri, 07 Mar 2008 20:54:11 +0000 |
parents | 3202e4826c57 |
children | 133562468ff2 |
line wrap: on
line diff
--- a/src/video/x11/SDL_x11events.c Fri Mar 07 17:20:37 2008 +0000 +++ b/src/video/x11/SDL_x11events.c Fri Mar 07 20:54:11 2008 +0000 @@ -1,3 +1,4 @@ +#define DEBUG_XEVENTS /* SDL - Simple DirectMedia Layer Copyright (C) 1997-2006 Sam Lantinga @@ -40,6 +41,15 @@ SDL_zero(xevent); /* valgrind fix. --ryan. */ XNextEvent(videodata->display, &xevent); + /* filter events catchs XIM events and sends them to the correct + handler */ + if (XFilterEvent(&xevent, None) == True) { +#ifdef DEBUG_XEVENTS + printf("Filtered event of type = 0x%X\n", xevent.type); +#endif + return; + } + /* Send a SDL_SYSWMEVENT if the application wants them */ if (SDL_ProcessEvents[SDL_SYSWMEVENT] == SDL_ENABLE) { SDL_SysWMmsg wmmsg; @@ -182,14 +192,14 @@ KeyCode keycode = xevent.xkey.keycode; KeySym keysym = NoSymbol; char text[SDL_TEXTINPUTEVENT_TEXT_SIZE]; - Uint32 ucs4 = 0; + Status status = 0; #ifdef DEBUG_XEVENTS printf("KeyPress (X11 keycode = 0x%X)\n", xevent.xkey.keycode); #endif SDL_SendKeyboardKey(videodata->keyboard, SDL_PRESSED, videodata->key_layout[keycode]); -#if 1 +#if 0 if (videodata->key_layout[keycode] == SDLK_UNKNOWN) { int min_keycode, max_keycode; XDisplayKeycodes(videodata->display, &min_keycode, @@ -201,9 +211,16 @@ XKeysymToString(keysym)); } #endif - /* Xutf8LookupString(), works for Latin-1 */ + /* */ SDL_zero(text); +#ifdef X_HAVE_UTF8_STRING + if (data->ic) { + Xutf8LookupString(data->ic, &xevent.xkey, text, sizeof(text), + &keysym, status); + } +#else XLookupString(&xevent.xkey, text, sizeof(text), &keysym, NULL); +#endif if (*text) { printf("Sending text event %s\n", text); SDL_SendKeyboardText(videodata->keyboard, text);