mirror of
https://github.com/glfw/glfw.git
synced 2025-10-04 05:36:35 +00:00
Add glfwGetCocoaOpenedFilenames()
This commit is contained in:
parent
d25248343e
commit
ec03b24c71
@ -215,6 +215,20 @@ GLFWAPI CGDirectDisplayID glfwGetCocoaMonitor(GLFWmonitor* monitor);
|
|||||||
* @ingroup native
|
* @ingroup native
|
||||||
*/
|
*/
|
||||||
GLFWAPI id glfwGetCocoaWindow(GLFWwindow* window);
|
GLFWAPI id glfwGetCocoaWindow(GLFWwindow* window);
|
||||||
|
|
||||||
|
/*! @brief Returns the list of filenames that opened the application,
|
||||||
|
* such as by dragging files to the app bundle or through file associations.
|
||||||
|
*
|
||||||
|
* @return A list of strings, null terminated.
|
||||||
|
*
|
||||||
|
* @thread_safety This function may be called from any thread. Access is not
|
||||||
|
* synchronized.
|
||||||
|
*
|
||||||
|
* @since Added in version 3.4.
|
||||||
|
*
|
||||||
|
* @ingroup native
|
||||||
|
*/
|
||||||
|
const char* const* glfwGetCocoaOpenedFilenames(void);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(GLFW_EXPOSE_NATIVE_NSGL)
|
#if defined(GLFW_EXPOSE_NATIVE_NSGL)
|
||||||
|
@ -461,6 +461,20 @@ static GLFWbool initializeTIS(void)
|
|||||||
_glfwRestoreVideoModeNS(_glfw.monitors[i]);
|
_glfwRestoreVideoModeNS(_glfw.monitors[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void)application:(NSApplication *)sender openFiles:(NSArray<NSString *> *)filenames
|
||||||
|
{
|
||||||
|
int len = [filenames count];
|
||||||
|
// Last entry is nil
|
||||||
|
_glfw.ns.openedFilenames = calloc(len + 1, sizeof(char*));
|
||||||
|
|
||||||
|
for (int i = 0; i < len; i++)
|
||||||
|
{
|
||||||
|
NSString* filename = [filenames objectAtIndex:i];
|
||||||
|
const char* filenameStr = [filename UTF8String];
|
||||||
|
_glfw.ns.openedFilenames[i] = _glfw_strdup(filenameStr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@end // GLFWApplicationDelegate
|
@end // GLFWApplicationDelegate
|
||||||
|
|
||||||
|
|
||||||
@ -577,6 +591,16 @@ void _glfwPlatformTerminate(void)
|
|||||||
if (_glfw.ns.keyUpMonitor)
|
if (_glfw.ns.keyUpMonitor)
|
||||||
[NSEvent removeMonitor:_glfw.ns.keyUpMonitor];
|
[NSEvent removeMonitor:_glfw.ns.keyUpMonitor];
|
||||||
|
|
||||||
|
if (_glfw.ns.openedFilenames)
|
||||||
|
{
|
||||||
|
for (char** p = _glfw.ns.openedFilenames; *p; p++)
|
||||||
|
{
|
||||||
|
free(*p);
|
||||||
|
}
|
||||||
|
free(_glfw.ns.openedFilenames);
|
||||||
|
_glfw.ns.openedFilenames = nil;
|
||||||
|
}
|
||||||
|
|
||||||
free(_glfw.ns.clipboardString);
|
free(_glfw.ns.clipboardString);
|
||||||
|
|
||||||
_glfwTerminateNSGL();
|
_glfwTerminateNSGL();
|
||||||
@ -594,3 +618,12 @@ const char* _glfwPlatformGetVersionString(void)
|
|||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
////// GLFW native API //////
|
||||||
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
const char* const* glfwGetCocoaOpenedFilenames(void)
|
||||||
|
{
|
||||||
|
return _glfw.ns.openedFilenames;
|
||||||
|
}
|
||||||
|
@ -148,6 +148,7 @@ typedef struct _GLFWlibraryNS
|
|||||||
double restoreCursorPosX, restoreCursorPosY;
|
double restoreCursorPosX, restoreCursorPosY;
|
||||||
// The window whose disabled cursor mode is active
|
// The window whose disabled cursor mode is active
|
||||||
_GLFWwindow* disabledCursorWindow;
|
_GLFWwindow* disabledCursorWindow;
|
||||||
|
char** openedFilenames;
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
CFBundleRef bundle;
|
CFBundleRef bundle;
|
||||||
|
Loading…
Reference in New Issue
Block a user