diff options
-rw-r--r-- | ChangeLog | 2 | ||||
-rw-r--r-- | src/keyevents.c | 15 |
2 files changed, 14 insertions, 3 deletions
@@ -8,6 +8,8 @@ git HEAD and -J for --thumb-redraw * Patch by Noel Cragg: Improve support for tiling window managers * Set correct window title when starting feh in paused mode + * Add Up/Down keys for zooming + * When zooming via keyboard: Always zoom around the center of the window Fri, 25 Jun 2010 16:07:20 +0200 Daniel Friesel <derf@chaosdorf.de> diff --git a/src/keyevents.c b/src/keyevents.c index 6a5a2d0..5ca57bd 100644 --- a/src/keyevents.c +++ b/src/keyevents.c @@ -261,16 +261,25 @@ void feh_event_handle_keypress(XEvent * ev) case XK_Up: /* erroneously recognized as '+' in the *kbuf switch. Work around this. */ len = 0; + winwid->old_zoom = winwid->zoom; winwid->zoom = winwid->zoom * 1.25; - /* TODO: Center only around current view */ - winwidget_center_image(winwid); + winwid->im_x = (winwid->w / 2) - (((winwid->w / 2) - winwid->im_x) / + winwid->old_zoom * winwid->zoom); + winwid->im_y = (winwid->h / 2) - (((winwid->h / 2) - winwid->im_y) / + winwid->old_zoom * winwid->zoom); + winwidget_sanitise_offsets(winwid); winwidget_render_image(winwid, 0, 1); break; case XK_KP_Subtract: case XK_Down: len = 0; + winwid->old_zoom = winwid->zoom; winwid->zoom = winwid->zoom * 0.75; - winwidget_center_image(winwid); + winwid->im_x = (winwid->w / 2) - (((winwid->w / 2) - winwid->im_x) / + winwid->old_zoom * winwid->zoom); + winwid->im_y = (winwid->h / 2) - (((winwid->h / 2) - winwid->im_y) / + winwid->old_zoom * winwid->zoom); + winwidget_sanitise_offsets(winwid); winwidget_render_image(winwid, 0, 1); break; case XK_KP_Multiply: |