API to change image for drag in progress

This commit is contained in:
Kovid Goyal 2026-02-22 09:10:26 +05:30
parent 8ad22e7859
commit 6506ce1e91
No known key found for this signature in database
GPG key ID: 06BC317B515ACE7C
7 changed files with 14 additions and 1 deletions

View file

@ -4194,6 +4194,9 @@ _glfwPlatformStartDrag(_GLFWwindow* window, const GLFWimage* thumbnail) {@autore
void
_glfwPlatformFreeDragSourceData(void) { }
int
_glfwPlatformChangeDragImage(const GLFWimage *thumbnail) { (void)thumbnail; return 0; /* TODO: Implement me */ }
int
_glfwPlatformDragDataReady(const char *mime_type) {
if (!file_promise_providers) return 0;

3
glfw/glfw3.h vendored
View file

@ -4982,7 +4982,8 @@ GLFWAPI void glfwEndDrop(GLFWwindow *window, GLFWDragOperationType op);
GLFWAPI GLFWdragsourcefun glfwSetDragSourceCallback(GLFWwindow* window, GLFWdragsourcefun callback);
// Start a drag. If called with operations == -1 indicates that previously
// requested data via GLFW_DRAG_DATA_REQUEST is ready.
// requested data via GLFW_DRAG_DATA_REQUEST is ready. operations == -2 means
// that the drag image is changed.
GLFWAPI int glfwStartDrag(GLFWwindow* window, const GLFWDragSourceItem *items, size_t mime_count, const GLFWimage* thumbnail, int operations);
/*! @brief Returns whether the specified joystick is present.

1
glfw/input.c vendored
View file

@ -1166,6 +1166,7 @@ glfwStartDrag(GLFWwindow* handle, const GLFWDragSourceItem *items, size_t item_c
assert(window != NULL);
_GLFW_REQUIRE_INIT_OR_RETURN(EINVAL);
if (operations == -1) return _glfwPlatformDragDataReady(items[0].mime_type);
if (operations == -2) return _glfwPlatformChangeDragImage(thumbnail);
_glfwFreeDragSourceData();
_glfw.drag.instance_id++;
if (!items || !item_count) return 0;

1
glfw/internal.h vendored
View file

@ -837,6 +837,7 @@ void _glfwFreeDragSourceData(void);
void _glfwPlatformFreeDragSourceData(void);
void _glfwInputDragSourceRequest(_GLFWwindow* window, GLFWDragEvent *ev);
int _glfwPlatformDragDataReady(const char *mime_type);
int _glfwPlatformChangeDragImage(const GLFWimage *thumbnail);
void _glfwInputColorScheme(GLFWColorScheme, bool);

1
glfw/null_window.c vendored
View file

@ -542,6 +542,7 @@ _glfwPlatformStartDrag(_GLFWwindow* window, const GLFWimage* thumbnail) {
}
void _glfwPlatformFreeDragSourceData(void) {}
int _glfwPlatformDragDataReady(const char *mime_type) { (void) mime_type; return 0; }
int _glfwPlatformChangeDragImage(const GLFWimage *thumbnail) { (void)thumbnail; return 0; }
const char** _glfwPlatformGetDropMimeTypes(GLFWDropData* drop UNUSED, int* count)
{

3
glfw/wl_window.c vendored
View file

@ -3189,6 +3189,9 @@ add_drag_watch(int fd) {
&_glfw.wl.eventLoopData, "drag_source", fd, POLLOUT | POLLERR | POLLHUP, true, ready_for_drag_data, NULL);
}
int
_glfwPlatformChangeDragImage(const GLFWimage *thumbnail) { (void)thumbnail; return 0; /* TODO: Implement me */ }
int
_glfwPlatformDragDataReady(const char *mime_type) {
for (size_t i = 0; i < _glfw.wl.drag.count; i++) {

3
glfw/x11_window.c vendored
View file

@ -4474,6 +4474,9 @@ _glfwPlatformFreeDragSourceData(void) {
_glfw.x11.drag.pending_capacity = 0;
}
int
_glfwPlatformChangeDragImage(const GLFWimage *thumbnail) { (void)thumbnail; return 0; /* TODO: Implement me */ }
int
_glfwPlatformDragDataReady(const char *mime_type) {
// Find the pending request for this MIME type