Fix drop on clients. data should be requested only after the client actually requests it not on return from drop event callback
This commit is contained in:
parent
59117ff5fd
commit
b4005d0e97
2 changed files with 7 additions and 6 deletions
|
|
@ -1497,10 +1497,10 @@ - (BOOL)wantsPeriodicDraggingUpdates
|
|||
}
|
||||
|
||||
static void
|
||||
update_drop_state(_GLFWwindow *window, size_t accepted_count) {
|
||||
update_drop_state(_GLFWwindow *window, size_t accepted_count, GLFWDropEventType t) {
|
||||
_GLFWDropData *d = &window->ns.drop_data;
|
||||
d->copy_mimes_count = accepted_count;
|
||||
d->drag_accepted = accepted_count > 0;
|
||||
if (t == GLFW_DROP_ENTER || t == GLFW_DROP_MOVE) d->drag_accepted = accepted_count > 0;
|
||||
}
|
||||
|
||||
// Reset the working copy of mimes so the next callback sees the full original
|
||||
|
|
@ -1582,7 +1582,7 @@ - (NSDragOperation)draggingEntered:(id <NSDraggingInfo>)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);
|
||||
update_drop_state(window, accepted_count);
|
||||
update_drop_state(window, accepted_count, GLFW_DROP_ENTER);
|
||||
}
|
||||
return window->ns.drop_data.drag_accepted ? NSDragOperationGeneric : NSDragOperationNone;
|
||||
}
|
||||
|
|
@ -1599,7 +1599,7 @@ - (NSDragOperation)draggingUpdated:(id <NSDraggingInfo>)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);
|
||||
update_drop_state(window, accepted_count);
|
||||
update_drop_state(window, accepted_count, GLFW_DROP_MOVE);
|
||||
}
|
||||
return window->ns.drop_data.drag_accepted ? NSDragOperationGeneric : NSDragOperationNone;
|
||||
}
|
||||
|
|
@ -1610,7 +1610,7 @@ - (void)draggingExited:(id <NSDraggingInfo>)sender
|
|||
_GLFWDropData *d = &window->ns.drop_data;
|
||||
if (reset_drop_copy_mimes(d)) {
|
||||
size_t accepted_count = _glfwInputDropEvent(window, GLFW_DROP_LEAVE, 0, 0, d->copy_mimes, d->copy_mimes_count, from_self);
|
||||
update_drop_state(window, accepted_count);
|
||||
update_drop_state(window, accepted_count, GLFW_DROP_LEAVE);
|
||||
}
|
||||
free_drop_data(window);
|
||||
}
|
||||
|
|
@ -1627,7 +1627,7 @@ - (BOOL)performDragOperation:(id <NSDraggingInfo>)sender
|
|||
if (!reset_drop_copy_mimes(d)) return NO;
|
||||
size_t num_accepted = _glfwInputDropEvent(window, GLFW_DROP_DROP, xpos, ypos, d->copy_mimes, d->copy_mimes_count, from_self);
|
||||
if (d->copy_mimes) {
|
||||
update_drop_state(window, num_accepted);
|
||||
update_drop_state(window, num_accepted, GLFW_DROP_DROP);
|
||||
window->ns.drop_data.pasteboard = [[sender draggingPasteboard] retain];
|
||||
for (size_t i = 0; i < num_accepted; i++)
|
||||
_glfwPlatformRequestDropData(window, d->copy_mimes[i]);
|
||||
|
|
|
|||
|
|
@ -830,6 +830,7 @@ on_drop(GLFWwindow *window, GLFWDropEvent *ev) {
|
|||
global_state.drop_dest.os_window_id = os_window->id;
|
||||
if (is_client_drop) {
|
||||
drop_move_on_child(w, ev->mimes, ev->num_mimes, true);
|
||||
ev->num_mimes = 0; // we wait for the client to request MIMEs
|
||||
} else {
|
||||
if (ev->from_self) {
|
||||
if (global_state.drag_source.drag_data) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue