Krolyxon
Commit c1ba841

Branches

Refs →

nsxivc1ba841

Merge dwminer/framerate

Author
Bert Münnich
Date
2016-11-28 18:54 +0100
Committer
Bert Münnich · 2016-11-28 19:10 +0100
Parents
32b29e6 ec47ecb
Commit
c1ba841783db1d53f4da303e0db3b05b5eea958f

+22 −4

6 files changed

  1. M Makefile +1 −1
  2. M image.c +2 −0
  3. M image.h +1 −0
  4. M options.c +11 −3
  5. M options.h +1 −0
  6. M sxiv.1 +6 −0
M Makefile View
@@ -1,4 +1,4 @@
1−VERSION := git-20161030
1+VERSION := git-20161128
22
33 PREFIX := /usr/local
44 MANPREFIX := $(PREFIX)/share/man
M image.c View
@@ -68,6 +68,7 @@ void img_init(img_t *img, win_t *win)
6868 img->alpha = ALPHA_LAYER;
6969 img->multi.cap = img->multi.cnt = 0;
7070 img->multi.animate = options->animate;
71+ img->multi.framedelay = options->framerate > 0 ? 1000 / options->framerate : 0;
7172 img->multi.length = 0;
7273
7374 img->cmod = imlib_create_color_modifier();
@@ -263,6 +264,7 @@ bool img_load_gif(img_t *img, const fileinfo_t *file)
263264 img->multi.cap * sizeof(img_frame_t));
264265 }
265266 img->multi.frames[img->multi.cnt].im = im;
267+ delay = img->multi.framedelay > 0 ? img->multi.framedelay : delay;
266268 img->multi.frames[img->multi.cnt].delay = delay > 0 ? delay : DEF_GIF_DELAY;
267269 img->multi.length += img->multi.frames[img->multi.cnt].delay;
268270 img->multi.cnt++;
M image.h View
@@ -35,6 +35,7 @@ typedef struct {
3535 int cnt;
3636 int sel;
3737 bool animate;
38+ int framedelay;
3839 int length;
3940 } multi_img_t;
4041
M options.c View
@@ -32,8 +32,9 @@ const options_t *options = (const options_t*) &_options;
3232
3333 void print_usage(void)
3434 {
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");
3738 }
3839
3940 void print_version(void)
@@ -60,6 +61,7 @@ void parse_options(int argc, char **argv)
6061 _options.animate = false;
6162 _options.gamma = 0;
6263 _options.slideshow = 0;
64+ _options.framerate = 0;
6365
6466 _options.fullscreen = false;
6567 _options.embed = 0;
@@ -71,11 +73,17 @@ void parse_options(int argc, char **argv)
7173 _options.thumb_mode = false;
7274 _options.clean_cache = false;
7375
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) {
7577 switch (opt) {
7678 case '?':
7779 print_usage();
7880 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 */
7987 case 'a':
8088 _options.animate = true;
8189 break;
M options.h View
@@ -37,6 +37,7 @@ typedef struct {
3737 bool animate;
3838 int gamma;
3939 int slideshow;
40+ int framerate;
4041
4142 /* window: */
4243 bool fullscreen;
M sxiv.1 View
@@ -4,6 +4,8 @@ sxiv \- Simple X Image Viewer
44 .SH SYNOPSIS
55 .B sxiv
66 .RB [ \-abcfhioqrtvZ ]
7+.RB [ \-A
8+.IR FRAMERATE ]
79 .RB [ \-e
810 .IR WID ]
911 .RB [ \-G
@@ -33,6 +35,10 @@ Please note, that the fullscreen mode requires an EWMH/NetWM compliant window
3335 manager.
3436 .SH OPTIONS
3537 .TP
38+.BI "\-A " FRAMERATE
39+Play animations with a constant frame rate set to
40+.IR FRAMERATE .
41+.TP
3642 .B \-a
3743 Play animations of multi-frame images.
3844 .TP