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 <blindwizard@tutanota.com>
Co-authored-by: NRK <nrk@disroot.org>
Reviewed-on: https://codeberg.org/nsxiv/nsxiv/pulls/446
Reviewed-by: eylles <eylles@noreply.codeberg.org>
Reviewed-by: NRK <nrk@disroot.org>
Co-authored-by: a1337xyz <a1337xyz@noreply.codeberg.org>
Co-committed-by: a1337xyz <a1337xyz@noreply.codeberg.org>
the multiframe loaders sets the color modifier to NULL but doesn't
restore it before returning. this results in a imlib2 developer warning
if you try to change brightness/contrast on a multiframe image (which
doesn't have alpha).
ensure that the color modifier is restored before returning under all
paths.
Reported-by: Madhu
Reviewed-on: https://codeberg.org/nsxiv/nsxiv/pulls/440
Reviewed-by: eylles <eylles@noreply.codeberg.org>
by default imlib2 doesn't check the file's timestamp to avoid disk
activity when loading from cache. however, this ends up breaking our
autoreload functionality on multi-frame images.
the reason why single frame images weren't broken was because
`img_load()` calls `imlib_image_set_changes_on_disk()`, which tells
imlib2 to check the timestamp before loading from cache.
do the same thing for the multi-frame loader as well.
additionally add a comment to img_load() explaining what's going on.
Closes: https://codeberg.org/nsxiv/nsxiv/issues/436
Reviewed-on: https://codeberg.org/nsxiv/nsxiv/pulls/437
Reviewed-by: eylles <eylles@noreply.codeberg.org>
clang-tidy currently flags the following:
util.c:57:8: error: 'ptr' may be set to null if 'realloc' fails, which may result in a leak of the original buffer [bugprone-suspicious-realloc-usage,-warnings-as-errors]
ptr = realloc(ptr, size);
the analysis here is correct, but if realloc fails, we simply exit so
there's no real "leak".
moreover this check is not very useful for nsxiv's codebase because we
do not use naked realloc(), instead we use the erealloc wrapper that
exits on failure. so just disable the warning entirely instead of
changing the source code to silence the false positive.
assertions are for debugging purposes, and so shouldn't be enabled for
"release" builds. disable it by default by using `-DNDEBUG`.
`-O2` on gcc/clang will result it slightly better binary. on tcc it'll
be ignored. and since -O is specified by POSIX there shouldn't be any
portability concern.
additionally add a (commented out) recommended debug build for gcc/clang
with address and undefined sanitizers turned on.
Closes: https://codeberg.org/nsxiv/nsxiv/issues/424
Reviewed-on: https://codeberg.org/nsxiv/nsxiv/pulls/435
Reviewed-by: explosion-mental <explosion-mental@noreply.codeberg.org>
Reviewed-by: eylles <eylles@noreply.codeberg.org>
The last time[0] this was discussed, no-one was against it but no-one
was confident in it either and so it was added to nsxiv-extra as a
patch.
But now that enough time has passed, it seems like there's a pretty high
demand for something like this because there's plenty of use-cases that
use nsxiv as a "picker" where it's meant to quickly pick a single file.
And so add this as a convenient default key-bind.
[0]: https://codeberg.org/nsxiv/nsxiv-record/pulls/42
Co-authored-by: eylles <ed.ylles1997@gmail.com>
Co-authored-by: NRK <nrk@disroot.org>
Reviewed-on: https://codeberg.org/nsxiv/nsxiv/pulls/432
Reviewed-by: NRK <nrk@disroot.org>
Co-authored-by: eylles <eylles@noreply.codeberg.org>
Co-committed-by: eylles <eylles@noreply.codeberg.org>
otherwise, it ends up applying to the manpage and git commit messages
too.
Reviewed-on: https://codeberg.org/nsxiv/nsxiv/pulls/433
Reviewed-by: eylles <eylles@noreply.codeberg.org>
Reviewed-by: explosion-mental <explosion-mental@noreply.codeberg.org>
bf6c062 tried to fixed the thumbnail leak, but it was done inside a
`if (n+1 < filecnt)` branch, meaning the thumbnail was still leaking
away whenever the last file was removed.
we need to unload the thumb regardless of whether it's in the middle or
not. this bug was caught due to the recent `assert`s that were added in
01f3cf2.
Closes: https://codeberg.org/nsxiv/nsxiv/issues/422
Reviewed-on: https://codeberg.org/nsxiv/nsxiv/pulls/423
Reviewed-by: eylles <eylles@noreply.codeberg.org>
Reviewed-by: explosion-mental <explosion-mental@noreply.codeberg.org>
removes a couple maintainers who have never been active in the
development.
there are a couple other maintainers have not been active in a while,
but was somewhat active in the past. so keep their names in it
(for now at least).
also re-arrange the entires a bit based on activity.
this section was added almost 10 years ago (see commit 60f84190f) back
when sxiv was pretty new and didn't have many contributors.
the situation has obviously changed now, especially with `nsxiv` we have
a fair amount of contributors now. so it makes no sense to special case
a couple of them.
instead of silently ignoring bogus arguments (i.e programming errors),
which can make debugging harder, it's better to assert them so that they
get caught faster in debug builds.
Reviewed-on: https://codeberg.org/nsxiv/nsxiv/pulls/406
Reviewed-by: explosion-mental <explosion-mental@noreply.codeberg.org>
now that we have long-opts, we don't have to worry about exhausting the
alphabet list for short-opts. so adding a cli flag to set/unset the
checker background makes sense.
ref: https://codeberg.org/nsxiv/nsxiv/issues/404
reported by thread-sanitizer.
the sighandler's spoiled `errno` was causing xlib to incorrectly assume some
error occurred and thus causing the crash described in #391.
to reproduce:
* Open an nsxiv window
* Open another terminal and run the following:
var=$(pidof nsxiv); while :; do kill -s SIGCHLD $var; done
putting the `pid` into a variable is actually important because doing
`$(pidof nsxiv)` inside the loop makes it really hard to reproduce the
issue, I presume because of the extra process invocation it was sending
less SIGCHLD and so putting it into a variable avoids that overhead and
is able to generate more signals.
instead of reaping the zombies manually, we now pass the
`SA_NOCLDSTOP|SA_NOCLDWAIT` for SIGCHLD instead so that the zombies are
reaped automatically.
Closes: https://codeberg.org/nsxiv/nsxiv/issues/391
Reviewed-on: https://codeberg.org/nsxiv/nsxiv/pulls/411
Reviewed-by: explosion-mental <explosion-mental@noreply.codeberg.org>
looks like some update to the markdown parser at codeberg broke our readme.
just use a simple `*` instead (escaped by `\` to be safe)
Reviewed-on: https://codeberg.org/nsxiv/nsxiv/pulls/402
posix_spawn() is designed especially for this purpose, and thus it's
much more lightweight and efficient than manually fork/dup/exec-ing.
on my system, it improves the performance of spawn() by about 10x. given
that we make frequent calls to potentially multiple scripts, the
increased efficiency will add up overtime.
using posix_spawn() also simplifies the logic quite a bit, despite the
very verbose function names. however it does make cleanup a bit more
complicated.
this patch uses the linux kernel style cleanup strategy [0] (which I'm
personally not a huge fan of, but it fits this situation quite nicely)
with a "stack-like" unwinding via `goto`-s.
additionally simplify the spawn() API by taking in {read,write}fd
pointers and returning the pid instead of using some custom struct.
this coincidently also fixes#299
[0]: https://www.kernel.org/doc/html/v4.10/process/coding-style.html?highlight=goto#centralized-exiting-of-functions
this will be a massive change compared to the usual stuff. however the
gains will be worth it:
* we gain lots of additional animated image support.
* and we'll gain _even_ more format support as imlib2 adds them, without needing
any change in our code-base.
* about ~300 LoC will be purged once we remove our internal gif and webp loader.
as for when to remove the internal loaders, a good time might be when debian
upgrades their imlib2, currently it seems to be at v1.7.5, which doesn't support
animated images.
as of now, nsxiv will continue to build with the internal gif/webp loaders
(assuming they were enabled in config.mk) if imlib2 version is below 1.8.0 and
will print out a deprecation notice.
and if imlib2 version supports multi-frame then it will simply ignore the
internal loaders and use the imlib2 one.
in other words, users shouldn't need to do anything on their side. everything
that previously functioned will continue to function regardless of the user's
imlib2 version (though they might see the annoying deprecation notice if the
imlib2 version doesn't support multi-frame images).
known issue:
* image loading performance can be noticeably worse in
imlib2 versions below 1.9.0
Closes: https://codeberg.org/nsxiv/nsxiv/issues/301
Closes: https://codeberg.org/nsxiv/nsxiv/issues/300
Reviewed-on: https://codeberg.org/nsxiv/nsxiv/pulls/373
Reviewed-by: TAAPArthur <taaparthur@noreply.codeberg.org>
* Imlib2 supports modifying gamma, brightness and contrast directly
while sxiv only supports gamma. Makes sense to extend it to brightness
and contrast as well.
* Since color corrections need to be aware of each other, they have been
refactored into one centralized function.
* This also makes the code more hackable as it makes it easier to add
more color correction functions without them interfering with each
other.
Co-authored-by: 0ion9 <finticemo@gmail.com>
Co-authored-by: NRK <nrk@disroot.org>
Reviewed-on: https://codeberg.org/nsxiv/nsxiv/pulls/396
Reviewed-by: NRK <nrk@disroot.org>
Reviewed-by: TAAPArthur <taaparthur@noreply.codeberg.org>
Co-authored-by: Berke Kocaoğlu <kberke@metu.edu.tr>
Co-committed-by: Berke Kocaoğlu <kberke@metu.edu.tr>
allows for developers to more easily run the analysis locally before
opening a pull request if they wish.
also disables a noisy warning (bugprone-assignment-in-if-condition)
producing too many false positives.
Reviewed-on: https://codeberg.org/nsxiv/nsxiv/pulls/395
Reviewed-by: Berke Kocaoğlu <kberke@metu.edu.tr>
Co-authored-by: NRK <nrk@disroot.org>
Co-committed-by: NRK <nrk@disroot.org>
this basically just extracts the logic that was previously inside
`main()` into a seperate function `add_entry()` so that it can be used
for accepting entries form stdin as well.
Closes: https://codeberg.org/nsxiv/nsxiv/issues/382
Reviewed-on: https://codeberg.org/nsxiv/nsxiv/pulls/383
Reviewed-by: Berke Kocaoğlu <berke.kocaoglu@metu.edu.tr>
the length member needed to be zero-ed before we started decoding.
this was causing unintended behavior of playing an animated webp longer
than it should under slideshow mode.
Reviewed-on: https://codeberg.org/nsxiv/nsxiv/pulls/381
Reviewed-by: Berke Kocaoğlu <berke.kocaoglu@metu.edu.tr>
the way `imlib_load_image()` works, is that it only does a lightweight
signature/metadata check. it doesn't actually decode the image. which
means that a file that has valid metadata but invalid content would get
loaded successfully.
`imlib_image_get_data_for_reading_only()` basically forces imlib to
decode the data, and thus reveal any malformed images so we can reject
it (see commit f0266187).
however, this is a spurious way of achieving the goal at hand. imlib2
already offers an `_immediately` variant which decodes the data
immediately. so just use that instead of spuriously using the "get_data"
function to force a decode.
Reviewed-on: https://codeberg.org/nsxiv/nsxiv/pulls/380
Reviewed-by: Berke Kocaoğlu <berke.kocaoglu@metu.edu.tr>
* ensure static variables comes after non-static ones
* remove depreciated DATA32 type
* prefer `sizeof(expression)` over `sizeof(Type)`.
* silence a -Wsign warning
* {gif,webp} loader: use a pointer to reduce code-noise
* gif loader: allocate in one place
Reviewed-on: https://codeberg.org/nsxiv/nsxiv/pulls/374
Reviewed-by: TAAPArthur <taaparthur@noreply.codeberg.org>
this will hopefully catch issues like [337] in the future.
not using gcc and/or clang since we have 5 build options right now,
which means 2^5 = 32 different combination. using gcc/clang would take
too much resources and time; meanwhile tcc is lightning fast.
[337]: https://codeberg.org/nsxiv/nsxiv/pulls/337
Reviewed-on: https://codeberg.org/nsxiv/nsxiv/pulls/338
Reviewed-by: eylles <eylles@noreply.codeberg.org>
currently the error messages have the shortopt hardcoded in them, even
when the user actually entered a longopt:
$ ./nsxiv --framerate v
nsxiv: Invalid argument for option -A: v
and as far as I see, there's no way to *reliably* tell weather we're
processing a longopt or a shortopt. perhaps we can do some shenanigangs
with `optind` but that seems finicky at best.
and it seems like other coreutils which support longopt has similar issues:
$ xargs --max-procs=z
xargs: invalid number "z" for -P option
utils like `grep` and `head` seems to work-around it by not mentioning the flag:
$ head --lines=z
head: invalid number of lines: ‘z’
$ grep --max-count=l
grep: invalid max count
this patch does the same thing as `grep/head` and omits the flag from
the error message.
Closes: https://codeberg.org/nsxiv/nsxiv/issues/368
Reviewed-on: https://codeberg.org/nsxiv/nsxiv/pulls/371
Reviewed-by: Berke Kocaoğlu <berke.kocaoglu@metu.edu.tr>
strtol() returns a `long`, but we're storing the result in an `int`
which might end up getting truncated. change `n` to `long` and guard
against >INT_MAX arguments in cases where it matters.
use a float for storing argument of `-S`
change `opt.slideshow` to `unsigned` similar to `img.ss.delay`
Co-authored-by: Berke Kocaoğlu <berke.kocaoglu@metu.edu.tr>
Reviewed-on: https://codeberg.org/nsxiv/nsxiv/pulls/367
Reviewed-by: Berke Kocaoğlu <berke.kocaoglu@metu.edu.tr>
Reviewed-by: explosion-mental <explosion-mental@noreply.codeberg.org>
simply running nsxiv with `--anti-alias` will enable anti-aliasing, and
running it with `--anti-alias=no` will disable it.
the cli flag will overwrite the config.h default.
Closes: https://codeberg.org/nsxiv/nsxiv/issues/349
handle a rare, but possible case of argc being 0, in which case argv[0]
would be null.
note that both POSIX and ISO C standard allow argc to be 0 and in
practice this can be triggered via calling `exec(3)` family of functions
with NULL as the first `argv`.
* disable `cert-err33-c` and `readability-identifier-length` check
which causes warnings on clang-tidy v14.
* disable all "readability" checks by default, instead just opt-into the
useful ones (such as duplicate include).
Reviewed-on: https://codeberg.org/nsxiv/nsxiv/pulls/365
Reviewed-by: Berke Kocaoğlu <berke.kocaoglu@metu.edu.tr>
* link to online man-page
* rename: "N-R-K" -> "NRK"
* separate multiple links with a comma.
otherwise the links get messed up due to `[] []` being valid syntax for
reference style links with the 2nd `[]` serving as `id`.
* prefer codeberg links over github ones
Reviewed-on: https://codeberg.org/nsxiv/nsxiv/pulls/362
Reviewed-by: explosion-mental <explosion-mental@noreply.codeberg.org>
* run_key_handler: make the logic easier to follow
* remove timeout_t
the typedef is not needed. inline the declaration similar to the other
static structs.
* simplify estrdup
reuse emalloc, instead of calling malloc and null-checking.
* win_clear: initialize `e` right away
* process_bindings: explicitly check against NULL
most pointer checks in the codebase do explicit check.
* use a named constant instead of magic number
also changes the padding from 3 to 4 bytes according to [0]. but i
couldn't find any situtation where this mattered, so perhaps the current
padding is enough. but doesn't hurt adding one more byte.
[0]: https://nullprogram.com/blog/2017/10/06/
Reviewed-on: https://codeberg.org/nsxiv/nsxiv/pulls/356
Reviewed-by: explosion-mental <explosion-mental@noreply.codeberg.org>