Skip to content
This repository has been archived by the owner on Feb 11, 2021. It is now read-only.

Commit

Permalink
Fixed crash on systems that don't have StopTextInput
Browse files Browse the repository at this point in the history
  • Loading branch information
slouken committed Sep 19, 2010
1 parent 750be4e commit 5aa094a
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions src/events/SDL_keyboard.c
Expand Up @@ -612,11 +612,14 @@ SDL_SetKeyboardFocus(SDL_Window * window)
if (keyboard->focus && keyboard->focus != window) {
SDL_SendWindowEvent(keyboard->focus, SDL_WINDOWEVENT_FOCUS_LOST,
0, 0);

//Ensures IME compositions are committed
if (SDL_EventState(SDL_TEXTINPUT, SDL_QUERY)) {
SDL_GetVideoDevice()->StopTextInput(SDL_GetVideoDevice());
}

/* Ensures IME compositions are committed */
if (SDL_EventState(SDL_TEXTINPUT, SDL_QUERY)) {
SDL_VideoDevice *video = SDL_GetVideoDevice();
if (video && video->StopTextInput) {
video->StopTextInput(video);
}
}
}

keyboard->focus = window;
Expand All @@ -626,7 +629,10 @@ SDL_SetKeyboardFocus(SDL_Window * window)
0, 0);

if (SDL_EventState(SDL_TEXTINPUT, SDL_QUERY)) {
SDL_StartTextInput();
SDL_VideoDevice *video = SDL_GetVideoDevice();
if (video && video->StartTextInput) {
video->StartTextInput(video);
}
}
}
}
Expand Down

0 comments on commit 5aa094a

Please sign in to comment.