summaryrefslogtreecommitdiffstats
path: root/fifo.c
diff options
context:
space:
mode:
authorreimar <reimar@b3059339-0415-0410-9bf9-f77b7e298cf2>2007-01-18 19:30:02 +0000
committerreimar <reimar@b3059339-0415-0410-9bf9-f77b7e298cf2>2007-01-18 19:30:02 +0000
commitb5f54a914de99a37abe8248fe7673a9a33694e02 (patch)
tree568598f3445abe8616b5253e11719b4ceb4f66a9 /fifo.c
parent21e71a8901c0f6ce9773c4b4ae39c92e0e94f8ff (diff)
downloadmpv-b5f54a914de99a37abe8248fe7673a9a33694e02.tar.bz2
mpv-b5f54a914de99a37abe8248fe7673a9a33694e02.tar.xz
Apply ancient double-click patch that nobody cares to comment on.
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@21959 b3059339-0415-0410-9bf9-f77b7e298cf2
Diffstat (limited to 'fifo.c')
-rw-r--r--fifo.c37
1 files changed, 35 insertions, 2 deletions
diff --git a/fifo.c b/fifo.c
index 5820a30a53..35b8777697 100644
--- a/fifo.c
+++ b/fifo.c
@@ -1,3 +1,4 @@
+#include "input/mouse.h"
#if 0
@@ -25,7 +26,7 @@ static void make_pipe(int* pr,int* pw){
set_nonblock_flag(temp[1]);
}
-void mplayer_put_key(int code){
+static void mplayer_put_key_internal(int code){
if( write(keyb_fifo_put,&code,4) != 4 ){
mp_msg(MSGT_INPUT,MSGL_ERR,"*** key event dropped (FIFO is full) ***\n");
@@ -39,7 +40,7 @@ static int *key_fifo_data = NULL;
static int key_fifo_read=0;
static int key_fifo_write=0;
-void mplayer_put_key(int code){
+static void mplayer_put_key_internal(int code){
// printf("mplayer_put_key(%d)\n",code);
if (key_fifo_data == NULL)
key_fifo_data = malloc(key_fifo_size * sizeof(int));
@@ -62,3 +63,35 @@ int mplayer_get_key(int fd){
#endif
+static unsigned doubleclick_time = 300;
+
+static void put_double(int code) {
+ if (code >= MOUSE_BTN0 && code <= MOUSE_BTN9)
+ mplayer_put_key_internal(code - MOUSE_BTN0 + MOUSE_BTN0_DBL);
+}
+
+void mplayer_put_key(int code) {
+ static unsigned last_key_time[2];
+ static int last_key[2];
+ unsigned now = GetTimerMS();
+ // ignore system-doubleclick if we generate these events ourselves
+ if (doubleclick_time &&
+ (code & ~MP_KEY_DOWN) >= MOUSE_BTN0_DBL &&
+ (code & ~MP_KEY_DOWN) <= MOUSE_BTN9_DBL)
+ return;
+ mplayer_put_key_internal(code);
+ if (code & MP_KEY_DOWN) {
+ code &= ~MP_KEY_DOWN;
+ last_key[1] = last_key[0];
+ last_key[0] = code;
+ last_key_time[1] = last_key_time[0];
+ last_key_time[0] = now;
+ if (last_key[1] == code &&
+ now - last_key_time[1] < doubleclick_time)
+ put_double(code);
+ return;
+ }
+ if (last_key[0] == code && last_key[1] == code &&
+ now - last_key_time[1] < doubleclick_time)
+ put_double(code);
+}