mirror of
https://github.com/kovidgoyal/kitty.git
synced 2026-07-05 23:31:36 +00:00
Merge branch 'copilot/modify-glfwstartdrag-cancel' of https://github.com/kovidgoyal/kitty
This commit is contained in:
commit
d1d7a442b6
6 changed files with 31 additions and 1 deletions
|
|
@ -4422,6 +4422,17 @@ _glfwPlatformStartDrag(_GLFWwindow* window, const GLFWimage* thumbnail) {@autore
|
|||
|
||||
@end
|
||||
|
||||
void
|
||||
_glfwPlatformCancelDrag(_GLFWwindow* window UNUSED) {@autoreleasepool{
|
||||
if (!_glfw.drag.window_id) return;
|
||||
_GLFWwindow* drag_win = _glfwWindowForId(_glfw.drag.window_id);
|
||||
if (drag_win) {
|
||||
GLFWDragEvent ev = {.type = GLFW_DRAG_CANCELLED};
|
||||
_glfwInputDragSourceRequest(drag_win, &ev);
|
||||
}
|
||||
_glfwFreeDragSourceData();
|
||||
}}
|
||||
|
||||
void
|
||||
_glfwPlatformFreeDragSourceData(void) {
|
||||
if (_glfw.ns.drag_session) [_glfw.ns.drag_session release];
|
||||
|
|
|
|||
2
glfw/glfw3.h
vendored
2
glfw/glfw3.h
vendored
|
|
@ -4985,7 +4985,7 @@ GLFWAPI GLFWdragsourcefun glfwSetDragSourceCallback(GLFWwindow* window, GLFWdrag
|
|||
|
||||
// Start a drag. If called with operations == -1 indicates that previously
|
||||
// requested data via GLFW_DRAG_DATA_REQUEST is ready. operations == -2 means
|
||||
// that the drag image is changed.
|
||||
// that the drag image is changed. operations == -3 cancels any existing drag.
|
||||
GLFWAPI int glfwStartDrag(GLFWwindow* window, const GLFWDragSourceItem *items, size_t mime_count, const GLFWimage* thumbnail, int operations, bool needs_toplevel_on_wayland);
|
||||
|
||||
/*! @brief Returns whether the specified joystick is present.
|
||||
|
|
|
|||
1
glfw/input.c
vendored
1
glfw/input.c
vendored
|
|
@ -1190,6 +1190,7 @@ glfwStartDrag(GLFWwindow* handle, const GLFWDragSourceItem *items, size_t item_c
|
|||
_GLFW_REQUIRE_INIT_OR_RETURN(EINVAL);
|
||||
if (operations == -1) return _glfwPlatformDragDataReady(items[0].mime_type);
|
||||
if (operations == -2) return _glfwPlatformChangeDragImage(thumbnail);
|
||||
if (operations == -3) { _glfwPlatformCancelDrag(window); return 0; }
|
||||
_glfwFreeDragSourceData();
|
||||
_glfw.drag.instance_id++;
|
||||
if (!items || !item_count) return 0;
|
||||
|
|
|
|||
1
glfw/internal.h
vendored
1
glfw/internal.h
vendored
|
|
@ -835,6 +835,7 @@ void _glfwPlatformEndDrop(GLFWwindow *w, GLFWDragOperationType op);
|
|||
int _glfwPlatformRequestDropData(_GLFWwindow *window, const char *mime);
|
||||
// Platform functions for drag source
|
||||
int _glfwPlatformStartDrag(_GLFWwindow* window, const GLFWimage* thumbnail);
|
||||
void _glfwPlatformCancelDrag(_GLFWwindow* window);
|
||||
void _glfwFreeDragSourceData(void);
|
||||
void _glfwPlatformFreeDragSourceData(void);
|
||||
void _glfwInputDragSourceRequest(_GLFWwindow* window, GLFWDragEvent *ev);
|
||||
|
|
|
|||
6
glfw/wl_window.c
vendored
6
glfw/wl_window.c
vendored
|
|
@ -3409,6 +3409,12 @@ static const struct wl_data_source_listener drag_source_listener = {
|
|||
.dnd_finished = drag_source_dnd_finished,
|
||||
};
|
||||
|
||||
void
|
||||
_glfwPlatformCancelDrag(_GLFWwindow* window UNUSED) {
|
||||
if (!_glfw.drag.window_id) return;
|
||||
cancel_drag(GLFW_DRAG_CANCELLED);
|
||||
}
|
||||
|
||||
void
|
||||
_glfwPlatformFreeDragSourceData(void) {
|
||||
if (_glfw.wl.drag.drag_viewport) wp_viewport_destroy(_glfw.wl.drag.drag_viewport);
|
||||
|
|
|
|||
11
glfw/x11_window.c
vendored
11
glfw/x11_window.c
vendored
|
|
@ -4522,6 +4522,17 @@ _glfwPlatformStartDrag(_GLFWwindow* window, const GLFWimage* thumbnail) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
_glfwPlatformCancelDrag(_GLFWwindow* window UNUSED) {
|
||||
if (!_glfw.drag.window_id) return;
|
||||
_GLFWwindow* drag_win = _glfwWindowForId(_glfw.drag.window_id);
|
||||
if (drag_win) {
|
||||
GLFWDragEvent ev = {.type = GLFW_DRAG_CANCELLED};
|
||||
_glfwInputDragSourceRequest(drag_win, &ev);
|
||||
}
|
||||
_glfwFreeDragSourceData();
|
||||
}
|
||||
|
||||
void
|
||||
_glfwPlatformFreeDragSourceData(void) {
|
||||
if (_glfw.x11.drag.active) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue