From 06405a5ba56a0c38b76859a8e1e4665061028a79 Mon Sep 17 00:00:00 2001 From: Uoti Urpala Date: Tue, 29 Apr 2008 15:44:03 +0300 Subject: [PATCH] Move key_fifo_size & doubleclick_time to options struct --- cfg-mplayer.h | 7 ++----- defaultopts.c | 2 ++ mp_fifo.c | 12 ++++++------ mp_fifo.h | 4 +++- mplayer.c | 2 +- options.h | 2 ++ 6 files changed, 16 insertions(+), 13 deletions(-) diff --git a/cfg-mplayer.h b/cfg-mplayer.h index 1f8bd131b6..1e7907b623 100644 --- a/cfg-mplayer.h +++ b/cfg-mplayer.h @@ -10,9 +10,6 @@ #include "cfg-common.h" #include "options.h" -extern int key_fifo_size; -extern unsigned doubleclick_time; - extern char *fb_mode_cfgfile; extern char *fb_mode_name; extern char *dfb_params; @@ -340,12 +337,12 @@ const m_option_t mplayer_opts[]={ {"idle", &player_idle_mode, CONF_TYPE_FLAG,CONF_GLOBAL , 0, 1, NULL}, {"noidle", &player_idle_mode, CONF_TYPE_FLAG,CONF_GLOBAL , 1, 0, NULL}, {"use-stdin", "-use-stdin has been renamed to -noconsolecontrols, use that instead.", CONF_TYPE_PRINT, 0, 0, 0, NULL}, - {"key-fifo-size", &key_fifo_size, CONF_TYPE_INT, CONF_RANGE, 2, 65000, NULL}, + OPT_INTRANGE("key-fifo-size", key_fifo_size, 0, 2, 65000), {"noconsolecontrols", &noconsolecontrols, CONF_TYPE_FLAG, CONF_GLOBAL, 0, 1, NULL}, {"consolecontrols", &noconsolecontrols, CONF_TYPE_FLAG, CONF_GLOBAL, 1, 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, 1, 0, NULL}, - {"doubleclick-time", &doubleclick_time, CONF_TYPE_INT, CONF_RANGE, 0, 1000, NULL}, + OPT_INTRANGE("doubleclick-time", doubleclick_time, 0, 0, 1000), #ifdef USE_TV {"tvscan", (void *) tvscan_conf, CONF_TYPE_SUBCONFIG, 0, 0, 0, NULL}, #else diff --git a/defaultopts.c b/defaultopts.c index 2ac08d9bc4..7ee0328829 100644 --- a/defaultopts.c +++ b/defaultopts.c @@ -15,6 +15,8 @@ void set_default_mplayer_options(struct MPOpts *opts) .vo_gamma_hue = 1000, .loop_times = -1, .user_correct_pts = -1, + .key_fifo_size = 7, + .doubleclick_time = 300, .audio_id = -1, .video_id = -1, .sub_id = -2, diff --git a/mp_fifo.c b/mp_fifo.c index 0699a55e4d..62228e8558 100644 --- a/mp_fifo.c +++ b/mp_fifo.c @@ -4,10 +4,11 @@ #include "input/mouse.h" #include "mp_fifo.h" #include "talloc.h" +#include "options.h" -int key_fifo_size = 7; struct mp_fifo { + struct MPOpts *opts; int *data; int readpos; int writepos; @@ -16,10 +17,11 @@ struct mp_fifo { int last_key[2]; }; -struct mp_fifo *mp_fifo_create(void) +struct mp_fifo *mp_fifo_create(struct MPOpts *opts) { struct mp_fifo *fifo = talloc_zero(NULL, struct mp_fifo); - fifo->size = key_fifo_size; + fifo->opts = opts; + fifo->size = opts->key_fifo_size; fifo->data = talloc_array_ptrtype(fifo, fifo->data, fifo->size); return fifo; } @@ -48,9 +50,6 @@ int mplayer_get_key(void *ctx, int fd) return key; } - -unsigned doubleclick_time = 300; - static void put_double(struct mp_fifo *fifo, int code) { if (code >= MOUSE_BTN0 && code <= MOUSE_BTN9) @@ -60,6 +59,7 @@ static void put_double(struct mp_fifo *fifo, int code) void mplayer_put_key(struct mp_fifo *fifo, int code) { unsigned now = GetTimerMS(); + int doubleclick_time = fifo->opts->doubleclick_time; // ignore system-doubleclick if we generate these events ourselves if (doubleclick_time && (code & ~MP_KEY_DOWN) >= MOUSE_BTN0_DBL diff --git a/mp_fifo.h b/mp_fifo.h index 719bbafac7..751de324b6 100644 --- a/mp_fifo.h +++ b/mp_fifo.h @@ -5,7 +5,9 @@ struct mp_fifo; int mplayer_get_key(void *ctx, int fd); void mplayer_put_key(struct mp_fifo *fifo, int code); // Can be freed with talloc_free() -struct mp_fifo *mp_fifo_create(void); +struct MPOpts; +struct mp_fifo *mp_fifo_create(struct MPOpts *opts); + #ifdef IS_OLD_VO #define mplayer_put_key(key) mplayer_put_key(global_vo->key_fifo, key) diff --git a/mplayer.c b/mplayer.c index a3c69988e4..92b21165d0 100644 --- a/mplayer.c +++ b/mplayer.c @@ -2634,7 +2634,7 @@ int gui_no_filename=0; } } } - mpctx->key_fifo = mp_fifo_create(); + mpctx->key_fifo = mp_fifo_create(opts); #if defined(WIN32) && defined(HAVE_NEW_GUI) void *runningmplayer = FindWindow("MPlayer GUI for Windows", "MPlayer for Windows"); diff --git a/options.h b/options.h index 3665383a46..3105a24252 100644 --- a/options.h +++ b/options.h @@ -24,6 +24,8 @@ typedef struct MPOpts { int loop_times; int correct_pts; int user_correct_pts; + int key_fifo_size; + int doubleclick_time; int audio_id; int video_id; int sub_id; -- 2.11.4.GIT