aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--config.def.h2
-rw-r--r--image.c22
-rw-r--r--main.c12
-rw-r--r--types.h8
4 files changed, 22 insertions, 22 deletions
diff --git a/config.def.h b/config.def.h
index 5d1a6e2..2742e65 100644
--- a/config.def.h
+++ b/config.def.h
@@ -102,8 +102,10 @@ static const keymap_t keys[] = {
{ 0, XK_R, t_reload_all, (arg_t) None },
{ 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_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_bracketright, i_navigate, (arg_t) +10 },
{ 0, XK_bracketleft, i_navigate, (arg_t) -10 },
diff --git a/image.c b/image.c
index 7312e73..9754e7a 100644
--- a/image.c
+++ b/image.c
@@ -687,20 +687,14 @@ bool img_pan_edge(img_t *img, direction_t dir)
ox = img->x;
oy = img->y;
- switch (dir) {
- case DIR_LEFT:
- img->x = 0;
- break;
- case DIR_RIGHT:
- img->x = img->win->w - img->w * img->zoom;
- break;
- case DIR_UP:
- img->y = 0;
- break;
- case DIR_DOWN:
- img->y = img->win->h - img->h * img->zoom;
- break;
- }
+ if (dir & DIR_LEFT)
+ img->x = 0;
+ if (dir & DIR_RIGHT)
+ img->x = img->win->w - img->w * img->zoom;
+ if (dir & DIR_UP)
+ img->y = 0;
+ if (dir & DIR_DOWN)
+ img->y = img->win->h - img->h * img->zoom;
img_check_pan(img, true);
diff --git a/main.c b/main.c
index 86b97b0..6db8a44 100644
--- a/main.c
+++ b/main.c
@@ -541,6 +541,7 @@ void on_keypress(XKeyEvent *kev)
unsigned int sh;
KeySym ksym, shksym;
char key;
+ bool dirty = false;
if (kev == NULL)
return;
@@ -571,16 +572,18 @@ void on_keypress(XKeyEvent *kev)
(cmds[keys[i].cmd].mode < 0 || cmds[keys[i].cmd].mode == mode))
{
if (cmds[keys[i].cmd].func(keys[i].arg))
- redraw();
- break;
+ dirty = true;
}
}
+ if (dirty)
+ redraw();
prefix = 0;
}
void on_buttonpress(XButtonEvent *bev)
{
int i, sel;
+ bool dirty = false;
static Time firstclick;
if (bev == NULL)
@@ -597,10 +600,11 @@ void on_buttonpress(XButtonEvent *bev)
(cmds[buttons[i].cmd].mode < 0 || cmds[buttons[i].cmd].mode == mode))
{
if (cmds[buttons[i].cmd].func(buttons[i].arg))
- redraw();
- break;
+ dirty = true;
}
}
+ if (dirty)
+ redraw();
} else {
/* thumbnail mode (hard-coded) */
switch (bev->button) {
diff --git a/types.h b/types.h
index 2e250ce..5434588 100644
--- a/types.h
+++ b/types.h
@@ -32,10 +32,10 @@ typedef enum {
} appmode_t;
typedef enum {
- DIR_LEFT,
- DIR_RIGHT,
- DIR_UP,
- DIR_DOWN
+ DIR_LEFT = 1,
+ DIR_RIGHT = 2,
+ DIR_UP = 4,
+ DIR_DOWN = 8
} direction_t;
typedef enum {