diff --git a/kitty/dnd.c b/kitty/dnd.c index ffddb387a..d85bb39b1 100644 --- a/kitty/dnd.c +++ b/kitty/dnd.c @@ -1904,6 +1904,15 @@ subdir_data_for_drag( } #undef mi +void +drag_offer_start_to_child(Window *w, int32_t cell_x, int32_t cell_y, int32_t pixel_x, int32_t pixel_y) { + char buf[256]; + int header_size = snprintf( + buf, sizeof(buf), "%d;t=o:x=%d:y=%d:X=%d:Y=%d", DND_CODE, cell_x, cell_y, pixel_x, pixel_y); + queue_payload_to_child( + w->id, w->drag_source.client_id, &w->drag_source.pending, buf, header_size, NULL, 0, false); +} + void drag_remote_file_data( Window *w, int32_t x, int32_t y, int32_t X, int32_t Y, bool has_more, const uint8_t *payload, size_t payload_sz diff --git a/kitty/dnd.h b/kitty/dnd.h index 27a7012e2..a1ed4effa 100644 --- a/kitty/dnd.h +++ b/kitty/dnd.h @@ -37,3 +37,4 @@ void drag_process_item_data(Window *w, size_t idx, int has_more, const uint8_t * void drag_remote_file_data(Window *w, int32_t x, int32_t y, int32_t X, int32_t Y, bool has_more, const uint8_t *payload, size_t payload_sz); void drag_start_offerring(Window *w, const char *client_machine_id, size_t sz); void drag_stop_offerring(Window *w); +void drag_offer_start_to_child(Window *w, int32_t cell_x, int32_t cell_y, int32_t pixel_x, int32_t pixel_y); diff --git a/kitty/mouse.c b/kitty/mouse.c index 01489df22..048dfa908 100644 --- a/kitty/mouse.c +++ b/kitty/mouse.c @@ -684,9 +684,8 @@ HANDLER(handle_move_event) { if (w->drag_source.initial_left_press.at && distance(w->mouse_pos.global_x, w->mouse_pos.global_y, w->drag_source.initial_left_press.x, w->drag_source.initial_left_press.y) > OPT(drag_threshold)) { zero_at_ptr(&w->drag_source.initial_left_press); if (w->drag_source.can_offer) { - snprintf(mouse_event_buf, sizeof(mouse_event_buf), "%d;t=o:x=%d:y=%d:X=%d:Y=%d", - DND_CODE, w->mouse_pos.cell_x, w->mouse_pos.cell_y, (int)w->mouse_pos.global_x, (int)w->mouse_pos.global_y); - write_escape_code_to_child(screen, ESC_OSC, mouse_event_buf); + drag_offer_start_to_child( + w, w->mouse_pos.cell_x, w->mouse_pos.cell_y, (int)w->mouse_pos.global_x, (int)w->mouse_pos.global_y); debug("Sent drag start event to child\n"); } else if (w->drag_source.potential_url_drag.active) { w->drag_source.potential_url_drag.active = false;