mirror of
https://github.com/kovidgoyal/kitty
synced 2026-07-28 11:11:47 +02:00
Fix drop data requests
This commit is contained in:
@@ -106,9 +106,9 @@ Requesting data is done by sending an escape code of the form::
|
|||||||
|
|
||||||
OSC _dnd_code ; t=r:x=idx ST
|
OSC _dnd_code ; t=r:x=idx ST
|
||||||
|
|
||||||
Here ``idx`` is a 1-based index into the list of MIME types sent previously.
|
Here ``idx`` is a 1-based index into the list of MIME types sent in the ``t=M``
|
||||||
This will request data for the specified MIME type. The terminal must respond
|
drop event. This will request data for the specified MIME type.
|
||||||
with a series of escape codes of the form::
|
The terminal must respond with a series of escape codes of the form::
|
||||||
|
|
||||||
OSC _dnd_code ; t=r:x=idx; base64 encoded data possibly chunked ST
|
OSC _dnd_code ; t=r:x=idx; base64 encoded data possibly chunked ST
|
||||||
|
|
||||||
|
|||||||
@@ -248,8 +248,11 @@ func run_loop(opts *Options, drop_dests map[string]*drop_dest, drag_sources map[
|
|||||||
}
|
}
|
||||||
|
|
||||||
request_mime_data := func() {
|
request_mime_data := func() {
|
||||||
for idx := range drop_status.accepted_mimes {
|
accepted := utils.NewSetWithItems(drop_status.accepted_mimes...)
|
||||||
lp.QueueDnDData(DC{Type: 'r', X: idx + 1})
|
for idx, m := range drop_status.offered_mimes {
|
||||||
|
if accepted.Has(m) {
|
||||||
|
lp.QueueDnDData(DC{Type: 'r', X: idx + 1})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -185,10 +185,12 @@ class TestDnDKitten(BaseTest):
|
|||||||
all_mimes += ' image/png'
|
all_mimes += ' image/png'
|
||||||
dnd_test_fake_drop_event(self.capture.window_id, False, all_mimes.split(), copy[0] + 1, copy[1] + 1)
|
dnd_test_fake_drop_event(self.capture.window_id, False, all_mimes.split(), copy[0] + 1, copy[1] + 1)
|
||||||
self.wait_for_state('drop_action', GLFW_DRAG_OPERATION_COPY)
|
self.wait_for_state('drop_action', GLFW_DRAG_OPERATION_COPY)
|
||||||
|
self.assertEqual('text/uri-list\x00image/png', self.probe_state('drop_mimes').rstrip('\x00'))
|
||||||
dnd_test_fake_drop_event(self.capture.window_id, True, all_mimes.split(), copy[0] + 1, copy[1] + 1)
|
dnd_test_fake_drop_event(self.capture.window_id, True, all_mimes.split(), copy[0] + 1, copy[1] + 1)
|
||||||
self.send_dnd_command_to_kitten('DROP_MIMES')
|
self.send_dnd_command_to_kitten('DROP_MIMES')
|
||||||
self.wait_for_responses(all_mimes)
|
self.wait_for_responses(all_mimes)
|
||||||
self.wait_for_state('drop_data_requests', ((1,0,0), (2,0,0)))
|
self.assertEqual('text/uri-list\x00image/png', self.probe_state('drop_mimes').rstrip('\x00'))
|
||||||
|
self.wait_for_state('drop_data_requests', ((1,0,0), (4,0,0)))
|
||||||
self.assertEqual('text/uri-list', self.probe_state('drop_getting_data_for_mime'))
|
self.assertEqual('text/uri-list', self.probe_state('drop_getting_data_for_mime'))
|
||||||
create_fs(self.src_data_dir)
|
create_fs(self.src_data_dir)
|
||||||
uri_list = []
|
uri_list = []
|
||||||
@@ -197,5 +199,6 @@ class TestDnDKitten(BaseTest):
|
|||||||
uri_list = ['moose://cow', 'frog:march'] + uri_list
|
uri_list = ['moose://cow', 'frog:march'] + uri_list
|
||||||
uri_list.insert(3, 'ignore://me')
|
uri_list.insert(3, 'ignore://me')
|
||||||
dnd_test_fake_drop_data(self.capture.window_id, 'text/uri-list', '\r\n'.join(uri_list).encode())
|
dnd_test_fake_drop_data(self.capture.window_id, 'text/uri-list', '\r\n'.join(uri_list).encode())
|
||||||
|
self.assertEqual('image/png', self.probe_state('drop_getting_data_for_mime'))
|
||||||
self.send_dnd_command_to_kitten('DROP_IS_REMOTE')
|
self.send_dnd_command_to_kitten('DROP_IS_REMOTE')
|
||||||
self.wait_for_responses(str(remote_client))
|
self.wait_for_responses(str(remote_client))
|
||||||
|
|||||||
Reference in New Issue
Block a user