From 0a9919fa2eb071de34865f6c8572683397c43da3 Mon Sep 17 00:00:00 2001 From: wm4 Date: Mon, 2 Sep 2013 02:40:05 +0200 Subject: input: merge consecutive mouse move events Might give better behavior on load. --- mpvcore/input/input.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/mpvcore/input/input.c b/mpvcore/input/input.c index 63f79981d7..f3f2cfd6a1 100644 --- a/mpvcore/input/input.c +++ b/mpvcore/input/input.c @@ -719,6 +719,14 @@ static struct mp_cmd *queue_peek(struct cmd_queue *queue) return ret; } +static struct mp_cmd *queue_peek_tail(struct cmd_queue *queue) +{ + struct mp_cmd *cur = queue->first; + while (cur && cur->queue_next) + cur = cur->queue_next; + return cur; +} + static struct input_fd *mp_input_add_fd(struct input_ctx *ictx) { if (ictx->num_fds == MP_MAX_FDS) { @@ -1668,6 +1676,12 @@ void mp_input_set_mouse_pos(struct input_ctx *ictx, int x, int y) if (should_drop_cmd(ictx, cmd)) { talloc_free(cmd); } else { + // Coalesce with previous mouse move events (i.e. replace it) + struct mp_cmd *tail = queue_peek_tail(&ictx->cmd_queue); + if (tail && tail->mouse_move) { + queue_remove(&ictx->cmd_queue, tail); + talloc_free(tail); + } queue_add_tail(&ictx->cmd_queue, cmd); } } -- cgit v1.2.3