Pass mouse events through to commands for if-shell.

This commit is contained in:
nicm 2015-04-21 15:18:06 +00:00
parent 0610f44380
commit bc3786ece9

View File

@ -44,11 +44,14 @@ const struct cmd_entry cmd_if_shell_entry = {
}; };
struct cmd_if_shell_data { struct cmd_if_shell_data {
char *cmd_if; char *cmd_if;
char *cmd_else; char *cmd_else;
struct cmd_q *cmdq;
int bflag; struct cmd_q *cmdq;
int started; struct mouse_event mouse;
int bflag;
int started;
}; };
enum cmd_retval enum cmd_retval
@ -95,21 +98,24 @@ cmd_if_shell_exec(struct cmd *self, struct cmd_q *cmdq)
} }
return (CMD_RETURN_ERROR); return (CMD_RETURN_ERROR);
} }
cmdq_run(cmdq, cmdlist, NULL); cmdq_run(cmdq, cmdlist, &cmdq->item->mouse);
cmd_list_free(cmdlist); cmd_list_free(cmdlist);
return (CMD_RETURN_NORMAL); return (CMD_RETURN_NORMAL);
} }
cdata = xmalloc(sizeof *cdata); cdata = xmalloc(sizeof *cdata);
cdata->cmd_if = xstrdup(args->argv[1]); cdata->cmd_if = xstrdup(args->argv[1]);
if (args->argc == 3) if (args->argc == 3)
cdata->cmd_else = xstrdup(args->argv[2]); cdata->cmd_else = xstrdup(args->argv[2]);
else else
cdata->cmd_else = NULL; cdata->cmd_else = NULL;
cdata->bflag = args_has(args, 'b'); cdata->bflag = args_has(args, 'b');
cdata->started = 0; cdata->started = 0;
cdata->cmdq = cmdq; cdata->cmdq = cmdq;
memcpy(&cdata->mouse, &cmdq->item->mouse, sizeof cdata->mouse);
cmdq->references++; cmdq->references++;
job_run(shellcmd, s, cmd_if_shell_callback, cmd_if_shell_free, cdata); job_run(shellcmd, s, cmd_if_shell_callback, cmd_if_shell_free, cdata);
@ -152,7 +158,7 @@ cmd_if_shell_callback(struct job *job)
cmdq1->emptyfn = cmd_if_shell_done; cmdq1->emptyfn = cmd_if_shell_done;
cmdq1->data = cdata; cmdq1->data = cdata;
cmdq_run(cmdq1, cmdlist, NULL); cmdq_run(cmdq1, cmdlist, &cdata->mouse);
cmd_list_free(cmdlist); cmd_list_free(cmdlist);
} }