* Kim Woelders ([EMAIL PROTECTED]) wrote: > > One fairly easy way to do this would be to add a struct, let's say > > struct { > KeySym left, right, up, down; > } menukeys; > > to the Conf struct, add the associated load and save statements (one > config line?) in config.c, and add a function call in menus.c after > XLookupKeysym() mapping the received key into the desired "function". > There would have to be configured some defaults (setup.c). Finally, a > way to actually set the values would be nice. vi > ~/.enlightenment/...e_session-XXXXXX could of course be considered "a > way" :)
Here is the patch. It will probably need some revisions, as there were some choices I add to make that I'm not sure are correct: - I chose to save the config in the CONTROL section - I chose to give it the number 1390 (which was not taken and leave some space for the transparency options if need be) - I chose to save one key per line, using the format: 1390 0 keysym_for_left 1390 1 keysym_for_right 1390 2 keysym_for_up 1390 3 keysym_for_down 1390 4 keysym_for_escape 1390 5 keysym_for_return The patch works well here. The simplest way to use it is: - apply the patch - start and quit enlightenment - edit the newly saved lines in ...e_session-XXXXXX (the lines starting with 1390) - start enlightenment again One nice feature (I think) is that unless you rebind one of the default keys (Left, Right, ...), then they can be still used to navigate the menus. So here I have remapped the directions to hljk, and return to space, but I can still use the arrows and the return key if I want. Alan Schmitt -- The hacker: someone who figured things out and made something cool happen. .O. ..O OOO
Index: E.h =================================================================== RCS file: /cvsroot/enlightenment/e16/e/src/E.h,v retrieving revision 1.314 diff -u -p -r1.314 E.h --- E.h 26 Jul 2004 18:54:48 -0000 1.314 +++ E.h 29 Jul 2004 15:49:59 -0000 @@ -1101,6 +1101,10 @@ typedef struct } hints; struct { + KeySym left, right, up, down, escape, ret; + } menukeys; + struct + { char enable; char zoom; char title; Index: conf.h =================================================================== RCS file: /cvsroot/enlightenment/e16/e/src/conf.h,v retrieving revision 1.34 diff -u -p -r1.34 conf.h --- conf.h 3 Jul 2004 00:58:19 -0000 1.34 +++ conf.h 29 Jul 2004 15:49:59 -0000 @@ -155,6 +155,8 @@ #define CONTROL_ST_PAGER 1383 #define CONTROL_ST_WARPLIST 1384 +#define CONTROL_MENU_NAVIGATION_KEYS 1390 + #define ICLASS_NAME 350 #define ICLASS_NORMAL 351 #define ICLASS_CLICKED 352 Index: config.c =================================================================== RCS file: /cvsroot/enlightenment/e16/e/src/config.c,v retrieving revision 1.111 diff -u -p -r1.111 config.c --- config.c 25 Jul 2004 09:34:43 -0000 1.111 +++ config.c 29 Jul 2004 15:49:59 -0000 @@ -648,6 +648,7 @@ Config_Control(FILE * ConfigFile) */ char s[FILEPATH_LEN_MAX]; + char s2[FILEPATH_LEN_MAX]; int i1, i2, i3, fields; float f1; @@ -984,6 +985,30 @@ Config_Control(FILE * ConfigFile) case CONTROL_DOCKAPP_SUPPORT: Conf.dockapp_support = i2; break; + case CONTROL_MENU_NAVIGATION_KEYS: + sscanf(s, "%*i %*i %s", s2); + switch(i2) + { + case 0: + Conf.menukeys.left = XStringToKeysym(s2); + break; + case 1: + Conf.menukeys.right = XStringToKeysym(s2); + break; + case 2: + Conf.menukeys.up = XStringToKeysym(s2); + break; + case 3: + Conf.menukeys.down = XStringToKeysym(s2); + break; + case 4: + Conf.menukeys.escape = XStringToKeysym(s2); + break; + case 5: + Conf.menukeys.ret = XStringToKeysym(s2); + break; + } + break; default: RecoverUserConfig(); Alert(_("Warning: unable to determine what to do with\n" @@ -3927,6 +3952,12 @@ SaveUserControlConfig(FILE * autosavefil fprintf(autosavefile, "1383 %i\n", (int)Conf.st_trans.pager); fprintf(autosavefile, "1384 %i\n", (int)Conf.st_trans.warplist); #endif + fprintf(autosavefile, "1390 0 %s\n", XKeysymToString(Conf.menukeys.left)); + fprintf(autosavefile, "1390 1 %s\n", XKeysymToString(Conf.menukeys.right)); + fprintf(autosavefile, "1390 2 %s\n", XKeysymToString(Conf.menukeys.up)); + fprintf(autosavefile, "1390 3 %s\n", XKeysymToString(Conf.menukeys.down)); + fprintf(autosavefile, "1390 4 %s\n", XKeysymToString(Conf.menukeys.escape)); + fprintf(autosavefile, "1390 5 %s\n", XKeysymToString(Conf.menukeys.ret)); #ifdef HAS_XINERAMA fprintf(autosavefile, "2013 %i\n", (int)Conf.extra_head); #endif Index: menus.c =================================================================== RCS file: /cvsroot/enlightenment/e16/e/src/menus.c,v retrieving revision 1.147 diff -u -p -r1.147 menus.c --- menus.c 15 Jul 2004 23:31:02 -0000 1.147 +++ menus.c 29 Jul 2004 15:49:59 -0000 @@ -2330,6 +2330,28 @@ MenuFindContextEwin(Menu * m) return FindEwinSpawningMenu(m); } +KeySym +MenuKeyPressConversion(KeySym key) +{ + if (key == Conf.menukeys.left) + return XK_Left; + if (key == Conf.menukeys.right) + return XK_Right; + if (key == Conf.menukeys.up) + return XK_Up; + if (key == Conf.menukeys.down) + return XK_Down; + if (key == Conf.menukeys.escape) + return XK_Escape; + if (key == Conf.menukeys.ret) + return XK_Return; + + /* The key does not correspond to any set, use the default behavior + * associated to the key */ + return key; +} + + int MenusEventKeyPress(XEvent * ev) { @@ -2353,7 +2375,7 @@ MenusEventKeyPress(XEvent * ev) /* NB! m != NULL */ key = XLookupKeysym(&ev->xkey, 0); - switch (key) + switch (MenuKeyPressConversion(key)) { case XK_Escape: MenusHide(); Index: setup.c =================================================================== RCS file: /cvsroot/enlightenment/e16/e/src/setup.c,v retrieving revision 1.139 diff -u -p -r1.139 setup.c --- setup.c 25 Jul 2004 09:34:43 -0000 1.139 +++ setup.c 29 Jul 2004 15:50:00 -0000 @@ -456,6 +456,13 @@ SetupX(void) Conf.st_trans.warplist = ICLASS_ATTR_BG; #endif + Conf.menukeys.left = XK_Left; + Conf.menukeys.right = XK_Right; + Conf.menukeys.up = XK_Up; + Conf.menukeys.down = XK_Down; + Conf.menukeys.escape = XK_Escape; + Conf.menukeys.ret = XK_Return; + ScreenInit(); MenusInit();
pgpVJXhap2io1.pgp
Description: PGP signature