summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2011-01-14 23:54:35 +0100
committerDaniel Friesel <derf@finalrewind.org>2011-01-14 23:54:35 +0100
commite406710610d45e51f52e827e2d0ad77b16d6fbe8 (patch)
tree1c7050223f965dba57342321cbce545514952e55
parent939b2b178c876427a6dcfa89b31080386de992dd (diff)
Configurable menu keybindings, too.
-rw-r--r--src/keyevents.c46
-rw-r--r--src/options.h6
2 files changed, 32 insertions, 20 deletions
diff --git a/src/keyevents.c b/src/keyevents.c
index 5b57893..6560aaa 100644
--- a/src/keyevents.c
+++ b/src/keyevents.c
@@ -68,12 +68,18 @@ void init_keyevents(void) {
char *home, *confpath;
char line[128];
char action[32], k1[32], k2[32], k3[32];
- fehkb *cur_kb = NULL;
+ struct __fehkey *cur_kb = NULL;
FILE *conf = NULL;
int read = 0;
memset(&keys, 0, sizeof(keys));
+ feh_set_kb(&keys.menu_close, 0, XK_Escape , 0, 0 , 0, 0);
+ feh_set_kb(&keys.menu_parent,0, XK_Left , 0, 0 , 0, 0);
+ feh_set_kb(&keys.menu_down , 0, XK_Down , 0, 0 , 0, 0);
+ feh_set_kb(&keys.menu_up , 0, XK_Up , 0, 0 , 0, 0);
+ feh_set_kb(&keys.menu_child, 0, XK_Right , 0, 0 , 0, 0);
+ feh_set_kb(&keys.menu_select,0, XK_Return , 0, XK_space , 0, 0);
feh_set_kb(&keys.move_right, 0, XK_KP_Left , 4, XK_Left , 0, 0);
feh_set_kb(&keys.move_left , 0, XK_KP_Right , 4, XK_Right , 0, 0);
feh_set_kb(&keys.move_up , 0, XK_KP_Down , 4, XK_Down , 0, 0);
@@ -142,7 +148,19 @@ void init_keyevents(void) {
if ((read == EOF) || (read < 2))
continue;
- if (!strcmp(action, "move_right"))
+ if (!strcmp(action, "menu_close"))
+ cur_kb = &keys.menu_close;
+ else if (!strcmp(action, "menu_parent"))
+ cur_kb = &keys.menu_parent;
+ else if (!strcmp(action, "menu_down"))
+ cur_kb = &keys.menu_down;
+ else if (!strcmp(action, "menu_up"))
+ cur_kb = &keys.menu_up;
+ else if (!strcmp(action, "menu_child"))
+ cur_kb = &keys.menu_child;
+ else if (!strcmp(action, "menu_select"))
+ cur_kb = &keys.menu_select;
+ else if (!strcmp(action, "move_right"))
cur_kb = &keys.move_right;
else if (!strcmp(action, "move_left"))
cur_kb = &keys.move_left;
@@ -300,30 +318,18 @@ void feh_event_handle_keypress(XEvent * ev)
/* menus are showing, so this is a menu control keypress */
if (ev->xbutton.window == menu_cover) {
selected_item = feh_menu_find_selected_r(menu_root, &selected_menu);
- switch (keysym) {
- case XK_Escape:
+ if (feh_is_kp(&keys.menu_close, keysym, kev->state))
feh_menu_hide(menu_root, True);
- break;
- case XK_Left:
+ else if (feh_is_kp(&keys.menu_parent, keysym, kev->state))
feh_menu_select_parent(selected_menu);
- break;
- case XK_Down:
+ else if (feh_is_kp(&keys.menu_down, keysym, kev->state))
feh_menu_select_next(selected_menu, selected_item);
- break;
- case XK_Up:
+ else if (feh_is_kp(&keys.menu_up, keysym, kev->state))
feh_menu_select_prev(selected_menu, selected_item);
- break;
- case XK_Right:
+ else if (feh_is_kp(&keys.menu_child, keysym, kev->state))
feh_menu_select_submenu(selected_menu);
- break;
- case XK_Return:
- case XK_space:
+ else if (feh_is_kp(&keys.menu_select, keysym, kev->state))
feh_menu_item_activate(selected_menu, selected_item);
- break;
- default:
- break;
- }
-
return;
}
diff --git a/src/options.h b/src/options.h
index 2030570..fc8fa02 100644
--- a/src/options.h
+++ b/src/options.h
@@ -136,6 +136,12 @@ struct __fehkey {
};
struct __fehkb {
+ struct __fehkey menu_close;
+ struct __fehkey menu_parent;
+ struct __fehkey menu_down;
+ struct __fehkey menu_up;
+ struct __fehkey menu_child;
+ struct __fehkey menu_select;
struct __fehkey move_right;
struct __fehkey prev_img;
struct __fehkey move_left;