Commit eaca5187 authored by Sam Lantinga's avatar Sam Lantinga

Fixed crash on systems that don't have StopTextInput

parent 7fcd8b75
...@@ -612,11 +612,14 @@ SDL_SetKeyboardFocus(SDL_Window * window) ...@@ -612,11 +612,14 @@ SDL_SetKeyboardFocus(SDL_Window * window)
if (keyboard->focus && keyboard->focus != window) { if (keyboard->focus && keyboard->focus != window) {
SDL_SendWindowEvent(keyboard->focus, SDL_WINDOWEVENT_FOCUS_LOST, SDL_SendWindowEvent(keyboard->focus, SDL_WINDOWEVENT_FOCUS_LOST,
0, 0); 0, 0);
//Ensures IME compositions are committed /* Ensures IME compositions are committed */
if (SDL_EventState(SDL_TEXTINPUT, SDL_QUERY)) { if (SDL_EventState(SDL_TEXTINPUT, SDL_QUERY)) {
SDL_GetVideoDevice()->StopTextInput(SDL_GetVideoDevice()); SDL_VideoDevice *video = SDL_GetVideoDevice();
} if (video && video->StopTextInput) {
video->StopTextInput(video);
}
}
} }
keyboard->focus = window; keyboard->focus = window;
...@@ -626,7 +629,10 @@ SDL_SetKeyboardFocus(SDL_Window * window) ...@@ -626,7 +629,10 @@ SDL_SetKeyboardFocus(SDL_Window * window)
0, 0); 0, 0);
if (SDL_EventState(SDL_TEXTINPUT, SDL_QUERY)) { if (SDL_EventState(SDL_TEXTINPUT, SDL_QUERY)) {
SDL_StartTextInput(); SDL_VideoDevice *video = SDL_GetVideoDevice();
if (video && video->StartTextInput) {
video->StartTextInput(video);
}
} }
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment