From fb1cfca824b9229e110386e35112a0ad8f552553 Mon Sep 17 00:00:00 2001 From: Olof-Joachim Frahm Date: Tue, 2 Oct 2018 23:36:29 +0200 Subject: Actually remove collage mode after ~7 years. --- src/main.c | 2 -- 1 file changed, 2 deletions(-) (limited to 'src/main.c') diff --git a/src/main.c b/src/main.c index 1a76e2d..eff664a 100644 --- a/src/main.c +++ b/src/main.c @@ -59,8 +59,6 @@ int main(int argc, char **argv) if (opt.index) init_index_mode(); - else if (opt.collage) - init_collage_mode(); else if (opt.multiwindow) init_multiwindow_mode(); else if (opt.list || opt.customlist) -- cgit v1.2.3 From 9803fc41e8e6a820634f41d2196bdced7cbbc99f Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Wed, 17 Oct 2018 20:40:17 +0200 Subject: Use random() instead of rand() to increase portability Quoting glibc rand(3): The versions of rand() and srand() in the Linux C Library use the same random number generator as random(3) and srandom(3), so the lower-order bits should be as random as the higher-order bits. However, on older rand() implementations, and on current implementations on different systems, the lower-order bits are much less random than the higher-order bits. Do not use this function in applications intended to be portable when good randomness is needed. (Use random(3) instead.) --- src/collage.c | 4 ++-- src/gib_list.c | 2 +- src/keyevents.c | 2 +- src/main.c | 2 +- src/slideshow.c | 2 +- src/wallpaper.c | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) (limited to 'src/main.c') diff --git a/src/collage.c b/src/collage.c index 2a4d9f9..b616bef 100644 --- a/src/collage.c +++ b/src/collage.c @@ -145,8 +145,8 @@ void init_collage_mode(void) } /* pick random coords for thumbnail */ - xxx = ((w - www) * ((double) rand() / RAND_MAX)); - yyy = ((h - hhh) * ((double) rand() / RAND_MAX)); + xxx = ((w - www) * ((double) random() / RAND_MAX)); + yyy = ((h - hhh) * ((double) random() / RAND_MAX)); D(("image going on at x=%d, y=%d\n", xxx, yyy)); im_thumb = gib_imlib_create_cropped_scaled_image(im_temp, diff --git a/src/gib_list.c b/src/gib_list.c index 5384d98..a8ba1dd 100644 --- a/src/gib_list.c +++ b/src/gib_list.c @@ -362,7 +362,7 @@ gib_list_randomize(gib_list * list) } for (i = 0; i < len - 1; i++) { - r = i + rand() / (RAND_MAX / (len - i) + 1 ); + r = i + random() / (RAND_MAX / (len - i) + 1 ); t = farray[r]; farray[r] = farray[i]; farray[i] = t; diff --git a/src/keyevents.c b/src/keyevents.c index 689aebd..43bc82a 100644 --- a/src/keyevents.c +++ b/src/keyevents.c @@ -686,7 +686,7 @@ void feh_event_handle_generic(winwidget winwid, unsigned int state, KeySym keysy } else if (feh_is_kp(EVENT_jump_random, state, keysym, button)) { if (winwid->type == WIN_TYPE_THUMBNAIL) - feh_thumbnail_select_next(winwid, rand() % (filelist_len - 1)); + feh_thumbnail_select_next(winwid, random() % (filelist_len - 1)); else slideshow_change_image(winwid, SLIDE_RAND, 1); } diff --git a/src/main.c b/src/main.c index 1a76e2d..779e0bd 100644 --- a/src/main.c +++ b/src/main.c @@ -42,7 +42,7 @@ int main(int argc, char **argv) { atexit(feh_clean_exit); - srand(getpid() * time(NULL) % ((unsigned int) -1)); + srandom(getpid() * time(NULL) % ((unsigned int) -1)); setup_signal_handlers(); init_parse_options(argc, argv); diff --git a/src/slideshow.c b/src/slideshow.c index 3770677..b404318 100644 --- a/src/slideshow.c +++ b/src/slideshow.c @@ -258,7 +258,7 @@ void slideshow_change_image(winwidget winwid, int change, int render) case SLIDE_RAND: if (filelist_len > 1) { current_file = feh_list_jump(filelist, current_file, FORWARD, - (rand() % (filelist_len - 1)) + 1); + (random() % (filelist_len - 1)) + 1); change = SLIDE_NEXT; } break; diff --git a/src/wallpaper.c b/src/wallpaper.c index db14a8c..ef7ecca 100644 --- a/src/wallpaper.c +++ b/src/wallpaper.c @@ -252,7 +252,7 @@ void feh_wm_set_bg(char *fil, Imlib_Image im, int centered, int scaled, XGCValues gcval; GC gc; char bgname[20]; - int num = (int) rand(); + int num = (int) random(); char bgfil[4096]; char sendbuf[4096]; -- cgit v1.2.3 From 7b873e26ed203365e9d96760b0ad5a3605574550 Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Mon, 5 Nov 2018 19:51:57 +0100 Subject: Remove deprecated option --menu-bg --- ChangeLog | 1 + examples/themes | 5 ----- share/images/menubg_aluminium.png | Bin 1862 -> 0 bytes share/images/menubg_aqua.png | Bin 5325 -> 0 bytes share/images/menubg_black.png | Bin 1716 -> 0 bytes share/images/menubg_brushed.png | Bin 8649 -> 0 bytes share/images/menubg_sky.png | Bin 1928 -> 0 bytes src/main.c | 1 - src/menu.c | 2 +- src/options.c | 7 ------- src/options.h | 1 - 11 files changed, 2 insertions(+), 15 deletions(-) delete mode 100644 share/images/menubg_aluminium.png delete mode 100644 share/images/menubg_aqua.png delete mode 100644 share/images/menubg_black.png delete mode 100644 share/images/menubg_brushed.png delete mode 100644 share/images/menubg_sky.png (limited to 'src/main.c') diff --git a/ChangeLog b/ChangeLog index 667d204..f2ec192 100644 --- a/ChangeLog +++ b/ChangeLog @@ -3,6 +3,7 @@ git HEAD * Remove deprecated webcam scripts (feh-cam and gen-cam-menu) * Remove deprecated collage mode (-c/--collage) * Remove deprecated option --cycle-once (use --on-last-slide=quit instead) + * Remove deprecated option --menu-bg * flip and rotation (keys "<", ">", "|", and "_") no longer change the underlying file. This leaves delete ("Ctrl+Delete") as the only destructive action which is enabled by default diff --git a/examples/themes b/examples/themes index d315942..2d77770 100644 --- a/examples/themes +++ b/examples/themes @@ -41,11 +41,6 @@ booth --full-screen --hide-pointer --slideshow-delay 20 # Screw xscreensaver, use feh =) screensave --recursive --full-screen --randomize --slideshow-delay 10 --hide-pointer -# Different menus -aqua --menu-bg /usr/share/feh/images/menubg_aqua.png -sky --menu-bg /usr/share/feh/images/menubg_sky.png -black --menu-bg /usr/share/feh/images/menubg_black.png - # Some more examples, used by the feh developer rfs --full-screen --hide-pointer --auto-zoom --randomize diff --git a/share/images/menubg_aluminium.png b/share/images/menubg_aluminium.png deleted file mode 100644 index eed00f1..0000000 Binary files a/share/images/menubg_aluminium.png and /dev/null differ diff --git a/share/images/menubg_aqua.png b/share/images/menubg_aqua.png deleted file mode 100644 index 3a72590..0000000 Binary files a/share/images/menubg_aqua.png and /dev/null differ diff --git a/share/images/menubg_black.png b/share/images/menubg_black.png deleted file mode 100644 index 08b4c2b..0000000 Binary files a/share/images/menubg_black.png and /dev/null differ diff --git a/share/images/menubg_brushed.png b/share/images/menubg_brushed.png deleted file mode 100644 index 32fad47..0000000 Binary files a/share/images/menubg_brushed.png and /dev/null differ diff --git a/share/images/menubg_sky.png b/share/images/menubg_sky.png deleted file mode 100644 index e0be8ca..0000000 Binary files a/share/images/menubg_sky.png and /dev/null differ diff --git a/src/main.c b/src/main.c index 0d1cc4d..ded0b22 100644 --- a/src/main.c +++ b/src/main.c @@ -216,7 +216,6 @@ void feh_clean_exit(void) { delete_rm_files(); - free(opt.menu_bg); free(opt.menu_font); if(disp) diff --git a/src/menu.c b/src/menu.c index 2f8875d..fcbb490 100644 --- a/src/menu.c +++ b/src/menu.c @@ -134,7 +134,7 @@ feh_menu *feh_menu_new(void) menus = l; if (!bg) { - feh_load_image_char(&bg, opt.menu_bg); + feh_load_image_char(&bg, PREFIX "/share/feh/images/menubg_default.png"); if (bg) { border.left = border.right = border.top = border.bottom = 4; diff --git a/src/options.c b/src/options.c index 298dbab..c6165ac 100644 --- a/src/options.c +++ b/src/options.c @@ -62,7 +62,6 @@ void init_parse_options(int argc, char **argv) opt.scroll_step = 20; opt.menu_font = estrdup(DEFAULT_MENU_FONT); opt.font = NULL; - opt.menu_bg = estrdup(PREFIX "/share/feh/images/menubg_default.png"); opt.max_height = opt.max_width = UINT_MAX; opt.start_list_at = NULL; @@ -319,7 +318,6 @@ static void feh_parse_option_array(int argc, char **argv, int finalrun) /* (*name, has_arg, *flag, val) See: struct option in getopts.h */ static struct option lopts[] = { - {"menu-bg" , 1, 0, ')'}, {"debug" , 0, 0, '+'}, {"scale-down" , 0, 0, '.'}, {"max-dimension" , 1, 0, '<'}, @@ -427,11 +425,6 @@ static void feh_parse_option_array(int argc, char **argv, int finalrun) switch (optch) { case 0: break; - case ')': - free(opt.menu_bg); - opt.menu_bg = estrdup(optarg); - weprintf("The --menu-bg option is deprecated and will be removed by 2012"); - break; case '+': opt.debug = 1; break; diff --git a/src/options.h b/src/options.h index 1c68fa0..7f8fe9c 100644 --- a/src/options.h +++ b/src/options.h @@ -96,7 +96,6 @@ struct __fehoptions { char *filelistfile; char *menu_font; char *customlist; - char *menu_bg; char *caption_path; char *start_list_at; char *info_cmd; -- cgit v1.2.3 From a4f09edc1eb8a673cb1d953aeded7ac0b1295859 Mon Sep 17 00:00:00 2001 From: Pavel Shlyak Date: Sun, 23 Dec 2018 18:44:09 +0300 Subject: There is no need to test ft against null ft is already checked on line 153 so this condition is useless. Check https://github.com/derf/feh/issues/440 for more details --- src/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/main.c') diff --git a/src/main.c b/src/main.c index ded0b22..87cf7c4 100644 --- a/src/main.c +++ b/src/main.c @@ -183,7 +183,7 @@ int feh_main_iteration(int block) && ((errno == ENOMEM) || (errno == EINVAL) || (errno == EBADF))) eprintf("Connection to X display lost"); - if ((ft) && (count == 0)) { + if (count == 0) { /* This means the timer is due to be executed. If count was > 0, that would mean an X event had woken us, we're not interested in that */ -- cgit v1.2.3