diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/collage.c | 2 | ||||
| -rw-r--r-- | src/debug.h | 2 | ||||
| -rw-r--r-- | src/events.c | 6 | ||||
| -rw-r--r-- | src/feh.h | 2 | ||||
| -rw-r--r-- | src/filelist.c | 2 | ||||
| -rw-r--r-- | src/imlib.c | 53 | ||||
| -rw-r--r-- | src/index.c | 2 | ||||
| -rw-r--r-- | src/index.h | 2 | ||||
| -rw-r--r-- | src/keyevents.c | 28 | ||||
| -rw-r--r-- | src/list.c | 2 | ||||
| -rw-r--r-- | src/main.c | 2 | ||||
| -rw-r--r-- | src/menu.c | 2 | ||||
| -rw-r--r-- | src/menu.h | 2 | ||||
| -rw-r--r-- | src/options.c | 2 | ||||
| -rw-r--r-- | src/options.h | 2 | ||||
| -rw-r--r-- | src/signals.c | 2 | ||||
| -rw-r--r-- | src/slideshow.c | 14 | ||||
| -rw-r--r-- | src/structs.h | 2 | ||||
| -rw-r--r-- | src/thumbnail.c | 17 | ||||
| -rw-r--r-- | src/thumbnail.h | 2 | ||||
| -rw-r--r-- | src/timers.c | 2 | ||||
| -rw-r--r-- | src/wallpaper.c | 75 | ||||
| -rw-r--r-- | src/wallpaper.h | 2 | ||||
| -rw-r--r-- | src/winwidget.c | 4 | ||||
| -rw-r--r-- | src/winwidget.h | 2 | 
25 files changed, 181 insertions, 52 deletions
| diff --git a/src/collage.c b/src/collage.c index 431d3b6..2a4d9f9 100644 --- a/src/collage.c +++ b/src/collage.c @@ -1,7 +1,7 @@  /* collage.c  Copyright (C) 1999-2003 Tom Gilbert. -Copyright (C) 2010-2011 Daniel Friesel. +Copyright (C) 2010-2018 Daniel Friesel.  Permission is hereby granted, free of charge, to any person obtaining a copy  of this software and associated documentation files (the "Software"), to diff --git a/src/debug.h b/src/debug.h index eb929e3..38cf83f 100644 --- a/src/debug.h +++ b/src/debug.h @@ -1,7 +1,7 @@  /* debug.h  Copyright (C) 1999-2003 Tom Gilbert. -Copyright (C) 2010-2011 Daniel Friesel. +Copyright (C) 2010-2018 Daniel Friesel.  Permission is hereby granted, free of charge, to any person obtaining a copy  of this software and associated documentation files (the "Software"), to diff --git a/src/events.c b/src/events.c index 947e69f..89eaab8 100644 --- a/src/events.c +++ b/src/events.c @@ -1,7 +1,7 @@  /* events.c  Copyright (C) 1999-2003 Tom Gilbert. -Copyright (C) 2010-2011 Daniel Friesel. +Copyright (C) 2010-2018 Daniel Friesel.  Permission is hereby granted, free of charge, to any person obtaining a copy  of this software and associated documentation files (the "Software"), to @@ -509,6 +509,8 @@ static void feh_event_handle_MotionNotify(XEvent * ev)  				dy = scr_height - (m->y + m->h);  				dx = dx < 0 ? dx : 0;  				dy = dy < 0 ? dy : 0; +				dx = m->x + dx < 0 ? -m->x : dx; +				dy = m->y + dy < 0 ? -m->y : dy;  				if (dx || dy)  					feh_menu_slide_all_menus_relative(dx, dy);  			} @@ -521,6 +523,8 @@ static void feh_event_handle_MotionNotify(XEvent * ev)  				dy = scr->height - (m->next->y + m->next->h);  				dx = dx < 0 ? dx : 0;  				dy = dy < 0 ? dy : 0; +				dx = m->x + dx < 0 ? -m->x : dx; +				dy = m->y + dy < 0 ? -m->y : dy;  				if (dx || dy)  					feh_menu_slide_all_menus_relative(dx, dy);  			} @@ -1,7 +1,7 @@  /* feh.h  Copyright (C) 1999-2003 Tom Gilbert. -Copyright (C) 2010-2011 Daniel Friesel. +Copyright (C) 2010-2018 Daniel Friesel.  Permission is hereby granted, free of charge, to any person obtaining a copy  of this software and associated documentation files (the "Software"), to diff --git a/src/filelist.c b/src/filelist.c index 08da331..eb8e294 100644 --- a/src/filelist.c +++ b/src/filelist.c @@ -1,7 +1,7 @@  /* filelist.c  Copyright (C) 1999-2003 Tom Gilbert. -Copyright (C) 2010-2011 Daniel Friesel. +Copyright (C) 2010-2018 Daniel Friesel.  Permission is hereby granted, free of charge, to any person obtaining a copy  of this software and associated documentation files (the "Software"), to diff --git a/src/imlib.c b/src/imlib.c index baaa64a..5be0539 100644 --- a/src/imlib.c +++ b/src/imlib.c @@ -1,7 +1,7 @@  /* imlib.c  Copyright (C) 1999-2003 Tom Gilbert. -Copyright (C) 2010-2011 Daniel Friesel. +Copyright (C) 2010-2018 Daniel Friesel.  Permission is hereby granted, free of charge, to any person obtaining a copy  of this software and associated documentation files (the "Software"), to @@ -304,8 +304,10 @@ static char *feh_magick_load_image(char *filename)  	char *basename;  	char *tmpname;  	char *sfn; +	char tempdir[] = "/tmp/.feh-magick-tmp-XXXXXX";  	int fd = -1, devnull = -1;  	int status; +	char created_tempdir = 0;  	if (opt.magick_timeout < 0)  		return NULL; @@ -339,6 +341,22 @@ static char *feh_magick_load_image(char *filename)  	 */  	argv_fn = estrjoin(":", "png", sfn, NULL); +	/* +	 * By default, ImageMagick saves (occasionally lots of) temporary files +	 * in /tmp. It doesn't remove them if it runs into a timeout and is killed +	 * by us, no matter whether we use SIGINT, SIGTERM or SIGKILL. So, unless +	 * MAGICK_TMPDIR has already been set by the user, we create our own +	 * temporary directory for ImageMagick and remove its contents at the end of +	 * this function. +	 */ +	if (getenv("MAGICK_TMPDIR") == NULL) { +		if (mkdtemp(tempdir) == NULL) { +			weprintf("%s: ImageMagick may leave temporary files in /tmp. mkdtemp failed:", filename); +		} else { +			created_tempdir = 1; +		} +	} +  	if ((childpid = fork()) < 0) {  		weprintf("%s: Can't load with imagemagick. Fork failed:", filename);  		unlink(sfn); @@ -360,6 +378,11 @@ static char *feh_magick_load_image(char *filename)  		 */  		setpgid(0, 0); +		if (created_tempdir) { +			// no error checking - this is a best-effort code path +			setenv("MAGICK_TMPDIR", tempdir, 0); +		} +  		execlp("convert", "convert", filename, argv_fn, NULL);  		_exit(1);  	} @@ -373,13 +396,39 @@ static char *feh_magick_load_image(char *filename)  			sfn = NULL;  			if (!opt.quiet) { -				weprintf("%s - Conversion took too long, skipping", filename); +				weprintf("%s: Conversion took too long, skipping", filename);  			}  		}  		close(fd);  		childpid = 0;  	} +	if (created_tempdir) { +		DIR *dir; +		struct dirent *de; +		if ((dir = opendir(tempdir)) == NULL) { +			weprintf("%s: Cannot remove temporary ImageMagick files from %s:", filename, tempdir); +		} else { +			while ((de = readdir(dir)) != NULL) { +				if (de->d_name[0] != '.') { +					char *temporary_file_name = estrjoin("/", tempdir, de->d_name, NULL); +					/* +					 * We assume that ImageMagick only creates temporary files and +					 * not directories. +					 */ +					if (unlink(temporary_file_name) == -1) { +						weprintf("unlink %s:", temporary_file_name); +					} +					free(temporary_file_name); +				} +			} +			if (rmdir(tempdir) == -1) { +				weprintf("rmdir %s:", tempdir); +			} +		} +		closedir(dir); +	} +  	free(argv_fn);  	return sfn;  } diff --git a/src/index.c b/src/index.c index c8c34c5..ca1664b 100644 --- a/src/index.c +++ b/src/index.c @@ -1,7 +1,7 @@  /* index.c  Copyright (C) 1999-2003 Tom Gilbert. -Copyright (C) 2010-2011 Daniel Friesel. +Copyright (C) 2010-2018 Daniel Friesel.  Permission is hereby granted, free of charge, to any person obtaining a copy  of this software and associated documentation files (the "Software"), to diff --git a/src/index.h b/src/index.h index 08ab337..b022f1a 100644 --- a/src/index.h +++ b/src/index.h @@ -1,6 +1,6 @@  /* index.h -Copyright (C) 2011 Daniel Friesel. +Copyright (C) 2018 Daniel Friesel.  Permission is hereby granted, free of charge, to any person obtaining a copy  of this software and associated documentation files (the "Software"), to diff --git a/src/keyevents.c b/src/keyevents.c index 933d887..689aebd 100644 --- a/src/keyevents.c +++ b/src/keyevents.c @@ -1,7 +1,7 @@  /* keyevents.c  Copyright (C) 1999-2003 Tom Gilbert. -Copyright (C) 2010-2011 Daniel Friesel. +Copyright (C) 2010-2018 Daniel Friesel.  Permission is hereby granted, free of charge, to any person obtaining a copy  of this software and associated documentation files (the "Software"), to @@ -317,6 +317,7 @@ void feh_event_invoke_action(winwidget winwid, unsigned char action)  void feh_event_handle_stdin()  {  	char stdin_buf[2]; +	static char is_esc = 0;  	KeySym keysym = NoSymbol;  	if (read(STDIN_FILENO, &stdin_buf, 1) == -1) {  		control_via_stdin = 0; @@ -328,17 +329,40 @@ void feh_event_handle_stdin()  	}  	stdin_buf[1] = '\0'; +	// escape? +	if (stdin_buf[0] == 0x1b) { +		is_esc = 1; +		return; +	} +	if ((is_esc == 1) && (stdin_buf[0] == '[')) { +		is_esc = 2; +		return; +	} +  	if (stdin_buf[0] == ' ')  		keysym = XK_space;  	else if (stdin_buf[0] == '\n')  		keysym = XK_Return;  	else if ((stdin_buf[0] == '\b') || (stdin_buf[0] == 127))  		keysym = XK_BackSpace; +	else if (is_esc == 2) { +		if (stdin_buf[0] == 'A') +			keysym = XK_Up; +		else if (stdin_buf[0] == 'B') +			keysym = XK_Down; +		else if (stdin_buf[0] == 'C') +			keysym = XK_Right; +		else if (stdin_buf[0] == 'D') +			keysym = XK_Left; +		is_esc = 0; +	}  	else  		keysym = XStringToKeysym(stdin_buf);  	if (window_num) -		feh_event_handle_generic(windows[0], 0, keysym, 0); +		feh_event_handle_generic(windows[0], is_esc * Mod1Mask, keysym, 0); + +	is_esc = 0;  }  void feh_event_handle_keypress(XEvent * ev) @@ -1,7 +1,7 @@  /* list.c  Copyright (C) 1999-2003 Tom Gilbert. -Copyright (C) 2010-2011 Daniel Friesel. +Copyright (C) 2010-2018 Daniel Friesel.  Permission is hereby granted, free of charge, to any person obtaining a copy  of this software and associated documentation files (the "Software"), to @@ -1,7 +1,7 @@  /* main.c  Copyright (C) 1999-2003 Tom Gilbert. -Copyright (C) 2010-2011 Daniel Friesel. +Copyright (C) 2010-2018 Daniel Friesel.  Permission is hereby granted, free of charge, to any person obtaining a copy  of this software and associated documentation files (the "Software"), to @@ -1,7 +1,7 @@  /* menu.c  Copyright (C) 1999-2003 Tom Gilbert. -Copyright (C) 2010-2011 Daniel Friesel. +Copyright (C) 2010-2018 Daniel Friesel.  Permission is hereby granted, free of charge, to any person obtaining a copy  of this software and associated documentation files (the "Software"), to @@ -1,7 +1,7 @@  /* menu.h  Copyright (C) 1999-2003 Tom Gilbert. -Copyright (C) 2010-2011 Daniel Friesel. +Copyright (C) 2010-2018 Daniel Friesel.  Permission is hereby granted, free of charge, to any person obtaining a copy  of this software and associated documentation files (the "Software"), to diff --git a/src/options.c b/src/options.c index 1e75c6b..ab9006c 100644 --- a/src/options.c +++ b/src/options.c @@ -1,7 +1,7 @@  /* options.c  Copyright (C) 1999-2003 Tom Gilbert. -Copyright (C) 2010-2011 Daniel Friesel. +Copyright (C) 2010-2018 Daniel Friesel.  Permission is hereby granted, free of charge, to any person obtaining a copy  of this software and associated documentation files (the "Software"), to diff --git a/src/options.h b/src/options.h index 6ad8a44..be2ca25 100644 --- a/src/options.h +++ b/src/options.h @@ -1,7 +1,7 @@  /* options.h  Copyright (C) 1999-2003 Tom Gilbert. -Copyright (C) 2010-2011 Daniel Friesel. +Copyright (C) 2010-2018 Daniel Friesel.  Permission is hereby granted, free of charge, to any person obtaining a copy  of this software and associated documentation files (the "Software"), to diff --git a/src/signals.c b/src/signals.c index 8a3a8f7..c08d5df 100644 --- a/src/signals.c +++ b/src/signals.c @@ -1,6 +1,6 @@  /* signals.c -Copyright (C) 2010 by Daniel Friesel +Copyright (C) 2010-2018 by Daniel Friesel  Permission is hereby granted, free of charge, to any person obtaining a copy  of this software and associated documentation files (the "Software"), to diff --git a/src/slideshow.c b/src/slideshow.c index f3860ed..b27a7e8 100644 --- a/src/slideshow.c +++ b/src/slideshow.c @@ -1,7 +1,7 @@  /* slideshow.c  Copyright (C) 1999-2003 Tom Gilbert. -Copyright (C) 2010-2011 Daniel Friesel. +Copyright (C) 2010-2018 Daniel Friesel.  Permission is hereby granted, free of charge, to any person obtaining a copy  of this software and associated documentation files (the "Software"), to @@ -425,6 +425,12 @@ char *feh_printf(char *str, feh_file * file, winwidget winwid)  				if (file)  					strncat(ret, shell_escape(file->filename), sizeof(ret) - strlen(ret) - 1);  				break; +			case 'g': +				if (winwid) { +					snprintf(buf, sizeof(buf), "%d,%d", winwid->w, winwid->h); +					strncat(ret, buf, sizeof(ret) - strlen(ret) - 1); +				} +				break;  			case 'h':  				if (file && (file->info || !feh_file_info_load(file, NULL))) {  					snprintf(buf, sizeof(buf), "%d", file->info->height); @@ -521,6 +527,12 @@ char *feh_printf(char *str, feh_file * file, winwidget winwid)  					strncat(ret, "1.00", sizeof(ret) - strlen(ret) - 1);  				}  				break; +			case 'Z': +				if (winwid) { +					snprintf(buf, sizeof(buf), "%f", winwid->zoom); +					strncat(ret, buf, sizeof(ret) - strlen(ret) - 1); +				} +				break;  			case '%':  				strncat(ret, "%", sizeof(ret) - strlen(ret) - 1);  				break; diff --git a/src/structs.h b/src/structs.h index 3942bc0..ce30eb9 100644 --- a/src/structs.h +++ b/src/structs.h @@ -1,7 +1,7 @@  /* structs.h  Copyright (C) 1999-2003 Tom Gilbert. -Copyright (C) 2010-2011 Daniel Friesel. +Copyright (C) 2010-2018 Daniel Friesel.  Permission is hereby granted, free of charge, to any person obtaining a copy  of this software and associated documentation files (the "Software"), to diff --git a/src/thumbnail.c b/src/thumbnail.c index 003c7b4..cf38cfc 100644 --- a/src/thumbnail.c +++ b/src/thumbnail.c @@ -1,7 +1,7 @@  /* thumbnail.c  Copyright (C) 1999-2003 Tom Gilbert. -Copyright (C) 2010-2011 Daniel Friesel. +Copyright (C) 2010-2018 Daniel Friesel.  Permission is hereby granted, free of charge, to any person obtaining a copy  of this software and associated documentation files (the "Software"), to @@ -766,17 +766,26 @@ int feh_thumbnail_get_generated(Imlib_Image * image, feh_file * file,  void feh_thumbnail_show_fullsize(feh_file *thumbfile)  {  	winwidget thumbwin = NULL; +	gib_list *l; + +	for (l = filelist; l; l = l->next) { +		if (FEH_FILE(l->data) == thumbfile) { +			break; +		} +	} +	if (!l) { +		eprintf("Cannot find %s in filelist, wtf", thumbfile->filename); +	}  	thumbwin = winwidget_get_first_window_of_type(WIN_TYPE_THUMBNAIL_VIEWER);  	if (!thumbwin) {  		thumbwin = winwidget_create_from_file( -				gib_list_add_front(NULL, thumbfile), +				l,  				WIN_TYPE_THUMBNAIL_VIEWER);  		if (thumbwin)  			winwidget_show(thumbwin);  	} else if (FEH_FILE(thumbwin->file->data) != thumbfile) { -		free(thumbwin->file); -		thumbwin->file = gib_list_add_front(NULL, thumbfile); +		thumbwin->file = l;  		feh_reload_image(thumbwin, 1, 1);  	}  } diff --git a/src/thumbnail.h b/src/thumbnail.h index f22ff77..09cd771 100644 --- a/src/thumbnail.h +++ b/src/thumbnail.h @@ -1,7 +1,7 @@  /* thumbnail.h  Copyright (C) 1999-2003 Tom Gilbert. -Copyright (C) 2010-2011 Daniel Friesel. +Copyright (C) 2010-2018 Daniel Friesel.  Permission is hereby granted, free of charge, to any person obtaining a copy  of this software and associated documentation files (the "Software"), to diff --git a/src/timers.c b/src/timers.c index 1cac94b..95fc9f8 100644 --- a/src/timers.c +++ b/src/timers.c @@ -1,7 +1,7 @@  /* timers.c  Copyright (C) 1999-2003 Tom Gilbert. -Copyright (C) 2010-2011 Daniel Friesel. +Copyright (C) 2010-2018 Daniel Friesel.  Permission is hereby granted, free of charge, to any person obtaining a copy  of this software and associated documentation files (the "Software"), to diff --git a/src/wallpaper.c b/src/wallpaper.c index 2d3d3bc..db14a8c 100644 --- a/src/wallpaper.c +++ b/src/wallpaper.c @@ -1,7 +1,7 @@  /* wallpaper.c  Copyright (C) 1999-2003 Tom Gilbert. -Copyright (C) 2010-2011 Daniel Friesel. +Copyright (C) 2010-2018 Daniel Friesel.  Permission is hereby granted, free of charge, to any person obtaining a copy  of this software and associated documentation files (the "Software"), to @@ -453,36 +453,69 @@ void feh_wm_set_bg(char *fil, Imlib_Image im, int centered, int scaled,  			if (home) {  				FILE *fp;  				char *path; +				char *absolute_path;  				struct stat s; +				gib_list *filelist_pos = filelist;  				path = estrjoin("/", home, ".fehbg", NULL);  				if ((fp = fopen(path, "w")) == NULL) {  					weprintf("Can't write to %s", path);  				} else {  					fputs("#!/bin/sh\n", fp); +					fputs(cmdargv[0], fp); +					fputs(" --bg-", fp); +					if (centered) +						fputs("center", fp); +					else if (scaled) +						fputs("scale", fp); +					else if (filled == 1) +						fputs("fill", fp); +					else if (filled == 2) +						fputs("max", fp); +					else +						fputs("tile", fp); +					if (opt.image_bg) { +						fputs(" --image-bg ", fp); +						fputs(shell_escape(opt.image_bg), fp); +					} +#ifdef HAVE_LIBXINERAMA +					if (opt.xinerama) { +						if (opt.xinerama_index >= 0) { +							fprintf(fp, " --xinerama-index %d", opt.xinerama_index); +						} +					} +					else { +						fputs(" --no-xinerama", fp); +					} +#endif			/* HAVE_LIBXINERAMA */ +					if (opt.geom_flags & XValue) { +						fprintf(fp, " --geometry %c%d", +								opt.geom_flags & XNegative ? '-' : '+', +								opt.geom_flags & XNegative ? abs(opt.geom_x) : opt.geom_x); +						if (opt.geom_flags & YValue) { +							fprintf(fp, "%c%d", +									opt.geom_flags & YNegative ? '-' : '+', +									opt.geom_flags & YNegative ? abs(opt.geom_y) : opt.geom_y); +						} +					} +					if (opt.force_aliasing) { +						fputs(" --force-aliasing", fp); +					} +					fputc(' ', fp);  					if (use_filelist) {  						for (int i = 0; i < cmdargc; i++) { -							fputs(shell_escape(cmdargv[i]), fp); -							fputc(' ', fp); +							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); +							}  						}  					} else if (fil) { -						fputs("feh --bg-", fp); -						if (centered) -							fputs("center", fp); -						else if (scaled) -							fputs("scale", fp); -						else if (filled) -							fputs("fill", fp); -						else -							fputs("tile", fp); - -						if (opt.force_aliasing) -							fputs(" --force-aliasing", fp); -#ifdef HAVE_LIBXINERAMA -						if (!opt.xinerama) -							fputs(" --no-xinerama", fp); -#endif -						fputc(' ', fp); -						fputs(shell_escape(fil), fp); +						absolute_path = feh_absolute_path(fil); +						fputs(shell_escape(absolute_path), fp); +						free(absolute_path);  					}  					fputc('\n', fp);  					fclose(fp); diff --git a/src/wallpaper.h b/src/wallpaper.h index 0921129..02a6997 100644 --- a/src/wallpaper.h +++ b/src/wallpaper.h @@ -1,7 +1,7 @@  /* wallpaper.h  Copyright (C) 1999-2003 Tom Gilbert. -Copyright (C) 2010-2011 Daniel Friesel. +Copyright (C) 2010-2018 Daniel Friesel.  Permission is hereby granted, free of charge, to any person obtaining a copy  of this software and associated documentation files (the "Software"), to diff --git a/src/winwidget.c b/src/winwidget.c index 4374752..e54b49e 100644 --- a/src/winwidget.c +++ b/src/winwidget.c @@ -1,7 +1,7 @@  /* winwidget.c  Copyright (C) 1999-2003 Tom Gilbert. -Copyright (C) 2010-2011 Daniel Friesel. +Copyright (C) 2010-2018 Daniel Friesel.  Permission is hereby granted, free of charge, to any person obtaining a copy  of this software and associated documentation files (the "Software"), to @@ -668,8 +668,6 @@ void winwidget_destroy(winwidget winwid)  		free(winwid->name);  	if (winwid->gc)  		XFreeGC(disp, winwid->gc); -	if ((winwid->type == WIN_TYPE_THUMBNAIL_VIEWER) && (winwid->file != NULL)) -		gib_list_free(winwid->file);  	if (winwid->im)  		gib_imlib_free_image_and_decache(winwid->im);  	free(winwid); diff --git a/src/winwidget.h b/src/winwidget.h index 280c977..0a707ac 100644 --- a/src/winwidget.h +++ b/src/winwidget.h @@ -1,7 +1,7 @@  /* winwidget.h  Copyright (C) 1999-2003 Tom Gilbert. -Copyright (C) 2010-2011 Daniel Friesel. +Copyright (C) 2010-2018 Daniel Friesel.  Permission is hereby granted, free of charge, to any person obtaining a copy  of this software and associated documentation files (the "Software"), to | 
