diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/events.c | 8 | ||||
-rw-r--r-- | src/feh.h | 3 | ||||
-rw-r--r-- | src/keyevents.c | 8 |
3 files changed, 15 insertions, 4 deletions
diff --git a/src/events.c b/src/events.c index def4651..2b8abdd 100644 --- a/src/events.c +++ b/src/events.c @@ -336,15 +336,15 @@ static void feh_event_handle_MotionNotify(XEvent * ev) winwid->zoom = winwid->old_zoom + ( ((double) ev->xmotion.x - (double) winwid->click_offset_x) / 128.0); - /*/ ((double) (winwid->click_offset_x + 1)));*/ else winwid->zoom = winwid->old_zoom - ( ((double) winwid->click_offset_x - (double) ev->xmotion.x) / 128.0); - /*/ ((double) (winwid->click_offset_x + 1)));*/ - if (winwid->zoom < 0.01) - winwid->zoom = 0.01; + if (winwid->zoom < ZOOM_MIN) + winwid->zoom = ZOOM_MIN; + else if (winwid->zoom > ZOOM_MAX) + winwid->zoom = ZOOM_MAX; /* center around click_offset */ winwid->im_x = winwid->click_offset_x @@ -107,6 +107,9 @@ enum image_bg { IMAGE_BG_CHECKS = 0, IMAGE_BG_BLACK, IMAGE_BG_WHITE }; #define INPLACE_EDIT_FLIP -1 #define INPLACE_EDIT_MIRROR -2 +#define ZOOM_MIN 0.002 +#define ZOOM_MAX 2000 + typedef void (*sighandler_t) (int); int feh_main_iteration(int block); diff --git a/src/keyevents.c b/src/keyevents.c index 60663db..942a88b 100644 --- a/src/keyevents.c +++ b/src/keyevents.c @@ -561,6 +561,10 @@ void feh_event_handle_keypress(XEvent * ev) else if (feh_is_kp(&keys.zoom_in, keysym, state)) { winwid->old_zoom = winwid->zoom; winwid->zoom = winwid->zoom * 1.25; + + if (winwid->zoom > ZOOM_MAX) + winwid->zoom = ZOOM_MAX; + 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) / @@ -571,6 +575,10 @@ void feh_event_handle_keypress(XEvent * ev) else if (feh_is_kp(&keys.zoom_out, keysym, state)) { winwid->old_zoom = winwid->zoom; winwid->zoom = winwid->zoom * 0.80; + + if (winwid->zoom < ZOOM_MIN) + winwid->zoom = ZOOM_MIN; + 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) / |