Move key_fifo_size & doubleclick_time to options struct

This commit is contained in:
Uoti Urpala 2008-04-29 15:44:03 +03:00
parent 77ec83e351
commit 06405a5ba5
6 changed files with 16 additions and 13 deletions

View File

@ -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

View File

@ -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,

View File

@ -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

View File

@ -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)

View File

@ -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");

View File

@ -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;