[MPlayer-cvslog] r21959 - in trunk: DOCS/man/en/mplayer.1 cfg-mplayer.h fifo.c

reimar subversion at mplayerhq.hu
Thu Jan 18 20:30:02 CET 2007


Author: reimar
Date: Thu Jan 18 20:30:02 2007
New Revision: 21959

Modified:
   trunk/cfg-mplayer.h
   trunk/fifo.c

Changes in other areas also in this revision:
Modified:
   trunk/DOCS/man/en/mplayer.1

Log:
Apply ancient double-click patch that nobody cares to comment on.


Modified: trunk/cfg-mplayer.h
==============================================================================
--- trunk/cfg-mplayer.h	(original)
+++ trunk/cfg-mplayer.h	Thu Jan 18 20:30:02 2007
@@ -367,6 +367,7 @@
 	{"consolecontrols", &noconsolecontrols, CONF_TYPE_FLAG, CONF_GLOBAL, 0, 0, NULL},
 	{"mouse-movements", &enable_mouse_movements, CONF_TYPE_FLAG, CONF_GLOBAL, 0, 1, NULL},
 	{"nomouse-movements", &enable_mouse_movements, CONF_TYPE_FLAG, CONF_GLOBAL, 0, 0, NULL},
+	{"doubleclick-time", &doubleclick_time, CONF_TYPE_INT, CONF_RANGE, 0, 1000, NULL},
 
 #define MAIN_CONF
 #include "cfg-common.h"

Modified: trunk/fifo.c
==============================================================================
--- trunk/fifo.c	(original)
+++ trunk/fifo.c	Thu Jan 18 20:30:02 2007
@@ -1,3 +1,4 @@
+#include "input/mouse.h"
 
 #if 0
 
@@ -25,7 +26,7 @@
   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_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 @@
 
 #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);
+}



More information about the MPlayer-cvslog mailing list