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

Reimar Döffinger Reimar.Doeffinger at stud.uni-karlsruhe.de
Tue Oct 17 22:01:25 CEST 2006


Hello,
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__)

Greetings,
Reimar Döffinger
-------------- next part --------------
Index: fifo.c
===================================================================
--- fifo.c	(revision 20287)
+++ 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,24 @@
 
 #endif
 
+static unsigned doubleclick_time = 300;
+static unsigned last_key_time[2];
+static int last_key[2];
+
+void mplayer_put_key(int code) {
+  unsigned now = GetTimerMS();
+  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);
+  }
+}


More information about the MPlayer-dev-eng mailing list