Refactor drop API and implement it on Wayland

This commit is contained in:
Kovid Goyal
2026-02-08 13:34:00 +05:30
parent 0ea65903b8
commit 3cf24afdc0
14 changed files with 516 additions and 682 deletions

17
glfw/internal.h vendored
View File

@@ -517,10 +517,13 @@ struct _GLFWwindow
GLFWcursorenterfun cursorEnter;
GLFWscrollfun scroll;
GLFWkeyboardfun keyboard;
GLFWdropfun drop;
GLFWliveresizefun liveResize;
GLFWdropfun drop;
GLFWdragfun drag;
GLFWdragsourcefun dragSource;
GLFWdropeventfun drop_event;
} callbacks;
// This is defined in the window API's platform.h
@@ -810,7 +813,6 @@ void _glfwPlatformChangeCursorTheme(void);
int _glfwPlatformStartDrag(_GLFWwindow* window, const char* const* mime_types, int mime_count, const GLFWimage* thumbnail, int operations);
ssize_t _glfwPlatformSendDragData(GLFWDragSourceData* source_data, const void* data, size_t size);
void _glfwPlatformCancelDrag(_GLFWwindow* window);
void _glfwPlatformUpdateDragState(_GLFWwindow* window);
void _glfwPlatformPollEvents(void);
void _glfwPlatformWaitEvents(void);
@@ -864,14 +866,20 @@ 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, GLFWDropData* drop, bool from_self);
int _glfwInputDragEvent(_GLFWwindow* window, int event, double xpos, double ypos, const char** mime_types, int* mime_count);
void _glfwInputDragSourceRequest(_GLFWwindow* window, const char* mime_type, GLFWDragSourceData* source_data);
// 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 _glfwPlatformRequestDropUpdate(_GLFWwindow* window);
size_t _glfwInputDropEvent(_GLFWwindow *window, GLFWDropEventType type, double xpos, double ypos, const char** mimes, size_t num_mimes, bool from_self);
ssize_t _glfwPlatformReadAvailableDropData(GLFWwindow *w, GLFWDropEvent *ev, char *buffer, size_t sz);
void _glfwPlatformEndDrop(GLFWwindow *w, GLFWDragOperationType op);
int _glfwPlatformRequestDropData(_GLFWwindow *window, const char *mime);
void _glfwInputColorScheme(GLFWColorScheme, bool);
void _glfwPlatformInputColorScheme(GLFWColorScheme);
void _glfwInputJoystick(_GLFWjoystick* js, int event);
@@ -952,3 +960,4 @@ void _glfw_free_clipboard_data(_GLFWClipboardData *cd);
#define debug_rendering(...) if (_glfw.hints.init.debugRendering) { timed_debug_print(__VA_ARGS__); }
#define debug_input(...) if (_glfw.hints.init.debugKeyboard) { timed_debug_print(__VA_ARGS__); }
#define safe_close(fd) do { errno = 0; close(fd); } while(errno == EINTR)