mirror of
https://github.com/libsdl-org/SDL.git
synced 2026-02-13 15:23:34 +00:00
emscripten: Prevent fullscreen transitions while one is already in progress.
Fixes #14533.
This commit is contained in:
@@ -480,6 +480,8 @@ static EM_BOOL Emscripten_HandleFullscreenChange(int eventType, const Emscripten
|
||||
{
|
||||
SDL_WindowData *window_data = userData;
|
||||
|
||||
window_data->fullscreen_change_in_progress = false;
|
||||
|
||||
if (fullscreenChangeEvent->isFullscreen) {
|
||||
SDL_SendWindowEvent(window_data->window, SDL_EVENT_WINDOW_ENTER_FULLSCREEN, 0, 0);
|
||||
window_data->fullscreen_mode_flags = 0;
|
||||
|
||||
@@ -674,6 +674,17 @@ static SDL_FullscreenResult Emscripten_SetWindowFullscreen(SDL_VideoDevice *_thi
|
||||
if (window->internal) {
|
||||
data = window->internal;
|
||||
|
||||
if (data->fullscreen_change_in_progress) {
|
||||
return SDL_FULLSCREEN_FAILED;;
|
||||
}
|
||||
|
||||
EmscriptenFullscreenChangeEvent fsevent;
|
||||
if (emscripten_get_fullscreen_status(&fsevent) == EMSCRIPTEN_RESULT_SUCCESS) {
|
||||
if ((fullscreen == SDL_FULLSCREEN_OP_ENTER) == fsevent.isFullscreen) {
|
||||
return SDL_FULLSCREEN_SUCCEEDED; // already there.
|
||||
}
|
||||
}
|
||||
|
||||
if (fullscreen) {
|
||||
EmscriptenFullscreenStrategy strategy;
|
||||
bool is_fullscreen_desktop = !window->fullscreen_exclusive;
|
||||
@@ -704,8 +715,10 @@ static SDL_FullscreenResult Emscripten_SetWindowFullscreen(SDL_VideoDevice *_thi
|
||||
}
|
||||
|
||||
if (res == EMSCRIPTEN_RESULT_SUCCESS) {
|
||||
data->fullscreen_change_in_progress = true; // even on success, this might animate to the new state.
|
||||
return SDL_FULLSCREEN_SUCCEEDED;
|
||||
} else if (res == EMSCRIPTEN_RESULT_DEFERRED) {
|
||||
data->fullscreen_change_in_progress = true;
|
||||
return SDL_FULLSCREEN_PENDING;
|
||||
} else {
|
||||
return SDL_FULLSCREEN_FAILED;
|
||||
|
||||
@@ -46,6 +46,7 @@ struct SDL_WindowData
|
||||
|
||||
Uint32 fullscreen_mode_flags;
|
||||
bool fullscreen_resize;
|
||||
bool fullscreen_change_in_progress;
|
||||
|
||||
bool has_pointer_lock;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user