diff options
author | Daniel Friesel <derf@derf.homelinux.org> | 2010-08-15 15:06:04 +0200 |
---|---|---|
committer | Daniel Friesel <derf@derf.homelinux.org> | 2010-08-15 15:06:04 +0200 |
commit | 7c031ab92eb26641e0b14fa8b7f8e20183c7cb25 (patch) | |
tree | 835b7efd1861c4e6fb343da75d2fcfc26ec4ca90 | |
parent | ccbebcbd7adf0663cae9a04b44f094163a3fd157 (diff) |
Improve keyboard zoom mode
-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: |