playloop: only notify MP_EVENT_INPUT_PROCESSED when needed
MP_EVENT_INPUT_PROCESSED is used to notify mouse and touch position updates, but it is currently notified for all input commands even when they have nothing to do with mouse position. This results in unnecessary acquisition and comparision of mouse and touch positions for all commands. Optimize this by checking whether the command is marked as requiring the event notification, and only notify if that is true.
This commit is contained in:
1 parent
ca6e26399f
commit
af1ac0f685
1 file changed
+4
-3
+4
-3
@@ -108,16 +108,17 @@ void mp_core_unlock(struct MPContext *mpctx)
|
||||
// Process any queued user input.
|
||||
static void mp_process_input(struct MPContext *mpctx)
|
||||
{
|
||||
int processed = 0;
|
||||
bool notify = false;
|
||||
for (;;) {
|
||||
mp_cmd_t *cmd = mp_input_read_cmd(mpctx->input);
|
||||
if (!cmd)
|
||||
break;
|
||||
if (cmd->notify_event)
|
||||
notify = true;
|
||||
run_command(mpctx, cmd, NULL, NULL, NULL);
|
||||
processed = 1;
|
||||
}
|
||||
mp_set_timeout(mpctx, mp_input_get_delay(mpctx->input));
|
||||
if (processed)
|
||||
if (notify)
|
||||
mp_notify(mpctx, MP_EVENT_INPUT_PROCESSED, NULL);
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user