mirror of
https://github.com/libsdl-org/SDL.git
synced 2026-05-27 10:57:22 +08:00
Fixed trying to grab the mouse when losing keyboard focus
Fixes https://github.com/libsdl-org/SDL/issues/14350
This commit is contained in:
+14
-14
@@ -337,6 +337,20 @@ bool SDL_SetKeyboardFocus(SDL_Window *window)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// See if the current window has lost focus
|
||||||
|
if (keyboard->focus && keyboard->focus != window) {
|
||||||
|
SDL_SendWindowEvent(keyboard->focus, SDL_EVENT_WINDOW_FOCUS_LOST, 0, 0);
|
||||||
|
|
||||||
|
#if !defined(SDL_PLATFORM_IOS) && !defined(SDL_PLATFORM_ANDROID)
|
||||||
|
// Ensures IME compositions are committed
|
||||||
|
if (SDL_TextInputActive(keyboard->focus)) {
|
||||||
|
if (video && video->StopTextInput) {
|
||||||
|
video->StopTextInput(video, keyboard->focus);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif // !SDL_PLATFORM_IOS && !SDL_PLATFORM_ANDROID
|
||||||
|
}
|
||||||
|
|
||||||
if (keyboard->focus && !window) {
|
if (keyboard->focus && !window) {
|
||||||
// We won't get anymore keyboard messages, so reset keyboard state
|
// We won't get anymore keyboard messages, so reset keyboard state
|
||||||
SDL_ResetKeyboard();
|
SDL_ResetKeyboard();
|
||||||
@@ -355,20 +369,6 @@ bool SDL_SetKeyboardFocus(SDL_Window *window)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// See if the current window has lost focus
|
|
||||||
if (keyboard->focus && keyboard->focus != window) {
|
|
||||||
SDL_SendWindowEvent(keyboard->focus, SDL_EVENT_WINDOW_FOCUS_LOST, 0, 0);
|
|
||||||
|
|
||||||
#if !defined(SDL_PLATFORM_IOS) && !defined(SDL_PLATFORM_ANDROID)
|
|
||||||
// Ensures IME compositions are committed
|
|
||||||
if (SDL_TextInputActive(keyboard->focus)) {
|
|
||||||
if (video && video->StopTextInput) {
|
|
||||||
video->StopTextInput(video, keyboard->focus);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif // !SDL_PLATFORM_IOS && !SDL_PLATFORM_ANDROID
|
|
||||||
}
|
|
||||||
|
|
||||||
keyboard->focus = window;
|
keyboard->focus = window;
|
||||||
|
|
||||||
if (keyboard->focus) {
|
if (keyboard->focus) {
|
||||||
|
|||||||
@@ -77,9 +77,6 @@ bool SDL_SendWindowEvent(SDL_Window *window, SDL_EventType windowevent, int data
|
|||||||
}
|
}
|
||||||
SDL_assert(SDL_ObjectValid(window, SDL_OBJECT_TYPE_WINDOW));
|
SDL_assert(SDL_ObjectValid(window, SDL_OBJECT_TYPE_WINDOW));
|
||||||
|
|
||||||
if (window->is_destroying && windowevent != SDL_EVENT_WINDOW_DESTROYED) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
switch (windowevent) {
|
switch (windowevent) {
|
||||||
case SDL_EVENT_WINDOW_SHOWN:
|
case SDL_EVENT_WINDOW_SHOWN:
|
||||||
if (!(window->flags & SDL_WINDOW_HIDDEN)) {
|
if (!(window->flags & SDL_WINDOW_HIDDEN)) {
|
||||||
@@ -219,6 +216,10 @@ bool SDL_SendWindowEvent(SDL_Window *window, SDL_EventType windowevent, int data
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (window->is_destroying && windowevent != SDL_EVENT_WINDOW_DESTROYED) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
// Post the event, if desired
|
// Post the event, if desired
|
||||||
SDL_Event event;
|
SDL_Event event;
|
||||||
event.type = windowevent;
|
event.type = windowevent;
|
||||||
|
|||||||
Reference in New Issue
Block a user