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/wallpaper.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/wallpaper.c') 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 553d6f9060d867cf05bd21d8669751b31bbe11dd Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Fri, 8 Feb 2019 17:58:21 +0100 Subject: Fix ~/.fehbg creation when using --randomize or directory arguments Closes #456 Note that --randomize and directory names are not saved in fehbg. It only contains the command line needed to recreate the wallpaper setup which resulted from its invocation, i.e., after randomization etc. have been applied. This is intentional. --- src/wallpaper.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) (limited to 'src/wallpaper.c') diff --git a/src/wallpaper.c b/src/wallpaper.c index ef7ecca..f0bf891 100644 --- a/src/wallpaper.c +++ b/src/wallpaper.c @@ -502,15 +502,16 @@ void feh_wm_set_bg(char *fil, Imlib_Image im, int centered, int scaled, } fputc(' ', fp); if (use_filelist) { - for (int i = 0; i < cmdargc; i++) { - if (filelist_pos && !strcmp(FEH_FILE(filelist_pos->data)->filename, cmdargv[i])) { - /* argument is a file */ - absolute_path = feh_absolute_path(cmdargv[i]); - fputs(shell_escape(absolute_path), fp); - filelist_pos = filelist_pos->next; - free(absolute_path); - fputc(' ', fp); - } +#ifdef HAVE_LIBXINERAMA + for (int i = 0; (i < num_xinerama_screens) && filelist_pos; i++) { +#else + for (int i = 0; (i < 1 ) && filelist_pos; i++) { +#endif + absolute_path = feh_absolute_path(FEH_FILE(filelist_pos->data)->filename); + fputs(shell_escape(absolute_path), fp); + filelist_pos = filelist_pos->next; + free(absolute_path); + fputc(' ', fp); } } else if (fil) { absolute_path = feh_absolute_path(fil); -- cgit v1.2.3 From d63e1cdd97d9c492733c798d1b5f55c0267b0160 Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Thu, 14 Feb 2019 17:40:47 +0100 Subject: Do not omit filenames in ~/.fehbg when using --no-xinerama (#456) --- src/wallpaper.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/wallpaper.c') diff --git a/src/wallpaper.c b/src/wallpaper.c index f0bf891..9df259f 100644 --- a/src/wallpaper.c +++ b/src/wallpaper.c @@ -503,7 +503,7 @@ void feh_wm_set_bg(char *fil, Imlib_Image im, int centered, int scaled, fputc(' ', fp); if (use_filelist) { #ifdef HAVE_LIBXINERAMA - for (int i = 0; (i < num_xinerama_screens) && filelist_pos; i++) { + for (int i = 0; (i < opt.xinerama ? num_xinerama_screens : 1) && filelist_pos; i++) { #else for (int i = 0; (i < 1 ) && filelist_pos; i++) { #endif -- cgit v1.2.3