summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2013-09-02 02:40:05 +0200
committerwm4 <wm4@nowhere>2013-09-08 01:49:59 +0200
commit0a9919fa2eb071de34865f6c8572683397c43da3 (patch)
tree97561bd9fa70c20bf888bb3c84770ec0b580e10b
parent681e829793d3b5dceca274068c9e6562469d64e4 (diff)
downloadmpv-0a9919fa2eb071de34865f6c8572683397c43da3.tar.bz2
mpv-0a9919fa2eb071de34865f6c8572683397c43da3.tar.xz
input: merge consecutive mouse move events
Might give better behavior on load.
-rw-r--r--mpvcore/input/input.c14
1 files changed, 14 insertions, 0 deletions
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);
}
}