[MPlayer-dev-eng] [PATCH] fix broken keyboard in osd menu file selector

Jason Lunz lunz at falooley.org
Tue Mar 11 02:47:06 CET 2003


In the OSD menu file selector, pressing any alphanumeric key jumps to
the corresponding part of the file list. The code uses isalnum() to
decide what's an "alphanumeric" key.

Unfortunately, isalnum() can be unpredictable depending on your locale.
For example, with LANG=en_US, the down-arrow key doesn't work for me
because isalnum() thinks the down keycode is an alphanumeric.

To fix this, the patch below reverses the calling order for keypress
resolution in libmenu. menu_dflt_read_key() is changed to return an int
indicating whether or not an action was performed, and the alphanumeric
lookup is only done in menu_list_read_key() if menu_dflt_read_key() did
nothing.

Jason


Index: libmenu/menu.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmenu/menu.c,v
retrieving revision 1.9
diff -u -p -r1.9 menu.c
--- libmenu/menu.c	9 Feb 2003 20:18:20 -0000	1.9
+++ libmenu/menu.c	11 Mar 2003 01:54:38 -0000
@@ -169,7 +159,8 @@ void menu_unint(void) {
 }
 
 /// Default read_key function
-void menu_dflt_read_key(menu_t* menu,int cmd) {
+int menu_dflt_read_key(menu_t* menu,int cmd) {
+  int ret = 1;
   switch(cmd) {
   case KEY_UP:
     menu->read_cmd(menu,MENU_CMD_UP);
@@ -185,7 +176,10 @@ void menu_dflt_read_key(menu_t* menu,int
   case KEY_ENTER:
     menu->read_cmd(menu,MENU_CMD_OK);
     break;
+  default:
+    ret = 0;
   }
+  return ret;
 }
 
 menu_t* menu_open(char *name) {
Index: libmenu/menu.h
===================================================================
RCS file: /cvsroot/mplayer/main/libmenu/menu.h,v
retrieving revision 1.1
diff -u -p -r1.1 menu.h
--- libmenu/menu.h	14 Nov 2002 23:47:11 -0000	1.1
+++ libmenu/menu.h	11 Mar 2003 01:54:38 -0000
@@ -45,7 +45,7 @@ void menu_close(menu_t* menu);
 void menu_read_key(menu_t* menu,int cmd);
 
 //// Default implementation
-void menu_dflt_read_key(menu_t* menu,int cmd);
+int menu_dflt_read_key(menu_t* menu,int cmd);
 
 /////////// Helpers
 
Index: libmenu/menu_list.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmenu/menu_list.c,v
retrieving revision 1.3
diff -u -p -r1.3 menu_list.c
--- libmenu/menu_list.c	9 Feb 2003 20:18:20 -0000	1.3
+++ libmenu/menu_list.c	11 Mar 2003 01:54:40 -0000
@@ -152,8 +152,7 @@ void menu_list_jump_to_key(menu_t* menu,
 	  return;
 	}
     }
-  } else
-    menu_dflt_read_key(menu,c);
+  }
 }
 
 void menu_list_read_key(menu_t* menu,int c,int jump_to) {
@@ -182,10 +181,8 @@ void menu_list_read_key(menu_t* menu,int
       mpriv->current = m;
     break;
   default:
-    if(jump_to)
+    if(!menu_dflt_read_key(menu,c) && jump_to)
       menu_list_jump_to_key(menu,c);
-    else
-      menu_dflt_read_key(menu,c);
   }    
 }
 



More information about the MPlayer-dev-eng mailing list