summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/events.c2
-rw-r--r--src/keyevents.c18
-rw-r--r--src/winwidget.c7
-rw-r--r--src/winwidget.h1
4 files changed, 21 insertions, 7 deletions
diff --git a/src/events.c b/src/events.c
index 0d5e07d..9fb2379 100644
--- a/src/events.c
+++ b/src/events.c
@@ -235,6 +235,7 @@ static void feh_event_handle_ButtonPress(XEvent * ev)
winwid->click_offset_x = ev->xbutton.x;
winwid->click_offset_y = ev->xbutton.y;
winwid->old_zoom = winwid->zoom;
+ winwid->has_manual_zoom = 1;
/* required to adjust the image position in zoom mode */
winwid->im_click_offset_x = (winwid->click_offset_x
@@ -332,6 +333,7 @@ static void feh_event_handle_ButtonRelease(XEvent * ev)
&& (ev->xbutton.x == winwid->click_offset_x)
&& (ev->xbutton.y == winwid->click_offset_y)) {
winwid->zoom = 1.0;
+ winwid->has_manual_zoom = 0;
winwidget_center_image(winwid);
} else
winwidget_sanitise_offsets(winwid);
diff --git a/src/keyevents.c b/src/keyevents.c
index 0ada751..c551ae3 100644
--- a/src/keyevents.c
+++ b/src/keyevents.c
@@ -573,6 +573,9 @@ void feh_event_handle_keypress(XEvent * ev)
feh_event_invoke_action(winwid, 9);
}
else if (feh_is_kp(&keys.zoom_in, keysym, state)) {
+ if (!winwid->has_manual_zoom)
+ winwid->has_manual_zoom = 1;
+
winwid->old_zoom = winwid->zoom;
winwid->zoom = winwid->zoom * 1.25;
@@ -587,6 +590,9 @@ void feh_event_handle_keypress(XEvent * ev)
winwidget_render_image(winwid, 0, 0);
}
else if (feh_is_kp(&keys.zoom_out, keysym, state)) {
+ if (!winwid->has_manual_zoom)
+ winwid->has_manual_zoom = 1;
+
winwid->old_zoom = winwid->zoom;
winwid->zoom = winwid->zoom * 0.80;
@@ -601,17 +607,17 @@ void feh_event_handle_keypress(XEvent * ev)
winwidget_render_image(winwid, 0, 0);
}
else if (feh_is_kp(&keys.zoom_default, keysym, state)) {
+ if (!winwid->has_manual_zoom)
+ winwid->has_manual_zoom = 1;
+
winwid->zoom = 1.0;
- /* --scale-down will revert our operation if old_zoom == 1.0 */
- if (opt.scale_down)
- winwid->old_zoom = 1.001;
winwidget_center_image(winwid);
winwidget_render_image(winwid, 0, 0);
- /* --scale-down will also do weird stuff if zoom is 1.0 */
- if (opt.scale_down)
- winwid->zoom = 1.001;
}
else if (feh_is_kp(&keys.zoom_fit, keysym, state)) {
+ if (!winwid->has_manual_zoom)
+ winwid->has_manual_zoom = 1;
+
feh_calc_needed_zoom(&winwid->zoom, winwid->im_w, winwid->im_h, winwid->w, winwid->h);
winwidget_center_image(winwid);
winwidget_render_image(winwid, 0, 0);
diff --git a/src/winwidget.c b/src/winwidget.c
index ae34045..36720ac 100644
--- a/src/winwidget.c
+++ b/src/winwidget.c
@@ -71,6 +71,7 @@ static winwidget winwidget_allocate(void)
ret->im_y = 0;
ret->zoom = 1.0;
ret->old_zoom = 1.0;
+ ret->has_manual_zoom = 0;
ret->click_offset_x = 0;
ret->click_offset_y = 0;
@@ -394,6 +395,9 @@ void winwidget_render_image(winwidget winwid, int resize, int force_alias)
if (winwid->im_y > winwid->h)
winwid->im_y = winwid->h;
+ if (!winwid->has_manual_zoom && winwid->zoom < 1.0)
+ winwid->zoom = 1.0;
+
D(("winwidget_render_image resize %d force_alias %d im %dx%d\n",
resize, force_alias, winwid->im_w, winwid->im_h));
@@ -401,7 +405,7 @@ void winwidget_render_image(winwidget winwid, int resize, int force_alias)
if (!winwid->full_screen && opt.scale_down && ((winwid->w < winwid->im_w)
|| (winwid->h < winwid->im_h)) &&
- (winwid->old_zoom == 1.0)) {
+ (!winwid->has_manual_zoom)) {
D(("scaling down image %dx%d\n", winwid->w, winwid->h));
feh_calc_needed_zoom(&(winwid->zoom), winwid->im_w, winwid->im_h, winwid->w, winwid->h);
@@ -950,6 +954,7 @@ void feh_debug_print_winwid(winwidget w)
void winwidget_reset_image(winwidget winwid)
{
+ winwid->has_manual_zoom = 0;
winwid->zoom = 1.0;
winwid->old_zoom = 1.0;
winwid->im_x = 0;
diff --git a/src/winwidget.h b/src/winwidget.h
index 33ad945..3a99868 100644
--- a/src/winwidget.h
+++ b/src/winwidget.h
@@ -108,6 +108,7 @@ struct __winwidget {
*/
double zoom;
double old_zoom;
+ unsigned char has_manual_zoom;
int click_offset_x;
int click_offset_y;