Allow reading dropped data in chunks

Fixes #9470
This commit is contained in:
copilot-swe-agent[bot]
2026-02-04 06:21:29 +00:00
committed by Kovid Goyal
parent 0ab7aec690
commit ed5eb8f45c
7 changed files with 759 additions and 135 deletions

28
glfw/internal.h vendored
View File

@@ -85,6 +85,27 @@ typedef struct _GLFWjoystick _GLFWjoystick;
typedef struct _GLFWtls _GLFWtls;
typedef struct _GLFWmutex _GLFWmutex;
// Drop data structure for chunked reading of drag and drop data
struct GLFWDropData {
const char** mime_types; // Array of available MIME types (owned by drop object)
int mime_count; // Number of MIME types
int mime_array_size; // Original array size for proper cleanup
const char* current_mime; // Currently being read MIME type
int read_fd; // File descriptor for reading data (Wayland/X11)
size_t bytes_read; // Total bytes read so far for current mime
void* platform_data; // Platform-specific data (offer for Wayland, pasteboard for Cocoa)
bool eof_reached; // Whether EOF has been reached for current mime
// Platform-specific data fields
void* current_data; // NSData* (Cocoa) or unsigned char* from XGetWindowProperty (X11)
size_t data_offset; // Read offset in current data (Cocoa/X11)
// X11-specific fields
size_t x11_data_size; // Size of current X11 data
unsigned long x11_drop_target; // Window handle where the drop occurred (X11)
unsigned long x11_drop_time; // Time from the drop event (X11)
unsigned long x11_source; // Source window for XdndFinished (X11)
int x11_version; // Xdnd protocol version (X11)
};
typedef void (* _GLFWmakecontextcurrentfun)(_GLFWwindow*);
typedef void (* _GLFWswapbuffersfun)(_GLFWwindow*);
typedef void (* _GLFWswapintervalfun)(int);
@@ -822,8 +843,13 @@ void _glfwInputScroll(_GLFWwindow* window, const GLFWScrollEvent *ev);
void _glfwInputMouseClick(_GLFWwindow* window, int button, int action, int mods);
void _glfwInputCursorPos(_GLFWwindow* window, double xpos, double ypos);
void _glfwInputCursorEnter(_GLFWwindow* window, bool entered);
void _glfwInputDrop(_GLFWwindow* window, const char *mime, const char *text, size_t sz);
void _glfwInputDrop(_GLFWwindow* window, GLFWDropData* drop);
int _glfwInputDragEvent(_GLFWwindow* window, int event, double xpos, double ypos, const char** mime_types, int* mime_count);
// Platform functions for drop data reading
const char** _glfwPlatformGetDropMimeTypes(GLFWDropData* drop, int* count);
ssize_t _glfwPlatformReadDropData(GLFWDropData* drop, const char* mime, void* buffer, size_t capacity, monotonic_t timeout);
void _glfwPlatformFinishDrop(GLFWDropData* drop, GLFWDragOperationType operation, bool success);
void _glfwInputColorScheme(GLFWColorScheme, bool);
void _glfwPlatformInputColorScheme(GLFWColorScheme);
void _glfwInputJoystick(_GLFWjoystick* js, int event);