nsxivc1ba841
Merge dwminer/framerate
+22 −4
6 files changed
- M Makefile +1 −1
- M image.c +2 −0
- M image.h +1 −0
- M options.c +11 −3
- M options.h +1 −0
- M sxiv.1 +6 −0
| @@ -1,4 +1,4 @@ | |||
| 1 | − | VERSION := git-20161030 | |
| 1 | + | VERSION := git-20161128 | |
| 2 | 2 | ||
| 3 | 3 | PREFIX := /usr/local | |
| 4 | 4 | MANPREFIX := $(PREFIX)/share/man | |
| @@ -68,6 +68,7 @@ void img_init(img_t *img, win_t *win) | |||
| 68 | 68 | img->alpha = ALPHA_LAYER; | |
| 69 | 69 | img->multi.cap = img->multi.cnt = 0; | |
| 70 | 70 | img->multi.animate = options->animate; | |
| 71 | + | img->multi.framedelay = options->framerate > 0 ? 1000 / options->framerate : 0; | |
| 71 | 72 | img->multi.length = 0; | |
| 72 | 73 | ||
| 73 | 74 | img->cmod = imlib_create_color_modifier(); | |
| @@ -263,6 +264,7 @@ bool img_load_gif(img_t *img, const fileinfo_t *file) | |||
| 263 | 264 | img->multi.cap * sizeof(img_frame_t)); | |
| 264 | 265 | } | |
| 265 | 266 | img->multi.frames[img->multi.cnt].im = im; | |
| 267 | + | delay = img->multi.framedelay > 0 ? img->multi.framedelay : delay; | |
| 266 | 268 | img->multi.frames[img->multi.cnt].delay = delay > 0 ? delay : DEF_GIF_DELAY; | |
| 267 | 269 | img->multi.length += img->multi.frames[img->multi.cnt].delay; | |
| 268 | 270 | img->multi.cnt++; | |
| @@ -35,6 +35,7 @@ typedef struct { | |||
| 35 | 35 | int cnt; | |
| 36 | 36 | int sel; | |
| 37 | 37 | bool animate; | |
| 38 | + | int framedelay; | |
| 38 | 39 | int length; | |
| 39 | 40 | } multi_img_t; | |
| 40 | 41 | ||
| @@ -32,8 +32,9 @@ const options_t *options = (const options_t*) &_options; | |||
| 32 | 32 | ||
| 33 | 33 | void print_usage(void) | |
| 34 | 34 | { | |
| 35 | − | printf("usage: sxiv [-abcfhioqrtvZ] [-e WID] [-G GAMMA] [-g GEOMETRY] " | |
| 36 | − | "[-N NAME] [-n NUM] [-S DELAY] [-s MODE] [-z ZOOM] FILES...\n"); | |
| 35 | + | printf("usage: sxiv [-abcfhioqrtvZ] [-A FRAMERATE] [-e WID] [-G GAMMA] " | |
| 36 | + | "[-g GEOMETRY] [-N NAME] [-n NUM] [-S DELAY] [-s MODE] [-z ZOOM] " | |
| 37 | + | "FILES...\n"); | |
| 37 | 38 | } | |
| 38 | 39 | ||
| 39 | 40 | void print_version(void) | |
| @@ -60,6 +61,7 @@ void parse_options(int argc, char **argv) | |||
| 60 | 61 | _options.animate = false; | |
| 61 | 62 | _options.gamma = 0; | |
| 62 | 63 | _options.slideshow = 0; | |
| 64 | + | _options.framerate = 0; | |
| 63 | 65 | ||
| 64 | 66 | _options.fullscreen = false; | |
| 65 | 67 | _options.embed = 0; | |
| @@ -71,11 +73,17 @@ void parse_options(int argc, char **argv) | |||
| 71 | 73 | _options.thumb_mode = false; | |
| 72 | 74 | _options.clean_cache = false; | |
| 73 | 75 | ||
| 74 | − | while ((opt = getopt(argc, argv, "abce:fG:g:hin:N:oqrS:s:tvZz:")) != -1) { | |
| 76 | + | while ((opt = getopt(argc, argv, "A:abce:fG:g:hin:N:oqrS:s:tvZz:")) != -1) { | |
| 75 | 77 | switch (opt) { | |
| 76 | 78 | case '?': | |
| 77 | 79 | print_usage(); | |
| 78 | 80 | exit(EXIT_FAILURE); | |
| 81 | + | case 'A': | |
| 82 | + | n = strtol(optarg, &end, 0); | |
| 83 | + | if (*end != '\0' || n <= 0) | |
| 84 | + | error(EXIT_FAILURE, 0, "Invalid argument for option -A: %s", optarg); | |
| 85 | + | _options.framerate = n; | |
| 86 | + | /* fall through */ | |
| 79 | 87 | case 'a': | |
| 80 | 88 | _options.animate = true; | |
| 81 | 89 | break; | |
| @@ -37,6 +37,7 @@ typedef struct { | |||
| 37 | 37 | bool animate; | |
| 38 | 38 | int gamma; | |
| 39 | 39 | int slideshow; | |
| 40 | + | int framerate; | |
| 40 | 41 | ||
| 41 | 42 | /* window: */ | |
| 42 | 43 | bool fullscreen; | |
| @@ -4,6 +4,8 @@ sxiv \- Simple X Image Viewer | |||
| 4 | 4 | .SH SYNOPSIS | |
| 5 | 5 | .B sxiv | |
| 6 | 6 | .RB [ \-abcfhioqrtvZ ] | |
| 7 | + | .RB [ \-A | |
| 8 | + | .IR FRAMERATE ] | |
| 7 | 9 | .RB [ \-e | |
| 8 | 10 | .IR WID ] | |
| 9 | 11 | .RB [ \-G | |
| @@ -33,6 +35,10 @@ Please note, that the fullscreen mode requires an EWMH/NetWM compliant window | |||
| 33 | 35 | manager. | |
| 34 | 36 | .SH OPTIONS | |
| 35 | 37 | .TP | |
| 38 | + | .BI "\-A " FRAMERATE | |
| 39 | + | Play animations with a constant frame rate set to | |
| 40 | + | .IR FRAMERATE . | |
| 41 | + | .TP | |
| 36 | 42 | .B \-a | |
| 37 | 43 | Play animations of multi-frame images. | |
| 38 | 44 | .TP | |