diff options
-rw-r--r-- | ChangeLog | 4 | ||||
-rw-r--r-- | man/feh.pre | 21 | ||||
-rw-r--r-- | src/help.raw | 1 | ||||
-rw-r--r-- | src/keyevents.c | 6 | ||||
-rw-r--r-- | src/menu.c | 12 | ||||
-rw-r--r-- | src/options.c | 4 | ||||
-rw-r--r-- | src/options.h | 2 | ||||
-rw-r--r-- | src/slideshow.c | 50 |
8 files changed, 91 insertions, 9 deletions
@@ -1,3 +1,7 @@ +git HEAD + * Add --keep-zoom-vp option to keep zoom and offsets when switching + images (patch by sdaau). Press 'k' to toggle it. + Mon, 24 Dec 2012 15:45:54 +0100 Daniel Friesel <derf+feh@finalrewind.org> * Release v2.8 diff --git a/man/feh.pre b/man/feh.pre index e9ee3b7..f24729d 100644 --- a/man/feh.pre +++ b/man/feh.pre @@ -375,6 +375,11 @@ with .Qq Nm in the name. . +.It Cm --keep-zoom-vp +. +When switching images, keep zoom and viewport settings +.Pq zoom level and X, Y offsets +. .It Cm -l , --list . Don't display images. Analyze them and display an @@ -1048,16 +1053,16 @@ and save the caption, or escape to cancel editing. Note that you can insert an actual newline into the caption using .Aq CTRL+return . . -.It e Bq toggle_exif -. -.Pq only if compiled with exif=1 -Toggle EXIF tag display -. .It d Bq toggle_filenames . Toggle filename display .Pq see Cm --draw-filename . +.It e Bq toggle_exif +. +.Pq only if compiled with exif=1 +Toggle EXIF tag display +. .It f Bq save_filelist . Save the current filelist as @@ -1074,6 +1079,12 @@ change slides based on Toggle info display .Pq see Cm --info . +.It k Bq toggle_keep_vp +. +Toggle zoom and viewport keeping. When enabled, +.Nm +will keep zoom and X, Y offset when switching images. +. .It m Bq toggle_menu . Show menu. Use the arrow keys and return to select items, diff --git a/src/help.raw b/src/help.raw index 8e25b00..27e3b6c 100644 --- a/src/help.raw +++ b/src/help.raw @@ -28,6 +28,7 @@ OPTIONS mode or when window geometry is fixed. If combined with --auto-zoom, zooming will be limited to the the size. + --keep-zoom-vp Keep viewport zoom and settings while changing images -w, --multiwindow Open all files at once, one window per image -x, --borderless Create borderless windows -d, --draw-filename Show the filename in the image window diff --git a/src/keyevents.c b/src/keyevents.c index 470d624..9bda112 100644 --- a/src/keyevents.c +++ b/src/keyevents.c @@ -154,6 +154,7 @@ void init_keyevents(void) { feh_set_kb(&keys.mirror, 0, XK_bar, 0, 0, 0, 0); feh_set_kb(&keys.reload_minus, 0, XK_minus, 0, 0, 0, 0); feh_set_kb(&keys.reload_plus, 0, XK_plus, 0, 0, 0, 0); + feh_set_kb(&keys.toggle_keep_vp, 0, XK_k, 0, 0, 0, 0); home = getenv("HOME"); if (!home) @@ -307,6 +308,8 @@ void init_keyevents(void) { cur_kb = &keys.reload_minus; else if (!strcmp(action, "reload_plus")) cur_kb = &keys.reload_plus; + else if (!strcmp(action, "toggle_keep_vp")) + cur_kb = &keys.toggle_keep_vp; else weprintf("keys: Invalid action: %s", action); @@ -761,5 +764,8 @@ void feh_event_handle_keypress(XEvent * ev) else if (opt.verbose) weprintf("Cannot set RELOAD lower than 1 second."); } + else if (feh_is_kp(&keys.toggle_keep_vp, keysym, state)) { + opt.keep_zoom_vp = !opt.keep_zoom_vp; + } return; } @@ -56,7 +56,7 @@ enum { CB_SORT_FILENAME, CB_SORT_IMAGENAME, CB_SORT_FILESIZE, CB_SORT_RANDOMIZE, CB_SAVE_IMAGE, CB_SAVE_FILELIST, CB_FIT, CB_OPT_DRAW_FILENAME, CB_OPT_DRAW_ACTIONS, CB_OPT_KEEP_HTTP, CB_OPT_FREEZE_WINDOW, - CB_OPT_FULLSCREEN, CB_EDIT_ROTATE, CB_OPT_AUTO_ZOOM + CB_OPT_FULLSCREEN, CB_EDIT_ROTATE, CB_OPT_AUTO_ZOOM, CB_OPT_KEEP_ZOOM_VP }; feh_menu *feh_menu_new(void) @@ -1326,6 +1326,14 @@ void feh_menu_cb(feh_menu * m, feh_menu_item * i, int action, unsigned short dat opt.zoom_mode = 0; winwidget_rerender_all(1); break; + case CB_OPT_KEEP_ZOOM_VP: + MENU_ITEM_TOGGLE(i); + if (MENU_ITEM_IS_ON(i)) + opt.keep_zoom_vp = 1; + else + opt.keep_zoom_vp = 0; + winwidget_rerender_all(1); + break; } return; } @@ -1381,6 +1389,8 @@ static feh_menu *feh_menu_func_gen_options(feh_menu * m) CB_OPT_FREEZE_WINDOW, 0, NULL, opt.geom_flags); feh_menu_add_toggle_entry(mm, "Fullscreen", NULL, CB_OPT_FULLSCREEN, 0, NULL, m->fehwin->full_screen); + feh_menu_add_toggle_entry(mm, "Keep viewport zoom & pos", NULL, + CB_OPT_KEEP_ZOOM_VP, 0, NULL, opt.keep_zoom_vp); feh_menu_add_entry(mm, NULL, NULL, 0, 0, NULL); diff --git a/src/options.c b/src/options.c index 240b0d6..cdd37d1 100644 --- a/src/options.c +++ b/src/options.c @@ -397,6 +397,7 @@ static void feh_parse_option_array(int argc, char **argv, int finalrun) {"info" , 1, 0, 234}, {"force-aliasing", 0, 0, 235}, {"no-fehbg" , 0, 0, 236}, + {"keep-zoom-vp" , 0, 0, 237}, {0, 0, 0, 0} }; @@ -722,6 +723,9 @@ static void feh_parse_option_array(int argc, char **argv, int finalrun) case 236: opt.no_fehbg = 1; break; + case 237: + opt.keep_zoom_vp = 1; + break; default: break; } diff --git a/src/options.h b/src/options.h index d30c396..f3f49eb 100644 --- a/src/options.h +++ b/src/options.h @@ -72,6 +72,7 @@ struct __fehoptions { unsigned char text_bg; unsigned char image_bg; unsigned char no_fehbg; + unsigned char keep_zoom_vp; char *output_file; char *output_dir; @@ -189,6 +190,7 @@ struct __fehkb { struct __fehkey toggle_fullscreen; struct __fehkey reload_minus; struct __fehkey reload_plus; + struct __fehkey toggle_keep_vp; }; struct __fehbutton { diff --git a/src/slideshow.c b/src/slideshow.c index d79c859..65aae3d 100644 --- a/src/slideshow.c +++ b/src/slideshow.c @@ -149,6 +149,16 @@ void feh_reload_image(winwidget w, int resize, int force_new) Imlib_Image tmp; int old_w, old_h; + unsigned char tmode =0; + int tim_x =0; + int tim_y =0; + double tzoom =0; + + tmode = w->mode; + tim_x = w->im_x; + tim_y = w->im_y; + tzoom = w->zoom; + if (!w->file) { im_weprintf(w, "couldn't reload, this image has no file associated with it."); winwidget_render_image(w, 0, 0); @@ -216,7 +226,16 @@ void feh_reload_image(winwidget w, int resize, int force_new) w->im_w = gib_imlib_image_get_width(w->im); w->im_h = gib_imlib_image_get_height(w->im); } - winwidget_render_image(w, resize, 0); + if (opt.keep_zoom_vp) { + /* put back in: */ + w->mode = tmode; + w->im_x = tim_x; + w->im_y = tim_y; + w->zoom = tzoom; + winwidget_render_image(w, 0, 0); + } else { + winwidget_render_image(w, resize, 0); + } winwidget_rename(w, title); free(title); @@ -236,6 +255,11 @@ void slideshow_change_image(winwidget winwid, int change, int render) int our_filelist_len = filelist_len; char *s; + unsigned char tmode =0; + int tim_x =0; + int tim_y =0; + double tzoom =0; + /* Without this, clicking a one-image slideshow reloads it. Not very * intelligent behaviour :-) */ if (filelist_len < 2 && opt.cycle_once == 0) @@ -308,6 +332,14 @@ void slideshow_change_image(winwidget winwid, int change, int render) last = NULL; } + if (opt.keep_zoom_vp) { + /* pre loadimage - record settings */ + tmode = winwid->mode; + tim_x = winwid->im_x; + tim_y = winwid->im_y; + tzoom = winwid->zoom; + } + if ((winwidget_loadimage(winwid, FEH_FILE(current_file->data))) != 0) { winwid->mode = MODE_NORMAL; @@ -318,8 +350,20 @@ void slideshow_change_image(winwidget winwid, int change, int render) winwidget_reset_image(winwid); winwid->im_w = gib_imlib_image_get_width(winwid->im); winwid->im_h = gib_imlib_image_get_height(winwid->im); - if (render) - winwidget_render_image(winwid, 1, 0); + if (opt.keep_zoom_vp) { + /* put back in: */ + winwid->mode = tmode; + winwid->im_x = tim_x; + winwid->im_y = tim_y; + winwid->zoom = tzoom; + } + if (render) { + if (opt.keep_zoom_vp) { + winwidget_render_image(winwid, 0, 0); + } else { + winwidget_render_image(winwid, 1, 0); + } + } s = slideshow_create_name(FEH_FILE(current_file->data), winwid); winwidget_rename(winwid, s); |