diff options
author | Erik Kundiman <erik@megapahit.org> | 2024-01-15 11:30:07 +0800 |
---|---|---|
committer | Erik Kundiman <erik@megapahit.org> | 2024-01-15 11:30:07 +0800 |
commit | 5bd49e68abdfef034f959abf71209535460441c3 (patch) | |
tree | e4f3c3aa5bc6a70b751443a6b237cbbf2b8f07f4 /indra/llwindow | |
parent | 52d27ba16c4682901d0028fd637d231e783f858f (diff) |
Revive external web browser spawning on macOS
Diffstat (limited to 'indra/llwindow')
-rw-r--r-- | indra/llwindow/llwindowsdl.cpp | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/indra/llwindow/llwindowsdl.cpp b/indra/llwindow/llwindowsdl.cpp index 4a1fb899a4..607e3f3782 100644 --- a/indra/llwindow/llwindowsdl.cpp +++ b/indra/llwindow/llwindowsdl.cpp @@ -72,6 +72,7 @@ static bool ATIbug = false; #include <OpenGL/OpenGL.h> #include <CoreGraphics/CGDirectDisplay.h> +#include <CoreServices/CoreServices.h> BOOL gHiDPISupport = TRUE; @@ -2730,6 +2731,42 @@ void LLWindowSDL::spawnWebBrowser(const std::string& escaped_url, bool async) cmd += "launch_url.sh"; arg = escaped_url; exec_cmd(cmd, arg); + +#elif LL_DARWIN + + S32 result = 0; + CFURLRef urlRef = NULL; + + LL_INFOS() << "Opening URL " << escaped_url << LL_ENDL; + + CFStringRef stringRef = CFStringCreateWithCString(NULL, escaped_url.c_str(), kCFStringEncodingUTF8); + if (stringRef) + { + // This will succeed if the string is a full URL, including the http:// + // Note that URLs specified this way need to be properly percent-escaped. + urlRef = CFURLCreateWithString(NULL, stringRef, NULL); + + // Don't use CRURLCreateWithFileSystemPath -- only want valid URLs + + CFRelease(stringRef); + } + + if (urlRef) + { + result = LSOpenCFURLRef(urlRef, NULL); + + if (result != noErr) + { + LL_INFOS() << "Error " << result << " on open." << LL_ENDL; + } + + CFRelease(urlRef); + } + else + { + LL_INFOS() << "Error: couldn't create URL." << LL_ENDL; + } + #endif // LL_LINUX LL_INFOS() << "spawn_web_browser returning." << LL_ENDL; |