From now on, libmenu does not steal all input keys from input modules.

git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@25530 b3059339-0415-0410-9bf9-f77b7e298cf2
This commit is contained in:
ulion 2007-12-26 13:13:48 +00:00
parent 2b517dc714
commit b6870cc5ba
8 changed files with 23 additions and 22 deletions

View File

@ -537,7 +537,7 @@ static mp_cmd_bind_t* cmd_binds_default = NULL;
static mp_cmd_filter_t* cmd_filters = NULL;
// Callback to allow the menu filter to grab the incoming keys
void (*mp_input_key_cb)(int code) = NULL;
int (*mp_input_key_cb)(int code) = NULL;
static mp_input_fd_t key_fds[MP_MAX_KEY_FD];
static unsigned int num_key_fd = 0;
@ -1070,7 +1070,7 @@ interpret_key(int code, int paused)
if (code & MP_KEY_DOWN)
return NULL;
code &= ~(MP_KEY_DOWN|MP_NO_REPEAT_KEY);
mp_input_key_cb(code);
if (mp_input_key_cb(code))
return NULL;
}

View File

@ -207,7 +207,7 @@ typedef int (*mp_cmd_func_t)(int fd,char* dest,int size);
typedef void (*mp_close_func_t)(int fd);
// Set this to grab all incoming key codes
extern void (*mp_input_key_cb)(int code);
extern int (*mp_input_key_cb)(int code);
// Should return 1 if the command was processed
typedef int (*mp_input_cmd_filter)(mp_cmd_t* cmd, int paused, void* ctx);

View File

@ -347,11 +347,11 @@ void menu_close(menu_t* menu) {
free(menu);
}
void menu_read_key(menu_t* menu,int cmd) {
int menu_read_key(menu_t* menu,int cmd) {
if(menu->read_key)
menu->read_key(menu,cmd);
return menu->read_key(menu,cmd);
else
menu_dflt_read_key(menu,cmd);
return menu_dflt_read_key(menu,cmd);
}
///////////////////////////// Helpers ////////////////////////////////////

View File

@ -10,7 +10,7 @@ struct menu_s {
struct MPContext *ctx;
void (*draw)(menu_t* menu,mp_image_t* mpi);
void (*read_cmd)(menu_t* menu,int cmd);
void (*read_key)(menu_t* menu,int cmd);
int (*read_key)(menu_t* menu,int cmd);
void (*close)(menu_t* menu);
struct m_struct_st* priv_st;
struct menu_priv_s* priv;
@ -56,7 +56,7 @@ menu_t* menu_open(char *name);
void menu_draw(menu_t* menu,mp_image_t* mpi);
void menu_read_cmd(menu_t* menu,int cmd);
void menu_close(menu_t* menu);
void menu_read_key(menu_t* menu,int cmd);
int menu_read_key(menu_t* menu,int cmd);
//// Default implementation
int menu_dflt_read_key(menu_t* menu,int cmd);

View File

@ -419,20 +419,20 @@ static void read_cmd(menu_t* menu,int cmd) {
}
}
static void read_key(menu_t* menu,int c) {
static int read_key(menu_t* menu,int c) {
if(mpriv->child && mpriv->raw_child) {
write(mpriv->child_fd[0],&c,sizeof(int));
return;
return 1;
}
if (c == KEY_DELETE || c == KEY_BS) {
unsigned int i = strlen(mpriv->cur_history->buffer);
if(i > 0)
mpriv->cur_history->buffer[i-1] = '\0';
return;
return 1;
}
if (menu_dflt_read_key(menu, c))
return;
return 1;
if(isascii(c)) {
int l = strlen(mpriv->cur_history->buffer);
@ -442,8 +442,9 @@ static void read_key(menu_t* menu,int c) {
}
mpriv->cur_history->buffer[l] = (char)c;
mpriv->cur_history->buffer[l+1] = '\0';
return 1;
}
return;
return 0;
}

View File

@ -377,17 +377,17 @@ static void read_cmd(menu_t* menu,int cmd) {
}
}
static void read_key(menu_t* menu,int c){
static int read_key(menu_t* menu,int c){
char **str;
for (str=mpriv->actions; str && *str; str++)
if (c == (*str)[0]) {
action = &(*str)[2];
read_cmd(menu,MENU_CMD_ACTION);
return;
return 1;
}
if (menu_dflt_read_key(menu, c))
return;
menu_list_jump_to_key(menu, c);
return 1;
return menu_list_jump_to_key(menu, c);
}
static void clos(menu_t* menu) {

View File

@ -95,10 +95,10 @@ static void read_cmd(menu_t* menu,int cmd) {
}
}
static void read_key(menu_t* menu,int c){
static int read_key(menu_t* menu,int c){
if (menu_dflt_read_key(menu, c))
return;
menu_list_jump_to_key(menu, c);
return 1;
return menu_list_jump_to_key(menu, c);
}
static void close_menu(menu_t* menu) {

View File

@ -120,8 +120,8 @@ static void get_image(struct vf_instance_s* vf, mp_image_t *mpi){
}
}
static void key_cb(int code) {
menu_read_key(st_priv->current,code);
static int key_cb(int code) {
return menu_read_key(st_priv->current,code);
}
static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts){