Move dnd escape code encoding into dnd.c

This commit is contained in:
Kovid Goyal 2026-04-19 13:48:35 +05:30
parent dc9bf889a6
commit 5558dfa953
No known key found for this signature in database
GPG key ID: 06BC317B515ACE7C
3 changed files with 12 additions and 3 deletions

View file

@ -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

View file

@ -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);

View file

@ -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;