You need to add another event here:
Check for SDL_WINDOWEVENT_FOCUS_GAINED instead of the “not-Emscripten” part.
SDL_WINDOWEVENT_FOCUS_GAINED