diff --git a/glfw/cocoa_window.m b/glfw/cocoa_window.m index 10da335ce..831fae3db 100644 --- a/glfw/cocoa_window.m +++ b/glfw/cocoa_window.m @@ -1505,6 +1505,15 @@ update_drop_state(_GLFWwindow *window, size_t accepted_count, GLFWDropEventType if (t == GLFW_DROP_ENTER || t == GLFW_DROP_MOVE) d->drag_accepted = accepted_count > 0; } +static void +update_drop_source_actions(_GLFWwindow *window, id sender) { + NSDragOperation src_ops = [sender draggingSourceOperationMask]; + window->drop_operation.source_actions = GLFW_DRAG_OPERATION_NONE; + if (src_ops & NSDragOperationCopy) window->drop_operation.source_actions |= GLFW_DRAG_OPERATION_COPY; + if (src_ops & NSDragOperationMove) window->drop_operation.source_actions |= GLFW_DRAG_OPERATION_MOVE; + if (src_ops & NSDragOperationGeneric) window->drop_operation.source_actions |= GLFW_DRAG_OPERATION_GENERIC; +} + // Reset the working copy of mimes so the next callback sees the full original // list. Returns false on allocation failure. static bool @@ -1581,11 +1590,7 @@ reset_drop_copy_mimes(_GLFWDropData *d) { window->ns.drop_data.mimes = mime_array; window->ns.drop_data.mimes_count = mime_count; bool from_self = ([sender draggingSource] != nil); - NSDragOperation src_ops = [sender draggingSourceOperationMask]; - window->drop_operation.source_actions = GLFW_DRAG_OPERATION_NONE; - if (src_ops & NSDragOperationCopy) window->drop_operation.source_actions |= GLFW_DRAG_OPERATION_COPY; - if (src_ops & NSDragOperationMove) window->drop_operation.source_actions |= GLFW_DRAG_OPERATION_MOVE; - if (src_ops & NSDragOperationGeneric) window->drop_operation.source_actions |= GLFW_DRAG_OPERATION_GENERIC; + update_drop_source_actions(window, sender); _GLFWDropData *d = &window->ns.drop_data; if (reset_drop_copy_mimes(d)) { size_t accepted_count = _glfwInputDropEvent(window, GLFW_DROP_ENTER, xpos, ypos, d->copy_mimes, d->copy_mimes_count, from_self); @@ -1603,11 +1608,7 @@ reset_drop_copy_mimes(_GLFWDropData *d) { double ypos = contentRect.size.height - pos.y; bool from_self = ([sender draggingSource] != nil); - NSDragOperation src_ops = [sender draggingSourceOperationMask]; - window->drop_operation.source_actions = GLFW_DRAG_OPERATION_NONE; - if (src_ops & NSDragOperationCopy) window->drop_operation.source_actions |= GLFW_DRAG_OPERATION_COPY; - if (src_ops & NSDragOperationMove) window->drop_operation.source_actions |= GLFW_DRAG_OPERATION_MOVE; - if (src_ops & NSDragOperationGeneric) window->drop_operation.source_actions |= GLFW_DRAG_OPERATION_GENERIC; + update_drop_source_actions(window, sender); _GLFWDropData *d = &window->ns.drop_data; if (reset_drop_copy_mimes(d)) { size_t accepted_count = _glfwInputDropEvent(window, GLFW_DROP_MOVE, xpos, ypos, d->copy_mimes, d->copy_mimes_count, from_self);