summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2011-09-28 17:30:10 +0200
committerDaniel Friesel <derf@finalrewind.org>2011-09-28 17:30:10 +0200
commit2963a156abf75542a3171dad45ddc9bcce2eb37f (patch)
tree14f8e3f5c7ddb610b83a409b700cdd3da721ce03
parent4807123ba77c4018a1fcfa31cee04001c07ba4c5 (diff)
downloadfeh-2963a156abf75542a3171dad45ddc9bcce2eb37f.zip
Set max/min zoom for both key and mouse zooming
-rw-r--r--src/events.c8
-rw-r--r--src/feh.h3
-rw-r--r--src/keyevents.c8
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
diff --git a/src/feh.h b/src/feh.h
index 4de4632..d4a1ff7 100644
--- a/src/feh.h
+++ b/src/feh.h
@@ -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) /