Skip to content

Commit

Permalink
don't run command in ui thread
Browse files Browse the repository at this point in the history
it may hang the gui message loop
  • Loading branch information
tsl0922 committed Feb 6, 2024
1 parent 7544fdb commit 58e5daf
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
6 changes: 2 additions & 4 deletions src/menu.c
Original file line number Diff line number Diff line change
Expand Up @@ -158,12 +158,10 @@ void show_menu(plugin_ctx *ctx, POINT *pt) {
if (!PtInRect(&rc, *pt)) return;

ClientToScreen(ctx->hwnd, pt);
mpv_command(ctx->mpv,
(const char *[]){"script-message", "menu-open", NULL});
mp_command_async("script-message menu-open");
TrackPopupMenuEx(ctx->hmenu, TPM_LEFTALIGN | TPM_LEFTBUTTON, pt->x, pt->y,
ctx->hwnd, NULL);
mpv_command(ctx->mpv,
(const char *[]){"script-message", "menu-close", NULL});
mp_command_async("script-message menu-close");
}

// run mpv command stored in menu item data
Expand Down
2 changes: 1 addition & 1 deletion src/plugin.c
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ static void async_cmd_fn(void *data) {
mpv_command_string(ctx->mpv, (const char *)data);
}

// run command on none-ui thread
// run command in none-ui thread
void mp_command_async(const char *args) {
mp_dispatch_enqueue(ctx->dispatch, async_cmd_fn, (void *)args);
mpv_wakeup(ctx->mpv);
Expand Down

0 comments on commit 58e5daf

Please sign in to comment.