TextLinkOpenURL(): fixed default Win32 io.PlatformOpenInShellFn handler to handle UTF-8 regardless of system regional settings. (#7660)

This commit is contained in:
ocornut
2025-02-10 12:02:01 +01:00
parent 2206e31e54
commit a18622c369
4 changed files with 11 additions and 2 deletions

View File

@@ -57,6 +57,8 @@ Other changes:
which amusingly made it disappear when using very big font/frame size. which amusingly made it disappear when using very big font/frame size.
- Tables: fixed calling SetNextWindowScroll() on clipped scrolling table - Tables: fixed calling SetNextWindowScroll() on clipped scrolling table
to not leak the value into a subsequent window. (#8196) to not leak the value into a subsequent window. (#8196)
- TextLinkOpenURL(): fixed default Win32 io.PlatformOpenInShellFn handler to
handle UTF-8 regardless of system regional settings. (#7660) [@achabense]
- Demo: Combos: demonstrate a very simple way to add a filter to a combo, - Demo: Combos: demonstrate a very simple way to add a filter to a combo,
by showing the filter inside the combo contents. (#718) by showing the filter inside the combo contents. (#718)
- Backends: Metal: Fixed a crash on application resources. (#8367, #7419) [@anszom] - Backends: Metal: Fixed a crash on application resources. (#8367, #7419) [@anszom]

View File

@@ -15090,7 +15090,11 @@ static void Platform_SetClipboardTextFn_DefaultImpl(ImGuiContext* ctx, const cha
#endif #endif
static bool Platform_OpenInShellFn_DefaultImpl(ImGuiContext*, const char* path) static bool Platform_OpenInShellFn_DefaultImpl(ImGuiContext*, const char* path)
{ {
return (INT_PTR)::ShellExecuteA(NULL, "open", path, NULL, NULL, SW_SHOWDEFAULT) > 32; const int path_wsize = ::MultiByteToWideChar(CP_UTF8, 0, path, -1, NULL, 0);
ImVector<wchar_t> path_wbuf;
path_wbuf.resize(path_wsize);
::MultiByteToWideChar(CP_UTF8, 0, path, -1, path_wbuf.Data, path_wsize);
return (INT_PTR)::ShellExecuteW(NULL, L"open", path_wbuf.Data, NULL, NULL, SW_SHOWDEFAULT) > 32;
} }
#else #else
#include <sys/wait.h> #include <sys/wait.h>

View File

@@ -3565,7 +3565,7 @@ struct ImGuiPlatformIO
void* Platform_ClipboardUserData; void* Platform_ClipboardUserData;
// Optional: Open link/folder/file in OS Shell // Optional: Open link/folder/file in OS Shell
// (default to use ShellExecuteA() on Windows, system() on Linux/Mac) // (default to use ShellExecuteW() on Windows, system() on Linux/Mac)
bool (*Platform_OpenInShellFn)(ImGuiContext* ctx, const char* path); bool (*Platform_OpenInShellFn)(ImGuiContext* ctx, const char* path);
void* Platform_OpenInShellUserData; void* Platform_OpenInShellUserData;

View File

@@ -7771,6 +7771,9 @@ void ImGui::ShowAboutWindow(bool* p_open)
#ifdef IMGUI_DISABLE_WIN32_FUNCTIONS #ifdef IMGUI_DISABLE_WIN32_FUNCTIONS
ImGui::Text("define: IMGUI_DISABLE_WIN32_FUNCTIONS"); ImGui::Text("define: IMGUI_DISABLE_WIN32_FUNCTIONS");
#endif #endif
#ifdef IMGUI_DISABLE_DEFAULT_SHELL_FUNCTIONS
ImGui::Text("define: IMGUI_DISABLE_DEFAULT_SHELL_FUNCTIONS");
#endif
#ifdef IMGUI_DISABLE_DEFAULT_FORMAT_FUNCTIONS #ifdef IMGUI_DISABLE_DEFAULT_FORMAT_FUNCTIONS
ImGui::Text("define: IMGUI_DISABLE_DEFAULT_FORMAT_FUNCTIONS"); ImGui::Text("define: IMGUI_DISABLE_DEFAULT_FORMAT_FUNCTIONS");
#endif #endif