Made key mappings mode-dependent

This commit is contained in:
Bert 2011-02-17 15:08:58 +01:00
parent ac747c3f91
commit f554cdf60e
1 changed files with 111 additions and 105 deletions

28
main.c
View File

@ -284,14 +284,8 @@ void on_keypress(XKeyEvent *kev) {
XLookupString(kev, &key, 1, &ksym, NULL);
changed = 0;
if (mode == MODE_NORMAL) {
switch (ksym) {
case XK_Escape:
cleanup();
exit(2);
case XK_q:
cleanup();
exit(0);
/* navigate image list */
case XK_n:
case XK_space:
@ -377,10 +371,6 @@ void on_keypress(XKeyEvent *kev) {
break;
/* control window */
case XK_f:
win_toggle_fullscreen(&win);
/* render on next configurenotify */
break;
case XK_W:
x = win.x + img.x;
y = win.y + img.y;
@ -401,6 +391,22 @@ void on_keypress(XKeyEvent *kev) {
changed = load_image();
break;
}
} else {
}
/* common key mappings */
switch (ksym) {
case XK_Escape:
cleanup();
exit(2);
case XK_q:
cleanup();
exit(0);
case XK_f:
win_toggle_fullscreen(&win);
/* render on next configurenotify */
break;
}
if (changed)
redraw();