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 /src | |
parent | ccbebcbd7adf0663cae9a04b44f094163a3fd157 (diff) |
Improve keyboard zoom mode
Diffstat (limited to 'src')
-rw-r--r-- | src/keyevents.c | 15 |
1 files changed, 12 insertions, 3 deletions
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: |