Added support for multiple commands per key/button mapping; elegant fix for issue #150
This commit is contained in:
parent
06164c29b7
commit
9c92de8584
|
@ -102,8 +102,10 @@ static const keymap_t keys[] = {
|
||||||
{ 0, XK_R, t_reload_all, (arg_t) None },
|
{ 0, XK_R, t_reload_all, (arg_t) None },
|
||||||
|
|
||||||
{ 0, XK_n, i_navigate, (arg_t) +1 },
|
{ 0, XK_n, i_navigate, (arg_t) +1 },
|
||||||
|
{ 0, XK_n, i_scroll_to_edge, (arg_t) (DIR_LEFT | DIR_UP) },
|
||||||
{ 0, XK_space, i_navigate, (arg_t) +1 },
|
{ 0, XK_space, i_navigate, (arg_t) +1 },
|
||||||
{ 0, XK_p, i_navigate, (arg_t) -1 },
|
{ 0, XK_p, i_navigate, (arg_t) -1 },
|
||||||
|
{ 0, XK_p, i_scroll_to_edge, (arg_t) (DIR_LEFT | DIR_UP) },
|
||||||
{ 0, XK_BackSpace, i_navigate, (arg_t) -1 },
|
{ 0, XK_BackSpace, i_navigate, (arg_t) -1 },
|
||||||
{ 0, XK_bracketright, i_navigate, (arg_t) +10 },
|
{ 0, XK_bracketright, i_navigate, (arg_t) +10 },
|
||||||
{ 0, XK_bracketleft, i_navigate, (arg_t) -10 },
|
{ 0, XK_bracketleft, i_navigate, (arg_t) -10 },
|
||||||
|
|
22
image.c
22
image.c
|
@ -687,20 +687,14 @@ bool img_pan_edge(img_t *img, direction_t dir)
|
||||||
ox = img->x;
|
ox = img->x;
|
||||||
oy = img->y;
|
oy = img->y;
|
||||||
|
|
||||||
switch (dir) {
|
if (dir & DIR_LEFT)
|
||||||
case DIR_LEFT:
|
img->x = 0;
|
||||||
img->x = 0;
|
if (dir & DIR_RIGHT)
|
||||||
break;
|
img->x = img->win->w - img->w * img->zoom;
|
||||||
case DIR_RIGHT:
|
if (dir & DIR_UP)
|
||||||
img->x = img->win->w - img->w * img->zoom;
|
img->y = 0;
|
||||||
break;
|
if (dir & DIR_DOWN)
|
||||||
case DIR_UP:
|
img->y = img->win->h - img->h * img->zoom;
|
||||||
img->y = 0;
|
|
||||||
break;
|
|
||||||
case DIR_DOWN:
|
|
||||||
img->y = img->win->h - img->h * img->zoom;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
img_check_pan(img, true);
|
img_check_pan(img, true);
|
||||||
|
|
||||||
|
|
12
main.c
12
main.c
|
@ -541,6 +541,7 @@ void on_keypress(XKeyEvent *kev)
|
||||||
unsigned int sh;
|
unsigned int sh;
|
||||||
KeySym ksym, shksym;
|
KeySym ksym, shksym;
|
||||||
char key;
|
char key;
|
||||||
|
bool dirty = false;
|
||||||
|
|
||||||
if (kev == NULL)
|
if (kev == NULL)
|
||||||
return;
|
return;
|
||||||
|
@ -571,16 +572,18 @@ void on_keypress(XKeyEvent *kev)
|
||||||
(cmds[keys[i].cmd].mode < 0 || cmds[keys[i].cmd].mode == mode))
|
(cmds[keys[i].cmd].mode < 0 || cmds[keys[i].cmd].mode == mode))
|
||||||
{
|
{
|
||||||
if (cmds[keys[i].cmd].func(keys[i].arg))
|
if (cmds[keys[i].cmd].func(keys[i].arg))
|
||||||
redraw();
|
dirty = true;
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (dirty)
|
||||||
|
redraw();
|
||||||
prefix = 0;
|
prefix = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void on_buttonpress(XButtonEvent *bev)
|
void on_buttonpress(XButtonEvent *bev)
|
||||||
{
|
{
|
||||||
int i, sel;
|
int i, sel;
|
||||||
|
bool dirty = false;
|
||||||
static Time firstclick;
|
static Time firstclick;
|
||||||
|
|
||||||
if (bev == NULL)
|
if (bev == NULL)
|
||||||
|
@ -597,10 +600,11 @@ void on_buttonpress(XButtonEvent *bev)
|
||||||
(cmds[buttons[i].cmd].mode < 0 || cmds[buttons[i].cmd].mode == mode))
|
(cmds[buttons[i].cmd].mode < 0 || cmds[buttons[i].cmd].mode == mode))
|
||||||
{
|
{
|
||||||
if (cmds[buttons[i].cmd].func(buttons[i].arg))
|
if (cmds[buttons[i].cmd].func(buttons[i].arg))
|
||||||
redraw();
|
dirty = true;
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (dirty)
|
||||||
|
redraw();
|
||||||
} else {
|
} else {
|
||||||
/* thumbnail mode (hard-coded) */
|
/* thumbnail mode (hard-coded) */
|
||||||
switch (bev->button) {
|
switch (bev->button) {
|
||||||
|
|
Loading…
Reference in New Issue