mirror of
https://github.com/libsdl-org/SDL.git
synced 2025-09-29 14:38:29 +00:00
Emscripten: Fix Emscripten_GetFocusedWindow
Ensure a window is focused if the DOM is focused
This commit is contained in:
@@ -286,6 +286,16 @@ static SDL_Window *Emscripten_GetFocusedWindow(SDL_VideoDevice *device)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// If the DOM is focused, then at least one canvas in the DOM should be considered focused.
|
||||||
|
// So in this case, just assume that the first canvas is focused.
|
||||||
|
if (!window) {
|
||||||
|
const int focused = MAIN_THREAD_EM_ASM_INT({
|
||||||
|
return document.hasFocus();
|
||||||
|
});
|
||||||
|
if (focused) {
|
||||||
|
window = device->windows;
|
||||||
|
}
|
||||||
|
}
|
||||||
return window;
|
return window;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user