|
@@ -746,10 +746,17 @@ SDL_GetKeyboardFocus(void)
|
|
|
return keyboard->focus;
|
|
|
}
|
|
|
|
|
|
-void SDL_SetKeyboardFocus(SDL_Window *window)
|
|
|
+int SDL_SetKeyboardFocus(SDL_Window *window)
|
|
|
{
|
|
|
+ SDL_VideoDevice *video = SDL_GetVideoDevice();
|
|
|
SDL_Keyboard *keyboard = &SDL_keyboard;
|
|
|
|
|
|
+ if (window) {
|
|
|
+ if (!video || window->magic != &video->window_magic || window->is_destroying) {
|
|
|
+ return SDL_SetError("Invalid window");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
if (keyboard->focus && window == NULL) {
|
|
|
/* We won't get anymore keyboard messages, so reset keyboard state */
|
|
|
SDL_ResetKeyboard();
|
|
@@ -773,7 +780,6 @@ void SDL_SetKeyboardFocus(SDL_Window *window)
|
|
|
|
|
|
/* Ensures IME compositions are committed */
|
|
|
if (SDL_EventEnabled(SDL_EVENT_TEXT_INPUT)) {
|
|
|
- SDL_VideoDevice *video = SDL_GetVideoDevice();
|
|
|
if (video && video->StopTextInput) {
|
|
|
video->StopTextInput(video);
|
|
|
}
|
|
@@ -793,6 +799,7 @@ void SDL_SetKeyboardFocus(SDL_Window *window)
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+ return 0;
|
|
|
}
|
|
|
|
|
|
static int SDL_SendKeyboardKeyInternal(Uint64 timestamp, SDL_KeyboardFlags flags, Uint8 state, SDL_Scancode scancode, SDL_Keycode keycode)
|