[MPlayer-dev-eng] [PATCH] double click to switch to full screen in GUI

Reimar Döffinger Reimar.Doeffinger at stud.uni-karlsruhe.de
Tue Nov 14 21:19:22 CET 2006


Hello,
On Tue, Oct 17, 2006 at 10:01:25PM +0200, Reimar D?ffinger wrote:
> since Diego keeps annoying me about reviewing this patch, but I am not
> at all motivated, here is the absolutely minimal version for
> implementing double clicks.
> It certainly has deficiencies, but it is something to build onto without
> needing too many prerequisite patches.
> I did not get any of those "key not bound messages btw, I think they
> nowadays only appear with -v.
> Now I still have one problem with it: I think it will interact badly
> with windows vos, which get the doubleclick events from windows
> directly.
> How to fix that?
> A quick hack if this somewhat incomplete patch should be part of rc1
> would be to put it under
> #if !defined(__MINGW32__) && !defined(__CYGWIN__)

Some fixes / updates. Don't remember what exactly. The native/generated
events issue is resolved by allowing to set the doubleclick-time to 0,
which will then enable the native events.
Will not work for vos that do not create proper mouse up and down events
(which means vos must also create up and down events for double-clicks
if the OS already detects them - no idea how the current behaviour is
for vos).

Greetings,
Reimar Döffinger
-------------- next part --------------
Index: fifo.c
===================================================================
--- fifo.c	(revision 20930)
+++ fifo.c	(working copy)
@@ -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){
+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){
+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,29 @@
 
 #endif
 
+static unsigned doubleclick_time = 300;
+
+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;
+    return;
+  }
+  if (last_key[0] == code && last_key[1] == code &&
+      now - last_key_time[1] < doubleclick_time) {
+    if (code >= MOUSE_BTN0 && code <= MOUSE_BTN9)
+      mplayer_put_key_internal(code - MOUSE_BTN0 + MOUSE_BTN0_DBL);
+  }
+}
Index: cfg-mplayer.h
===================================================================
--- cfg-mplayer.h	(revision 20930)
+++ cfg-mplayer.h	(working copy)
@@ -370,6 +372,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"


More information about the MPlayer-dev-eng mailing list