From ad5c7d5bb1bf83d7f339704512e43035fa61d560 Mon Sep 17 00:00:00 2001
From: uau <uau@b3059339-0415-0410-9bf9-f77b7e298cf2>
Date: Sat, 25 Aug 2007 04:28:20 +0000
Subject: [PATCH] Handle queued commands from input event functions immediately

Check whether an event handler called mp_input_queue_cmd and return the
command immediately if so. Currently x11_common.c creates commands from
mouse position updates.


git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@24154 b3059339-0415-0410-9bf9-f77b7e298cf2
---
 input/input.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/input/input.c b/input/input.c
index f37da37088..84a2ae6661 100644
--- a/input/input.c
+++ b/input/input.c
@@ -1173,6 +1173,8 @@ static mp_cmd_t *read_events(int time, int paused)
 	int code;
 	if (key_fds[i].no_readfunc_retval) {   // getch2 handler special-cased for now
 	    ((void (*)(void))key_fds[i].read_func)();
+	    if (cmd_queue_length)
+		return NULL;
 	    code = mplayer_get_key(0);
 	    if (code < 0)
 		code = MP_INPUT_NOTHING;
@@ -1264,6 +1266,10 @@ mp_input_get_cmd(int time, int paused, int peek_only) {
     if(ret) break;
     from_queue = 0;
     ret = read_events(time, paused);
+    if (!ret) {
+	from_queue = 1;
+	ret = mp_input_get_queued_cmd(peek_only);
+    }
     break;
   }
   if(!ret) return NULL;