Skip to content

Commit

Permalink
Port cocoa backend to use new drop API
Browse files Browse the repository at this point in the history
  • Loading branch information
kovidgoyal committed Mar 19, 2020
1 parent 2458c3a commit ab9a36f
Showing 1 changed file with 4 additions and 11 deletions.
15 changes: 4 additions & 11 deletions glfw/cocoa_window.m
Original file line number Diff line number Diff line change
Expand Up @@ -1159,27 +1159,20 @@ - (BOOL)performDragOperation:(id <NSDraggingInfo>)sender
const NSUInteger count = [objs count];
if (count)
{
char** paths = calloc(count, sizeof(char*));

for (NSUInteger i = 0; i < count; i++)
{
id obj = objs[i];
if ([obj isKindOfClass:[NSURL class]]) {
paths[i] = _glfw_strdup([obj fileSystemRepresentation]);
const char *path = [obj fileSystemRepresentation];
_glfwInputDrop(window, "text/uri-list", path, strlen(path));
} else if ([obj isKindOfClass:[NSString class]]) {
paths[i] = _glfw_strdup([obj UTF8String]);
const char *text = [obj UTF8String];
_glfwInputDrop(window, "text/plain;charset=utf-8", text, strlen(text));
} else {
_glfwInputError(GLFW_PLATFORM_ERROR,
"Cocoa: Object is neither a URL nor a string");
paths[i] = _glfw_strdup("");
}
}

_glfwInputDrop(window, (int) count, (const char**) paths);

for (NSUInteger i = 0; i < count; i++)
free(paths[i]);
free(paths);
}

return YES;
Expand Down

0 comments on commit ab9a36f

Please sign in to comment.