From fba67322d6ac80907bfdb095da50d5047066bb1e Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Fri, 6 Mar 2026 10:32:45 +0530 Subject: [PATCH] Some docs --- docs/dnd-protocol.rst | 13 +++++++++++++ kitty/dnd.c | 3 ++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/docs/dnd-protocol.rst b/docs/dnd-protocol.rst index 6798cbdcb..70459e6c1 100644 --- a/docs/dnd-protocol.rst +++ b/docs/dnd-protocol.rst @@ -51,6 +51,18 @@ code:: to inform the terminal that it no longer wants drops. +Whenever the user drags something over the window, the terminal will send an +escape code of the form:: + + OSC _dnd_code ; t=m:x=x:y=y:X=X:Y=Y ; optional MIME list ST + +Here, ``x, y`` identify the cell over which the drag is currently present. +The ``(0, 0)`` cell is at top left of the screen. ``X and Y`` are the pixel +offsets from the top-left. The optional list of MIMES is a space separated +list of MIME types that are available for dropping. To avoid overhead, the +terminal should only send this list for the first move event and subsequently +only if the list changes. + Metadata reference --------------------------- @@ -63,6 +75,7 @@ Key Value Default Description ``t`` Single character. ``a`` The type of drag and drop event. ``(a, A, ``a`` - start accepting drops )`` ``A`` - stop accepting drops + ``m`` - a drop move event ``m`` Chunking indicator ``0`` ``0`` or ``i`` diff --git a/kitty/dnd.c b/kitty/dnd.c index 93fbd97e3..4e3e2b06f 100644 --- a/kitty/dnd.c +++ b/kitty/dnd.c @@ -7,6 +7,7 @@ #include "dnd.h" #include "base64.h" +#include "control-codes.h" static void drop_free_offered_mimes(Window *w) { @@ -124,7 +125,7 @@ drop_move_on_child(Window *w, const char** mimes, size_t num_mimes) { // we simply drop this event if there is too much data being written to the child if (w->drop.pending.count) return; char buf[128]; - int header_size = snprintf(buf, sizeof(buf), "\x1b]%d;i=%u:t=m:x=%u:y=%u:X=%d:Y=%d", w->drop.client_id, + int header_size = snprintf(buf, sizeof(buf), "\x1b]%d;i=%u:t=m:x=%u:y=%u:X=%d:Y=%d", DND_CODE, w->drop.client_id, w->mouse_pos.cell_x, w->mouse_pos.cell_y, (int)w->mouse_pos.global_x, (int)w->mouse_pos.global_y); if (mimes_total_size) { mimes_total_size += 1;