changeset 25502:605d4e3e403f

From now on, libmenu does not steal all input keys from input modules.
author ulion
date Wed, 26 Dec 2007 13:13:48 +0000
parents 26a839637972
children 9f8f66eca56e
files input/input.c input/input.h libmenu/menu.c libmenu/menu.h libmenu/menu_console.c libmenu/menu_filesel.c libmenu/menu_pt.c libmenu/vf_menu.c
diffstat 8 files changed, 23 insertions(+), 22 deletions(-) [+]
line wrap: on
line diff
--- a/input/input.c	Wed Dec 26 04:15:56 2007 +0000
+++ b/input/input.c	Wed Dec 26 13:13:48 2007 +0000
@@ -537,7 +537,7 @@
 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 @@
       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;
   }
 
--- a/input/input.h	Wed Dec 26 04:15:56 2007 +0000
+++ b/input/input.h	Wed Dec 26 13:13:48 2007 +0000
@@ -207,7 +207,7 @@
 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);
 
--- a/libmenu/menu.c	Wed Dec 26 04:15:56 2007 +0000
+++ b/libmenu/menu.c	Wed Dec 26 13:13:48 2007 +0000
@@ -347,11 +347,11 @@
   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 ////////////////////////////////////
--- a/libmenu/menu.h	Wed Dec 26 04:15:56 2007 +0000
+++ b/libmenu/menu.h	Wed Dec 26 13:13:48 2007 +0000
@@ -10,7 +10,7 @@
   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 @@
 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);
--- a/libmenu/menu_console.c	Wed Dec 26 04:15:56 2007 +0000
+++ b/libmenu/menu_console.c	Wed Dec 26 13:13:48 2007 +0000
@@ -419,20 +419,20 @@
   }
 }
 
-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 @@
     }
     mpriv->cur_history->buffer[l] = (char)c;
     mpriv->cur_history->buffer[l+1] = '\0';
+    return 1;
   }
-  return;
+  return 0;
 }
 
 
--- a/libmenu/menu_filesel.c	Wed Dec 26 04:15:56 2007 +0000
+++ b/libmenu/menu_filesel.c	Wed Dec 26 13:13:48 2007 +0000
@@ -377,17 +377,17 @@
   }
 }
 
-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) {
--- a/libmenu/menu_pt.c	Wed Dec 26 04:15:56 2007 +0000
+++ b/libmenu/menu_pt.c	Wed Dec 26 13:13:48 2007 +0000
@@ -95,10 +95,10 @@
   }
 }
 
-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) {
--- a/libmenu/vf_menu.c	Wed Dec 26 04:15:56 2007 +0000
+++ b/libmenu/vf_menu.c	Wed Dec 26 13:13:48 2007 +0000
@@ -120,8 +120,8 @@
   }
 }
   
-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){