[MPlayer-dev-eng] [PATCH] double click to switch to full screen in GUI
Reimar Döffinger
Reimar.Doeffinger at stud.uni-karlsruhe.de
Sat Dec 2 21:30:28 CET 2006
Hello,
On Sun, Nov 19, 2006 at 10:24:06PM +0100, laurent wozniak wrote:
> * Usability issue:
> - Double click is not mouse button (press, release, press, release) but
> (press, release, press).
> The double click event should not wait for the last button release to be
> fired.
> This also explain why you have to be so fast in clicking with a timeout
> set to 300.
Hmm.. We just found out that fluxbox behaves as my patch, everyone else
uses your way...
Now, there is a little annoyance with supporting press, release, press,
namely that it is (correctly) detected as the key combination of
mouse button and mouse button double click.
Attached patch turns this into a feature by supporting both ways (I
know, it is a bit ugly and will need explanation in the documentation):
MOUSE_BTN0_DBL bind is for press, release, press, release
MOUSE_BTN0-MOUSE_BTN0_DBL is for press, release, press
So is this finally an acceptable basic implementation so I can apply and
move to fix the remaining problems?
Greetings,
Reimar Döffinger
-------------- next part --------------
diff --git a/cfg-mplayer.h b/cfg-mplayer.h
index 497e018..de62307 100644
--- a/cfg-mplayer.h
+++ b/cfg-mplayer.h
@@ -368,6 +368,7 @@ m_option_t mplayer_opts[]={
{"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"
diff --git a/fifo.c b/fifo.c
index 5820a30..35b8777 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);
+}
More information about the MPlayer-dev-eng
mailing list