# HG changeset patch # User Sam Lantinga # Date 1271395621 25200 # Node ID e953700da4ca653a793c641ea706db93bff3c0c8 # Parent 5c64052fb4761f2079f2c8098fbf32210d83742f Minor cleanup on Jiang's patch diff -r 5c64052fb476 -r e953700da4ca include/SDL_events.h --- a/include/SDL_events.h Thu Apr 15 22:14:26 2010 -0700 +++ b/include/SDL_events.h Thu Apr 15 22:27:01 2010 -0700 @@ -139,6 +139,7 @@ { Uint32 type; /**< ::SDL_TEXTEDITING */ Uint32 windowID; /**< The window with keyboard focus, if any */ + Uint8 which; /**< The keyboard device index */ char text[SDL_TEXTEDITINGEVENT_TEXT_SIZE]; /**< The editing text */ int start; /**< The start cursor of selected editing text */ int length; /**< The length of selected editing text */ diff -r 5c64052fb476 -r e953700da4ca src/events/SDL_keyboard.c --- a/src/events/SDL_keyboard.c Thu Apr 15 22:14:26 2010 -0700 +++ b/src/events/SDL_keyboard.c Thu Apr 15 22:27:01 2010 -0700 @@ -679,8 +679,10 @@ if (keyboard->focus) { SDL_SendWindowEvent(keyboard->focus, SDL_WINDOWEVENT_FOCUS_GAINED, 0, 0); - if (SDL_EventState(SDL_TEXTINPUT, SDL_QUERY)) + + if (SDL_EventState(SDL_TEXTINPUT, SDL_QUERY)) { SDL_StartTextInput(); + } } } @@ -832,6 +834,7 @@ if (SDL_GetEventState(SDL_TEXTINPUT) == SDL_ENABLE) { SDL_Event event; event.text.type = SDL_TEXTINPUT; + event.text.windowID = keyboard->focus ? keyboard->focus->id : 0; event.text.which = (Uint8) index; SDL_strlcpy(event.text.text, text, SDL_arraysize(event.text.text)); event.text.windowID = keyboard->focus->id; @@ -846,18 +849,20 @@ SDL_Keyboard *keyboard = SDL_GetKeyboard(index); int posted; - if (!keyboard) + if (!keyboard) { return 0; + } /* Post the event, if desired */ posted = 0; if (SDL_GetEventState(SDL_TEXTEDITING) == SDL_ENABLE) { SDL_Event event; event.edit.type = SDL_TEXTEDITING; + event.edit.windowID = keyboard->focus ? keyboard->focus->id : 0; + event.text.which = (Uint8) index; event.edit.start = start; event.edit.length = length; - SDL_strlcpy(event.edit.text, text, SDL_arraysize(event.text.text)); - event.edit.windowID = keyboard->focus->id; + SDL_strlcpy(event.edit.text, text, SDL_arraysize(event.edit.text)); posted = (SDL_PushEvent(&event) > 0); } return (posted); diff -r 5c64052fb476 -r e953700da4ca src/video/cocoa/SDL_cocoakeyboard.m --- a/src/video/cocoa/SDL_cocoakeyboard.m Thu Apr 15 22:14:26 2010 -0700 +++ b/src/video/cocoa/SDL_cocoakeyboard.m Thu Apr 15 22:27:01 2010 -0700 @@ -638,13 +638,14 @@ * than one copy. When we switched to another window and requesting for * text input, simply remove the field editor from its superview then add * it to the front most window's content view */ - if (! data->fieldEdit) + if (!data->fieldEdit) { data->fieldEdit = [[SDLTranslatorResponder alloc] initWithFrame: NSMakeRect(0.0, 0.0, 0.0, 0.0)]; + } [data->fieldEdit setKeyboard: data->keyboard]; - if (! [[data->fieldEdit superview] isEqual: parentView]) + if (![[data->fieldEdit superview] isEqual: parentView]) { // DEBUG_IME(@"add fieldEdit to window contentView"); [data->fieldEdit removeFromSuperview];