Windows: Don't freeze the UI thread for a sec while launching a URL

This commit is contained in:
Henrik Rydgård committed 2025-05-20 00:19:06 +02:00
1 parent 48852ed81d
commit 1056547c70
1 file changed
+6 -1
+6 -1
View File
@@ -133,7 +133,12 @@ static double g_lastKeepAwake = 0.0;
static constexpr double ACTIVITY_IDLE_TIMEOUT = 2.0 * 3600.0;
void System_LaunchUrl(LaunchUrlType urlType, const char *url) {
ShellExecute(NULL, L"open", ConvertUTF8ToWString(url).c_str(), NULL, NULL, SW_SHOWNORMAL);
std::string u(url);
std::thread t = std::thread([u]() {
ShellExecute(NULL, L"open", ConvertUTF8ToWString(u).c_str(), NULL, NULL, SW_SHOWNORMAL);
});
// Detach is bad (given exit behavior), but in this case all the thread does is a ShellExecute to avoid freezing the caller while it runs, so it's safe.
t.detach();
}
void System_Vibrate(int length_ms) {