Extract update_drop_source_actions helper in cocoa backend to avoid duplication

Agent-Logs-Url: https://github.com/kovidgoyal/kitty/sessions/91dbd1d2-ae9d-4816-b710-7d6f3147cda6

Co-authored-by: kovidgoyal <1308621+kovidgoyal@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot] 2026-05-14 05:49:20 +00:00 committed by GitHub
parent 077f402bee
commit 344fa2bc5f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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<NSDraggingInfo> 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);