From e4fceab18f4b7856a2ef6fbabebe1988c1fbfaea Mon Sep 17 00:00:00 2001 From: a1337xyz Date: Tue, 23 May 2023 03:01:44 +0000 Subject: [PATCH 1/7] move load/cache messages to right side (#446) this avoids overwriting the left side bar, which might contain more important information, for e.g output of the thumb-info script. Co-authored-by: A1337Xyz Co-authored-by: NRK Reviewed-on: https://codeberg.org/nsxiv/nsxiv/pulls/446 Reviewed-by: eylles Reviewed-by: NRK Co-authored-by: a1337xyz Co-committed-by: a1337xyz --- main.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/main.c b/main.c index 3868e8e..fed9528 100644 --- a/main.c +++ b/main.c @@ -434,12 +434,12 @@ static void update_info(void) r->p = r->buf; if (mode == MODE_THUMB) { if (tns.loadnext < tns.end) - bar_put(l, "Loading... %0*d", fw, tns.loadnext + 1); + bar_put(r, "Loading... %0*d | ", fw, tns.loadnext + 1); else if (tns.initnext < filecnt) - bar_put(l, "Caching... %0*d", fw, tns.initnext + 1); - else if (info.ft.err) - strncpy(l->buf, files[fileidx].name, l->size); + bar_put(r, "Caching... %0*d | ", fw, tns.initnext + 1); bar_put(r, "%s%0*d/%d", mark, fw, fileidx + 1, filecnt); + if (info.ft.err) + strncpy(l->buf, files[fileidx].name, l->size); } else { bar_put(r, "%s", mark); if (img.ss.on) { From 0e1bc3c045384bca18922accbc50fa6914a67bd0 Mon Sep 17 00:00:00 2001 From: NRK Date: Tue, 23 May 2023 11:36:41 +0000 Subject: [PATCH 2/7] set a default delay if delay is 0 (#445) gif spec [0] doesn't mention what to do when "Delay Time" is 0. apng spec [1] states: | If the the value of the numerator is 0 the decoder should render the | next frame as quickly as possible, though viewers may impose a | reasonable lower bound. webp spec [2]: | the interpretation of frame duration of 0 (and often <= 10) is | implementation defined. so it seems that it's safe to set a default delay for 0 delay frames, which is what the older gif and webp loaders were already doing. do the same for the imlib2 multi-frame loader as well. [0]: https://www.w3.org/Graphics/GIF/spec-gif89a.txt [1]: https://wiki.mozilla.org/APNG_Specification [2]: https://developers.google.com/speed/webp/docs/riff_container#animation Reviewed-on: https://codeberg.org/nsxiv/nsxiv/pulls/445 Reviewed-by: eylles --- image.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/image.c b/image.c index 4f9015d..426a05a 100644 --- a/image.c +++ b/image.c @@ -54,6 +54,10 @@ enum { DEF_GIF_DELAY = 75 }; enum { DEF_WEBP_DELAY = 75 }; #endif +#if HAVE_IMLIB2_MULTI_FRAME +enum { DEF_ANIM_DELAY = 75 }; +#endif + #define ZOOM_MIN (zoom_levels[0] / 100) #define ZOOM_MAX (zoom_levels[ARRLEN(zoom_levels) - 1] / 100) @@ -539,7 +543,7 @@ static bool img_load_multiframe(img_t *img, const fileinfo_t *file) imlib_context_set_blend(!!(finfo.frame_flags & IMLIB_FRAME_BLEND)); imlib_blend_image_onto_image(frame, has_alpha, 0, 0, sw, sh, sx, sy, sw, sh); m->frames[m->cnt].im = canvas; - m->frames[m->cnt].delay = finfo.frame_delay; + m->frames[m->cnt].delay = finfo.frame_delay ? finfo.frame_delay : DEF_ANIM_DELAY; m->length += m->frames[m->cnt].delay; m->cnt++; imlib_context_set_image(frame); From 40480596cad8654dca225e7fb136f4151f5df5c0 Mon Sep 17 00:00:00 2001 From: NRK Date: Fri, 26 May 2023 07:06:17 +0000 Subject: [PATCH 3/7] make assertions opt-in (#447) slight addendum to 657080a7e55843e351fa6ce41e4ce315eab62b67 instead of disabling asserts by adding -DNDEBUG to config.mk, this disables asserts by default in the source code itself. this way, if someone compiles with `make CFLAGS="-O3 -march=native"` without knowing about asserts/-DNDEBUG then he won't accidentally get a build with assertions in it. this basically makes the assertions opt-in, if someone wants it, he'll need to *explicitly* set `-DDEBUG` to get it. so that it's not possible to accidentally end up with assertions enabled. Reviewed-on: https://codeberg.org/nsxiv/nsxiv/pulls/447 Reviewed-by: TAAPArthur --- config.mk | 2 +- nsxiv.h | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/config.mk b/config.mk index 44ec692..20bb2b2 100644 --- a/config.mk +++ b/config.mk @@ -26,7 +26,7 @@ CC = c99 # CFLAGS, any additional compiler flags goes here CFLAGS = -Wall -pedantic -O2 -DNDEBUG # Uncomment for a debug build using gcc/clang -# CFLAGS = -Wall -pedantic -g3 -fsanitize=address,undefined +# CFLAGS = -Wall -pedantic -DDEBUG -g3 -fsanitize=address,undefined # LDFLAGS = $(CFLAGS) # icons that will be installed via `make icon` diff --git a/nsxiv.h b/nsxiv.h index 8011f9e..7e373c2 100644 --- a/nsxiv.h +++ b/nsxiv.h @@ -20,6 +20,10 @@ #ifndef NSXIV_H #define NSXIV_H +#if !defined(DEBUG) && !defined(NDEBUG) + #define NDEBUG +#endif + #include #include From c03ec39437b473526080f496d6c8564e98bea1d7 Mon Sep 17 00:00:00 2001 From: NRK Date: Sun, 28 May 2023 06:49:07 +0000 Subject: [PATCH 4/7] update documentation (#448) the fedora copr repo is no longer being updated since the maintainer of it, mamg22, no longer uses nsxiv in his daily setup (and thus stopped contributing to nsxiv as well). he has requested the repo and his email to be removed from the project. so go ahead and honor that request. also take this as an opportunity to remove some long inactive maintainers from the CURRENT MAINTAINERS section of the manpage. Reviewed-on: https://codeberg.org/nsxiv/nsxiv/pulls/448 Reviewed-by: explosion-mental --- README.md | 4 ---- etc/nsxiv.1 | 5 ----- 2 files changed, 9 deletions(-) diff --git a/README.md b/README.md index bc303d4..70376d7 100644 --- a/README.md +++ b/README.md @@ -58,10 +58,6 @@ nsxiv is available on the following distributions/repositories. If you don't see your distro listed here, either contact your distro's package maintainer or consider packaging it yourself and adding it to the respective community repo. -Repos not tracked by repology: - -* Fedora: Enable the copr repo via `dnf copr enable mamg22/nsxiv`. - Dependencies ------------ diff --git a/etc/nsxiv.1 b/etc/nsxiv.1 index 10f131a..e2fb4c8 100644 --- a/etc/nsxiv.1 +++ b/etc/nsxiv.1 @@ -569,11 +569,6 @@ TAAPArthur eylles Stein Gunnar Bakkeby explosion-mental -mamg22 -LuXu -Guilherme Freire -Sam Whitehead -Kian Kasad .EE .SH CONTRIBUTORS .EX From 28018e92d3e2fa47d58a216bab489cbd81d8e974 Mon Sep 17 00:00:00 2001 From: NRK Date: Thu, 15 Jun 2023 15:25:54 +0000 Subject: [PATCH 5/7] CI: misc cleanups + faster analysis (#449) * switch to git ls-files to avoid picking up any other local .c files * enable assertions during static analysis since we used some assertions to disable/silence certain warnings. * update TCC commit hash to a more recent one * parallelize static analysis cppcheck already has -j argument to parallelize it's analysis and provide results faster, clang-tidy unfortunately doesn't. so use xargs -P to archive parallel execution. on my system this brings down the analysis time from ~27s to ~5s. --- .github/workflows/build.yml | 2 +- etc/woodpecker/analysis.sh | 17 ++++++++++------- etc/woodpecker/analysis.yml | 2 +- etc/woodpecker/build.yml | 2 +- 4 files changed, 13 insertions(+), 10 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 4619bb7..3c3b3c1 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -16,7 +16,7 @@ jobs: sudo apt-get install libimlib2 libimlib2-dev xserver-xorg-core xserver-xorg-dev \ libxft2 libxft-dev libexif12 libexif-dev \ gcc clang git bc - TCC_SHA="027b8fb9b88fe137447fb8bb1b61079be9702472" + TCC_SHA="29ae3ed4d5b83eec43598d6cd7949bccb41c8083" wget "https://github.com/TinyCC/tinycc/archive/${TCC_SHA}.tar.gz" && tar xzf "${TCC_SHA}.tar.gz" ( cd "tinycc-$TCC_SHA" && ./configure && make -j"$(nproc)" && sudo make install; ) - name: build diff --git a/etc/woodpecker/analysis.sh b/etc/woodpecker/analysis.sh index 330d140..5a227ce 100755 --- a/etc/woodpecker/analysis.sh +++ b/etc/woodpecker/analysis.sh @@ -1,21 +1,24 @@ #!/bin/sh -e std="c99" +NProc=$(( $(nproc) / 4 )) +if [ -z "$NProc" ] || [ "$NProc" -lt 1 ]; then NProc="1"; fi run_cppcheck() { cppcheck --std="$std" --enable=performance,portability \ --force --quiet --inline-suppr --error-exitcode=1 \ - --max-ctu-depth=8 -j"$(nproc)" \ - $(make OPT_DEP_DEFAULT="$1" dump_cppflags) \ + --max-ctu-depth=8 -j"$NProc" \ + $(make OPT_DEP_DEFAULT="$1" dump_cppflags) -DDEBUG \ --suppress=varFuncNullUB --suppress=uninitvar \ - *.c + $(git ls-files *.c) } run_tidy() { checks="$(sed '/^#/d' etc/woodpecker/clang-tidy-checks | paste -d ',' -s)" - clang-tidy --warnings-as-errors="*" --checks="$checks" --quiet *.c \ - -- -std="$std" $(make OPT_DEP_DEFAULT="$1" dump_cppflags) + git ls-files *.c | xargs -P"$NProc" -I{} clang-tidy --quiet \ + --warnings-as-errors="*" --checks="$checks" {} \ + -- -std="$std" $(make OPT_DEP_DEFAULT="$1" dump_cppflags) -DDEBUG } -run_cppcheck "0"; run_cppcheck "1"; -run_tidy "0"; run_tidy "1"; +run_cppcheck "0" & run_cppcheck "1" & run_tidy "0" & run_tidy "1"; +wait diff --git a/etc/woodpecker/analysis.yml b/etc/woodpecker/analysis.yml index 65da7aa..9ebcc4f 100644 --- a/etc/woodpecker/analysis.yml +++ b/etc/woodpecker/analysis.yml @@ -4,7 +4,7 @@ pipeline: analysis: image: alpine commands: | - apk add --no-cache build-base cppcheck clang-extra-tools \ + apk add --no-cache build-base cppcheck clang-extra-tools git \ imlib2-dev xorgproto \ libxft-dev libexif-dev giflib-dev libwebp-dev >/dev/null make config.h version.h diff --git a/etc/woodpecker/build.yml b/etc/woodpecker/build.yml index eced0d1..7c79a90 100644 --- a/etc/woodpecker/build.yml +++ b/etc/woodpecker/build.yml @@ -5,7 +5,7 @@ pipeline: build: image: alpine environment: - - TCC_SHA=027b8fb9b88fe137447fb8bb1b61079be9702472 + - TCC_SHA=29ae3ed4d5b83eec43598d6cd7949bccb41c8083 commands: | apk add --no-cache \ imlib2 imlib2-dev xorgproto \ From 3097037624881791cc544d0d0dab384a2af43bf6 Mon Sep 17 00:00:00 2001 From: explosion-mental Date: Wed, 15 Mar 2023 23:32:20 -0500 Subject: [PATCH 6/7] make xresources class name configurable in config.h --- config.def.h | 14 +++++++------- window.c | 12 ++++++------ 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/config.def.h b/config.def.h index 5d4e97a..c49a5eb 100644 --- a/config.def.h +++ b/config.def.h @@ -6,14 +6,14 @@ static const int WIN_HEIGHT = 600; /* colors and font can be overwritten via X resource properties. * See nsxiv(1), X(7) section Resources and xrdb(1) for more information. - */ -static const char *DEFAULT_WIN_BG = "white"; -static const char *DEFAULT_WIN_FG = "black"; -static const char *DEFAULT_MARK_COLOR = NULL; /* NULL means it will default to window foreground */ + * X resource default value */ +static const char *WIN_BG[] = { "Nsxiv.window.background", "white" }; +static const char *WIN_FG[] = { "Nsxiv.window.foreground", "black" }; +static const char *MARK_FG[] = { "Nsxiv.mark.foreground", NULL }; /* NULL means it will default to window foreground */ #if HAVE_LIBFONTS -static const char *DEFAULT_BAR_BG = NULL; /* NULL means it will default to window background */ -static const char *DEFAULT_BAR_FG = NULL; /* NULL means it will default to window foreground */ -static const char *DEFAULT_FONT = "monospace-8"; +static const char *BAR_BG[] = { "Nsxiv.bar.background", NULL }; /* NULL means it will default to window background */ +static const char *BAR_FG[] = { "Nsxiv.bar.foreground", NULL }; /* NULL means it will default to window foreground */ +static const char *BAR_FONT[] = { "Nsxiv.bar.font", "monospace-8" }; /* if true, statusbar appears on top of the window */ static const bool TOP_STATUSBAR = false; diff --git a/window.c b/window.c index b170614..8b513bd 100644 --- a/window.c +++ b/window.c @@ -141,20 +141,20 @@ void win_init(win_t *win) res_man = XResourceManagerString(e->dpy); db = res_man == NULL ? NULL : XrmGetStringDatabase(res_man); - win_bg = win_res(db, RES_CLASS ".window.background", DEFAULT_WIN_BG); - win_fg = win_res(db, RES_CLASS ".window.foreground", DEFAULT_WIN_FG); - mrk_fg = win_res(db, RES_CLASS ".mark.foreground", DEFAULT_MARK_COLOR ? DEFAULT_MARK_COLOR : win_fg); + win_bg = win_res(db, WIN_BG[0], WIN_BG[1]); + win_fg = win_res(db, WIN_FG[0], WIN_FG[1]); + mrk_fg = win_res(db, MARK_FG[0], MARK_FG[1] ? MARK_FG[1] : win_fg); win_alloc_color(e, win_bg, &win->win_bg); win_alloc_color(e, win_fg, &win->win_fg); win_alloc_color(e, mrk_fg, &win->mrk_fg); #if HAVE_LIBFONTS - bar_bg = win_res(db, RES_CLASS ".bar.background", DEFAULT_BAR_BG ? DEFAULT_BAR_BG : win_bg); - bar_fg = win_res(db, RES_CLASS ".bar.foreground", DEFAULT_BAR_FG ? DEFAULT_BAR_FG : win_fg); + bar_bg = win_res(db, BAR_BG[0], BAR_BG[1] ? BAR_BG[1] : win_bg); + bar_fg = win_res(db, BAR_FG[0], BAR_FG[1] ? BAR_FG[1] : win_fg); xft_alloc_color(e, bar_bg, &win->bar_bg); xft_alloc_color(e, bar_fg, &win->bar_fg); - f = win_res(db, RES_CLASS ".bar.font", DEFAULT_FONT); + f = win_res(db, BAR_FONT[0], BAR_FONT[1]); win_init_font(e, f); win->bar.l.buf = lbuf; From 6185bcb441ac6c2f5c1e94c5f15e9dd678418e56 Mon Sep 17 00:00:00 2001 From: NRK Date: Fri, 23 Jun 2023 22:10:27 +0600 Subject: [PATCH 7/7] config.h: allow all values to be NULL might as well make things consistent instead of having certain values that can be NULL and certain that cannot. some of the default values are still kept in config.h for example reasons. --- config.def.h | 8 ++++---- window.c | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/config.def.h b/config.def.h index c49a5eb..7fbfb17 100644 --- a/config.def.h +++ b/config.def.h @@ -6,13 +6,13 @@ static const int WIN_HEIGHT = 600; /* colors and font can be overwritten via X resource properties. * See nsxiv(1), X(7) section Resources and xrdb(1) for more information. - * X resource default value */ + * X resource value (NULL == default) */ static const char *WIN_BG[] = { "Nsxiv.window.background", "white" }; static const char *WIN_FG[] = { "Nsxiv.window.foreground", "black" }; -static const char *MARK_FG[] = { "Nsxiv.mark.foreground", NULL }; /* NULL means it will default to window foreground */ +static const char *MARK_FG[] = { "Nsxiv.mark.foreground", NULL }; #if HAVE_LIBFONTS -static const char *BAR_BG[] = { "Nsxiv.bar.background", NULL }; /* NULL means it will default to window background */ -static const char *BAR_FG[] = { "Nsxiv.bar.foreground", NULL }; /* NULL means it will default to window foreground */ +static const char *BAR_BG[] = { "Nsxiv.bar.background", NULL }; +static const char *BAR_FG[] = { "Nsxiv.bar.foreground", NULL }; static const char *BAR_FONT[] = { "Nsxiv.bar.font", "monospace-8" }; /* if true, statusbar appears on top of the window */ diff --git a/window.c b/window.c index 8b513bd..387d789 100644 --- a/window.c +++ b/window.c @@ -141,8 +141,8 @@ void win_init(win_t *win) res_man = XResourceManagerString(e->dpy); db = res_man == NULL ? NULL : XrmGetStringDatabase(res_man); - win_bg = win_res(db, WIN_BG[0], WIN_BG[1]); - win_fg = win_res(db, WIN_FG[0], WIN_FG[1]); + win_bg = win_res(db, WIN_BG[0], WIN_BG[1] ? WIN_BG[1] : "white"); + win_fg = win_res(db, WIN_FG[0], WIN_FG[1] ? WIN_FG[1] : "black"); mrk_fg = win_res(db, MARK_FG[0], MARK_FG[1] ? MARK_FG[1] : win_fg); win_alloc_color(e, win_bg, &win->win_bg); win_alloc_color(e, win_fg, &win->win_fg); @@ -154,7 +154,7 @@ void win_init(win_t *win) xft_alloc_color(e, bar_bg, &win->bar_bg); xft_alloc_color(e, bar_fg, &win->bar_fg); - f = win_res(db, BAR_FONT[0], BAR_FONT[1]); + f = win_res(db, BAR_FONT[0], BAR_FONT[1] ? BAR_FONT[1] : "monospace-8"); win_init_font(e, f); win->bar.l.buf = lbuf;