Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 5 additions & 16 deletions src/MacVim/gui_macvim.m
Original file line number Diff line number Diff line change
Expand Up @@ -2257,26 +2257,16 @@ static int vimModMaskToEventModifierFlags(int mods)

// -- Channel Support ------------------------------------------------------

static NSMutableSet *MMChannels;

void *
gui_macvim_add_channel(channel_T *channel, int part)
{
if (!MMChannels)
MMChannels = [NSMutableSet new];

int fd = channel->ch_part[part].ch_fd;
dispatch_queue_t q =
dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0);
dispatch_source_t s =
dispatch_source_create(DISPATCH_SOURCE_TYPE_READ, fd, 0, q);
[MMChannels addObject:s];
dispatch_source_create(DISPATCH_SOURCE_TYPE_READ,
channel->ch_part[part].ch_fd,
0,
dispatch_get_main_queue());
dispatch_source_set_event_handler(s, ^{
dispatch_sync(dispatch_get_main_queue(), ^{
if ([MMChannels containsObject:s]) {
channel_read(channel, part, "gui_macvim_add_channel");
}
});
channel_read(channel, part, "gui_macvim_add_channel");
});
dispatch_resume(s);
return s;
Expand All @@ -2286,7 +2276,6 @@ static int vimModMaskToEventModifierFlags(int mods)
gui_macvim_remove_channel(void *cookie)
{
dispatch_source_t s = (dispatch_source_t)cookie;
[MMChannels removeObject:s];
dispatch_source_cancel(s);
dispatch_release(s);
}
Expand Down
6 changes: 4 additions & 2 deletions src/channel.c
Original file line number Diff line number Diff line change
Expand Up @@ -599,9 +599,11 @@ channel_gui_register_one(channel_T *channel, int part)
# endif
# else
# ifdef FEAT_GUI_MACVIM
/* Tell Core Foundation we are interested in being called when there
* is input on the editor connection socket. */
if (channel->ch_part[part].ch_inputHandler == 0)
channel->ch_part[part].ch_inputHandler =
gui_macvim_add_channel(channel, part);
channel->ch_part[part].ch_inputHandler = gui_macvim_add_channel(
channel, part);
# endif
# endif
# endif
Expand Down