mirror of
				https://github.com/ocornut/imgui.git
				synced 2025-11-04 01:34:32 +00:00 
			
		
		
		
	+ Enable on non-iPhone macOS builds
This commit is contained in:
		
							
								
								
									
										37
									
								
								imgui.cpp
									
									
									
									
									
								
							
							
						
						
									
										37
									
								
								imgui.cpp
									
									
									
									
									
								
							@@ -14353,11 +14353,18 @@ static void SetClipboardTextFn_DefaultImpl(void* user_data_ctx, const char* text
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
//-----------------------------------------------------------------------------
 | 
					//-----------------------------------------------------------------------------
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#if defined(__APPLE__) && defined(TARGET_OS_IPHONE) && !defined(IMGUI_DISABLE_DEFAULT_SHELL_FUNCTIONS)
 | 
					#ifndef IMGUI_DISABLE_DEFAULT_SHELL_FUNCTIONS
 | 
				
			||||||
 | 
					#if defined(__APPLE__) && TARGET_OS_IPHONE
 | 
				
			||||||
#define IMGUI_DISABLE_DEFAULT_SHELL_FUNCTIONS
 | 
					#define IMGUI_DISABLE_DEFAULT_SHELL_FUNCTIONS
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#if defined(_WIN32) && !defined(IMGUI_DISABLE_WIN32_FUNCTIONS) && !defined(IMGUI_DISABLE_DEFAULT_SHELL_FUNCTIONS)
 | 
					#if defined(_WIN32) && defined(IMGUI_DISABLE_WIN32_FUNCTIONS)
 | 
				
			||||||
 | 
					#define IMGUI_DISABLE_DEFAULT_SHELL_FUNCTIONS
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#ifndef IMGUI_DISABLE_DEFAULT_SHELL_FUNCTIONS
 | 
				
			||||||
 | 
					#ifdef _WIN32
 | 
				
			||||||
#include <shellapi.h>   // ShellExecuteA()
 | 
					#include <shellapi.h>   // ShellExecuteA()
 | 
				
			||||||
#ifdef _MSC_VER
 | 
					#ifdef _MSC_VER
 | 
				
			||||||
#pragma comment(lib, "shell32")
 | 
					#pragma comment(lib, "shell32")
 | 
				
			||||||
@@ -14366,18 +14373,32 @@ static bool PlatformOpenInShellFn_DefaultImpl(ImGuiContext*, const char* path)
 | 
				
			|||||||
{
 | 
					{
 | 
				
			||||||
    return (INT_PTR)::ShellExecuteA(NULL, "open", path, NULL, NULL, SW_SHOWDEFAULT) > 32;
 | 
					    return (INT_PTR)::ShellExecuteA(NULL, "open", path, NULL, NULL, SW_SHOWDEFAULT) > 32;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
#elif !defined(IMGUI_DISABLE_DEFAULT_SHELL_FUNCTIONS)
 | 
					#else
 | 
				
			||||||
 | 
					#include <sys/wait.h>
 | 
				
			||||||
 | 
					#include <unistd.h>
 | 
				
			||||||
static bool PlatformOpenInShellFn_DefaultImpl(ImGuiContext*, const char* path)
 | 
					static bool PlatformOpenInShellFn_DefaultImpl(ImGuiContext*, const char* path)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
#if __APPLE__
 | 
					#if __APPLE__
 | 
				
			||||||
    const char* open_executable = "open";
 | 
					    const char* args[] { "open", "--", path, NULL };
 | 
				
			||||||
#else
 | 
					#else
 | 
				
			||||||
    const char* open_executable = "xdg-open";
 | 
					    const char* args[] { "xdg-open", path, NULL };
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
    ImGuiTextBuffer buf;
 | 
					    pid_t pid = fork();
 | 
				
			||||||
    buf.appendf("%s \"%s\"", open_executable, path);
 | 
					    if (pid < 0)
 | 
				
			||||||
    return system(buf.c_str()) != -1;
 | 
					        return false;
 | 
				
			||||||
 | 
					    if (!pid)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        execvp(args[0], const_cast<char **>(args));
 | 
				
			||||||
 | 
					        exit(-1);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					    else
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        int status;
 | 
				
			||||||
 | 
					        waitpid(pid, &status, 0);
 | 
				
			||||||
 | 
					        return WEXITSTATUS(status) == 0;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
#else
 | 
					#else
 | 
				
			||||||
static bool PlatformOpenInShellFn_DefaultImpl(ImGuiContext*, const char*) { return false; }
 | 
					static bool PlatformOpenInShellFn_DefaultImpl(ImGuiContext*, const char*) { return false; }
 | 
				
			||||||
#endif // Default shell handlers
 | 
					#endif // Default shell handlers
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user