comparison src/events/SDL_keyboard.c @ 4890:443771460df9

Fixed crash on systems that don't have StopTextInput
author Sam Lantinga <slouken@libsdl.org>
date Sat, 18 Sep 2010 18:31:01 -0700
parents e725a6a60c32
children 25d4feb7c127
comparison
equal deleted inserted replaced
4889:8c9cbb623d55 4890:443771460df9
611 /* See if the current window has lost focus */ 611 /* See if the current window has lost focus */
612 if (keyboard->focus && keyboard->focus != window) { 612 if (keyboard->focus && keyboard->focus != window) {
613 SDL_SendWindowEvent(keyboard->focus, SDL_WINDOWEVENT_FOCUS_LOST, 613 SDL_SendWindowEvent(keyboard->focus, SDL_WINDOWEVENT_FOCUS_LOST,
614 0, 0); 614 0, 0);
615 615
616 //Ensures IME compositions are committed 616 /* Ensures IME compositions are committed */
617 if (SDL_EventState(SDL_TEXTINPUT, SDL_QUERY)) { 617 if (SDL_EventState(SDL_TEXTINPUT, SDL_QUERY)) {
618 SDL_GetVideoDevice()->StopTextInput(SDL_GetVideoDevice()); 618 SDL_VideoDevice *video = SDL_GetVideoDevice();
619 if (video && video->StopTextInput) {
620 video->StopTextInput(video);
621 }
619 } 622 }
620 } 623 }
621 624
622 keyboard->focus = window; 625 keyboard->focus = window;
623 626
624 if (keyboard->focus) { 627 if (keyboard->focus) {
625 SDL_SendWindowEvent(keyboard->focus, SDL_WINDOWEVENT_FOCUS_GAINED, 628 SDL_SendWindowEvent(keyboard->focus, SDL_WINDOWEVENT_FOCUS_GAINED,
626 0, 0); 629 0, 0);
627 630
628 if (SDL_EventState(SDL_TEXTINPUT, SDL_QUERY)) { 631 if (SDL_EventState(SDL_TEXTINPUT, SDL_QUERY)) {
629 SDL_StartTextInput(); 632 SDL_VideoDevice *video = SDL_GetVideoDevice();
633 if (video && video->StartTextInput) {
634 video->StartTextInput(video);
635 }
630 } 636 }
631 } 637 }
632 } 638 }
633 639
634 int 640 int