From e3106eaa2a7eb0c9ff042b67d5660950b36bdd48 Mon Sep 17 00:00:00 2001 From: WerWolv Date: Fri, 10 Dec 2021 16:10:34 +0100 Subject: [PATCH] ux: Use native APIs to open websites to prevent terminal from appearing --- plugins/libimhex/source/helpers/utils.cpp | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/plugins/libimhex/source/helpers/utils.cpp b/plugins/libimhex/source/helpers/utils.cpp index 9a7ac7433..84cb2bedf 100644 --- a/plugins/libimhex/source/helpers/utils.cpp +++ b/plugins/libimhex/source/helpers/utils.cpp @@ -7,6 +7,13 @@ #include +#if defined(OS_WINDOWS) + #include +#elif defined(OS_MACOS) + #include + #include +#endif + namespace hex { std::string to_string(u128 value) { @@ -173,9 +180,11 @@ namespace hex { url = "https://" + url; #if defined(OS_WINDOWS) - system(hex::format("start {0}", url).c_str()); + ShellExecute(nullptr, "open", url.c_str(), nullptr, nullptr, SW_SHOWNORMAL); #elif defined(OS_MACOS) - system(hex::format("open {0}", url).c_str()); + CFURLRef urlRef = CFURLCreateWithBytes(nullptr, reinterpret_cast(url.data()), url.length(), kCFStringEncodingASCII, nullptr); + LSOpenCFURLRef(urlRef, nullptr); + CFRelease(urlRef); #elif defined(OS_LINUX) system(hex::format("xdg-open {0}", url).c_str()); #else