mirror of
https://github.com/kovidgoyal/kitty
synced 2026-07-25 01:38:02 +02:00
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:
committed by
GitHub
parent
077f402bee
commit
344fa2bc5f
@@ -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;
|
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
|
// Reset the working copy of mimes so the next callback sees the full original
|
||||||
// list. Returns false on allocation failure.
|
// list. Returns false on allocation failure.
|
||||||
static bool
|
static bool
|
||||||
@@ -1581,11 +1590,7 @@ reset_drop_copy_mimes(_GLFWDropData *d) {
|
|||||||
window->ns.drop_data.mimes = mime_array;
|
window->ns.drop_data.mimes = mime_array;
|
||||||
window->ns.drop_data.mimes_count = mime_count;
|
window->ns.drop_data.mimes_count = mime_count;
|
||||||
bool from_self = ([sender draggingSource] != nil);
|
bool from_self = ([sender draggingSource] != nil);
|
||||||
NSDragOperation src_ops = [sender draggingSourceOperationMask];
|
update_drop_source_actions(window, sender);
|
||||||
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;
|
|
||||||
_GLFWDropData *d = &window->ns.drop_data;
|
_GLFWDropData *d = &window->ns.drop_data;
|
||||||
if (reset_drop_copy_mimes(d)) {
|
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);
|
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;
|
double ypos = contentRect.size.height - pos.y;
|
||||||
|
|
||||||
bool from_self = ([sender draggingSource] != nil);
|
bool from_self = ([sender draggingSource] != nil);
|
||||||
NSDragOperation src_ops = [sender draggingSourceOperationMask];
|
update_drop_source_actions(window, sender);
|
||||||
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;
|
|
||||||
_GLFWDropData *d = &window->ns.drop_data;
|
_GLFWDropData *d = &window->ns.drop_data;
|
||||||
if (reset_drop_copy_mimes(d)) {
|
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);
|
size_t accepted_count = _glfwInputDropEvent(window, GLFW_DROP_MOVE, xpos, ypos, d->copy_mimes, d->copy_mimes_count, from_self);
|
||||||
|
|||||||
Reference in New Issue
Block a user