Skip to content

Commit 437609a

Browse files
committed
add an option to change the zoom rate of zoom-mode
1 parent 989b90c commit 437609a

File tree

3 files changed

+16
-6
lines changed

3 files changed

+16
-6
lines changed

src/events.c

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,6 @@ fehkey *feh_str_to_kb(char *action);
4040

4141
feh_event_handler *ev_handler[LASTEvent];
4242

43-
static const double zoom_rate = M_LN2 / 128.0;
44-
4543
static void feh_event_handle_ButtonPress(XEvent * ev);
4644
static void feh_event_handle_ButtonRelease(XEvent * ev);
4745
static void feh_event_handle_LeaveNotify(XEvent * ev);
@@ -244,7 +242,7 @@ static void feh_event_handle_ButtonPress(XEvent * ev)
244242
D(("click offset is %d,%d\n", ev->xbutton.x, ev->xbutton.y));
245243
winwid->click_offset_x = ev->xbutton.x;
246244
winwid->click_offset_y = ev->xbutton.y;
247-
winwid->zoom_old = round(log(winwid->zoom) / zoom_rate);
245+
winwid->zoom_old = round(log(winwid->zoom) / opt.zoom_rate);
248246

249247
/* required to adjust the image position in zoom mode */
250248
winwid->im_click_offset_x = (winwid->click_offset_x
@@ -553,9 +551,9 @@ static void feh_event_handle_MotionNotify(XEvent * ev)
553551
while (XCheckTypedWindowEvent(disp, ev->xmotion.window, MotionNotify, ev));
554552

555553
winwid = winwidget_get_from_window(ev->xmotion.window);
556-
if (winwid) {
554+
if (winwid && opt.zoom_rate > 0) {
557555
int step = winwid->zoom_old + ev->xmotion.x - winwid->click_offset_x;
558-
winwid->zoom = exp(step * zoom_rate);
556+
winwid->zoom = exp(step * opt.zoom_rate);
559557

560558
if (winwid->zoom < ZOOM_MIN)
561559
winwid->zoom = ZOOM_MIN;

src/options.c

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ void init_parse_options(int argc, char **argv)
6363
opt.font = NULL;
6464
opt.max_height = opt.max_width = UINT_MAX;
6565

66+
opt.zoom_rate = M_LN2 / 128.0;
6667
opt.step_rate = M_LN2 / 3.0;
6768

6869
opt.start_list_at = NULL;
@@ -395,6 +396,7 @@ static void feh_parse_option_array(int argc, char **argv, int finalrun)
395396
{"bg-center" , 0, 0, OPTION_bg_center},
396397
{"bg-scale" , 0, 0, OPTION_bg_scale},
397398
{"zoom" , 1, 0, OPTION_zoom},
399+
{"zoom-rate" , 1, 0, OPTION_zoom_rate},
398400
{"zoom-step" , 1, 0, OPTION_zoom_step},
399401
{"no-screen-clip", 0, 0, OPTION_no_screen_clip},
400402
{"index-info" , 1, 0, OPTION_index_info},
@@ -845,10 +847,18 @@ static void feh_parse_option_array(int argc, char **argv, int finalrun)
845847
case OPTION_window_id:
846848
opt.x11_windowid = strtol(optarg, NULL, 0);
847849
break;
850+
case OPTION_zoom_rate:
851+
opt.zoom_rate = atof(optarg);
852+
if ((opt.zoom_rate <= 0)) {
853+
weprintf("Zoom mode disabled due to --zoom-rate=%f", opt.zoom_rate);
854+
} else {
855+
opt.zoom_rate = M_LN2 / opt.zoom_rate;
856+
}
857+
break;
848858
case OPTION_zoom_step:
849859
opt.step_rate = atof(optarg);
850860
if ((opt.step_rate <= 0)) {
851-
weprintf("Zooming disabled due to --zoom-step=%f", opt.step_rate);
861+
weprintf("Zoom steps disabled due to --zoom-step=%f", opt.step_rate);
852862
} else {
853863
opt.step_rate = M_LN2 / opt.step_rate;
854864
}

src/options.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ struct __fehoptions {
127127
int offset_y;
128128
int default_zoom;
129129
int zoom_mode;
130+
double zoom_rate;
130131
double step_rate;
131132
unsigned char adjust_reload;
132133
int xinerama_index;
@@ -216,6 +217,7 @@ OPTION_bg_scale,
216217
OPTION_bg_fill,
217218
OPTION_bg_max,
218219
OPTION_zoom,
220+
OPTION_zoom_rate,
219221
OPTION_zoom_step,
220222
OPTION_zoom_in_rate,
221223
OPTION_zoom_out_rate,

0 commit comments

Comments
 (0)