From 6c8f2227cdc01c978ec1cbf08a93925e148175b8 Mon Sep 17 00:00:00 2001 From: embeddedt <42941056+embeddedt@users.noreply.github.com> Date: Mon, 8 Feb 2021 13:18:30 -0500 Subject: Fix: [Emscripten] open links in browser (#8655) --- src/os/unix/unix.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'src/os/unix') diff --git a/src/os/unix/unix.cpp b/src/os/unix/unix.cpp index 4b94539b0..9ef2bc386 100644 --- a/src/os/unix/unix.cpp +++ b/src/os/unix/unix.cpp @@ -28,6 +28,10 @@ #include #endif +#ifdef __EMSCRIPTEN__ +# include +#endif + #ifdef __APPLE__ # include #elif (defined(_POSIX_VERSION) && _POSIX_VERSION >= 200112L) || defined(__GLIBC__) @@ -288,7 +292,13 @@ bool GetClipboardContents(char *buffer, const char *last) #endif -#ifndef __APPLE__ +#if defined(__EMSCRIPTEN__) +void OSOpenBrowser(const char *url) +{ + /* Implementation in pre.js */ + EM_ASM({ if(window["openttd_open_url"]) window.openttd_open_url($0, $1) }, url, strlen(url)); +} +#elif !defined( __APPLE__) void OSOpenBrowser(const char *url) { pid_t child_pid = fork(); -- cgit v1.2.3-70-g09d2