Commit Graph

987 Commits

Author SHA1 Message Date
NRK
5cab2fb525 reject empty xresources (#340)
currently, in case of an empty xresources we would fail to init:

	nsxiv: Error allocating color ''

instead, just reject empty value and use the fallback.

Closes: https://codeberg.org/nsxiv/nsxiv/issues/339

Reviewed-on: https://codeberg.org/nsxiv/nsxiv/pulls/340
Reviewed-by: Berke Kocaoğlu <berke.kocaoglu@metu.edu.tr>
Co-authored-by: NRK <nrk@disroot.org>
Co-committed-by: NRK <nrk@disroot.org>
2022-07-05 11:24:53 +02:00
NRK
51d4c8dd4f check for utf8_decode errors (#327)
utf8_decode() may return an errors, in which case the returned codepoint
might be garbage. the issue can be tested by adding the following to
`image-info` which produces invalid utf8 sequences:

	base64 -d << EOF
	9JCAgPSQgIH0kICC9JCAg/SQgIT0kICF9JCAhvSQgIf0kICI9JCAifSQgIr0kICL9JCAjPSQgI30
	kICO9JCAj/SQgJD0kICR9JCAkvSQgJP0kICU9JCAlfSQgJb0kICX9JCAmPSQgJn0kICa9JCAm/SQ
	gJz0kICd9JCAnvSQgJ8=
	EOF

on my system, this leads to the statusbar being filled with empty boxes.

check for returned error and skip the iteration.

Reviewed-on: https://codeberg.org/nsxiv/nsxiv/pulls/327
Reviewed-by: Berke Kocaoğlu <berke.kocaoglu@metu.edu.tr>
2022-07-03 12:45:50 +02:00
NRK
7c59cc7edc fix build failure due to missing <stdio.h> (#337)
the following combination currently fails to build:

	$ make HAVE_LIBFONTS=0 HAVE_LIBWEBP=1

this is probably because one of the font library was including <stdio.h>

Reviewed-on: https://codeberg.org/nsxiv/nsxiv/pulls/337
Reviewed-by: Berke Kocaoğlu <berke.kocaoglu@metu.edu.tr>
Reviewed-by: TAAPArthur <taaparthur@noreply.codeberg.org>
Co-authored-by: NRK <nrk@disroot.org>
Co-committed-by: NRK <nrk@disroot.org>
2022-07-03 08:16:56 +02:00
Berke Kocaoğlu
5c2c719735 Clean up readme (#330)
Co-authored-by: NRK <nrk@disroot.org>
Reviewed-on: https://codeberg.org/nsxiv/nsxiv/pulls/330
Reviewed-by: NRK <nrk@disroot.org>
2022-06-29 01:02:17 +02:00
NRK
b162aee497 sort and group includes
* includes are sorted alphabetically

* their grouping and layout is the following:
  - nsxiv.h will be the first include
  - followed by any internal headers (e.g "commands.h" "config.h")
  - followed by system headers (<stdlib.h> etc)
  - followed by third party headers (X.h libwebp etc)

* also add `llvm-include-order` check to clang-tidy so that it can catch
  unsorted includes during CI.
2022-06-28 21:28:06 +02:00
NRK
6d5a04005d code-style: cleanup includes
* rm unused include <sys/types.h>
* move <sys/time.h> to main.c, it's the only file that needs it.
* move TV_* macros to main.c
* let *.c files explicitly include what they need instead of including
  them at nsxiv.h
2022-06-28 21:28:06 +02:00
NRK
86a83c1ec5 CHANGELOG: use reference style links (#325)
Originally we stopped doing links in the CHANGELOG since it harmed
readability when reading the raw markdown file. However we can use
reference styles links instead.

* Pros
  - Doesn't harm readability.
  - We can link to proper thread on the proper repo (`CodeBerg/nsxiv`
    for newer threads, `nsxiv-record` for wiped ones)
  - The links will be clickable on the [webpage]
  - Both GitHub and Codeberg support reference style links, as well as
    lowdown (which we use for building the webpage)

[webpage]: https://nsxiv.codeberg.page/changelog/

* Cons
  - Slightly higher maintainance burden.
  - Larger file size.

Reviewed-on: https://codeberg.org/nsxiv/nsxiv/pulls/325
Reviewed-by: Berke Kocaoğlu <berke.kocaoglu@metu.edu.tr>
2022-06-27 21:20:59 +02:00
NRK
f78626c187 CHANGELOG: update title and link (#324)
now that CHANGELOG has it's own webpage [0], update the title
accordingly. also change the link to `nsxiv-record` instead.

[0]: https://nsxiv.codeberg.page/changelog/

Reviewed-on: https://codeberg.org/nsxiv/nsxiv/pulls/324
Reviewed-by: Berke Kocaoğlu <berke.kocaoglu@metu.edu.tr>
2022-06-27 10:48:00 +02:00
NRK
50f7b767c9 [ci]: check for typos via codespell (#326)
also fix any found issues.

Reviewed-on: https://codeberg.org/nsxiv/nsxiv/pulls/326
Reviewed-by: Berke Kocaoğlu <berke.kocaoglu@metu.edu.tr>
2022-06-27 10:47:14 +02:00
NRK
8248729320 [ci]: skip the pipeline entirely if branch isn't master
currently, it will clone the repo and then skip the step. this is
wasteful, instead skip the pipeline entirely.
2022-06-25 08:27:01 +02:00
NRK
a9d2b5b088 [ci]: suppress some cppcheck warnings
cppcheck warns about passing a plain NULL to construct_argv()

	main.c:254:36: portability: Passing NULL after the last typed argument to a variadic function leads to undefined behaviour. [varFuncNullUB]
	                fidx, fcnt, w, h, z, NULL);

in our case, POSIX mandates `NULL` to be defined as `(void *)0` rather
than a plain `0` [0]. and void pointers are required to have the same
representation and size as char pointers [1]. so this is not an issue we
need to worry about.

[0]: https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/stddef.h.html#tag_13_47
[1]: https://port70.net/~nsz/c/c99/n1256.html#6.2.5p27
2022-06-25 08:27:01 +02:00
NRK
5c3a796e55 [ci]: slience some clang-tidy warnings
the warnings on r_readdir(), img_load_gif() and strcpy seems to be false
positives. the warning about fmt being unused is valid, but not worth
fixing with additional #ifdef guards.

use `assert` to silence the false positive cases when possible,
otherwise use a NOLINT comment with an explanation.
2022-06-25 08:27:01 +02:00
NRK
4cf17d2349 fix: memory leak in r_readdir()
reported by clang-tidy: `filename` gets leaked when this branch gets
taken.
2022-06-25 08:27:01 +02:00
NRK
b28449e10c fix: don't use reserved identifiers
identifiers beginning with an underscore is reserved by the C standard.
2022-06-25 08:27:01 +02:00
NRK
f23d57d4ad [ci]: use cppcheck and clang-tidy for static analysis 2022-06-25 08:27:01 +02:00
NRK
658a935c04 fix: potentially printing wrong error message (#321)
it's possible for the close() calls to override the errno resulting in
incorrect error message being printed.

call error() immediately to avoid such possibilities.

also refactor a couple conditions to avoid doing multiple checks.

Reviewed-on: https://codeberg.org/nsxiv/nsxiv/pulls/321
Reviewed-by: Berke Kocaoğlu <berke.kocaoglu@metu.edu.tr>
2022-06-25 08:21:05 +02:00
NRK
9812d601c1 r_mkdir: don't truncate the path on error (#322)
currently, in case of error, r_mkdir will leave the path at a truncated
state.

a7d39b0ab8 is the commit that introduced this change, and in it the
error printing is moved from r_mkdir to the caller, which makes me think
it was probably intentional.

make it so that the function itself prints the error/warning
message and returns the path back to the caller unharmed.

Reviewed-on: https://codeberg.org/nsxiv/nsxiv/pulls/322
Reviewed-by: Berke Kocaoğlu <berke.kocaoglu@metu.edu.tr>
Reviewed-by: TAAPArthur <taaparthur@noreply.codeberg.org>
2022-06-22 05:05:03 +02:00
NRK
a67665a1c1 add codeberg ci and cleanup github one (#311)
- apt-get is slow, takes up ~1m40s just to install deps, fix it by not
  using it. instead use alpine linux for codeberg ci, which brings build
  time down to 25s.
- And since alpine uses musl, it's probably a good idea to use it on our
  ci since it might catch us using any glibc extensions. The github ci
  can keep using ubuntu.
- remove duplication of CFLAGS by having it on a separate file instead.
- remove pull_request from github ci since we no longer accept PRs
  there.

Closes: https://codeberg.org/nsxiv/nsxiv/issues/307

Reviewed-on: https://codeberg.org/nsxiv/nsxiv/pulls/311
Reviewed-by: Berke Kocaoğlu <berke.kocaoglu@metu.edu.tr>
Reviewed-by: TAAPArthur <taaparthur@noreply.codeberg.org>
2022-06-16 05:08:09 +02:00
NRK
33a5d54cae Release version 30
Co-authored-by: NRK <nrk@disroot.org>
Co-authored-by: Berke Kocaoğlu <berke.kocaoglu@metu.edu.tr>
2022-06-15 16:07:46 +02:00
Sanjay Pavan
91e097a4e6 Fix links in readme (#309)
The former worked on GitHub, but does not work on Codeberg.

Reviewed-on: https://codeberg.org/nsxiv/nsxiv/pulls/309
Reviewed-by: Berke Kocaoğlu <berke.kocaoglu@metu.edu.tr>
Co-authored-by: Sanjay Pavan <withercubes@protonmail.com>
Co-committed-by: Sanjay Pavan <withercubes@protonmail.com>
2022-06-12 18:49:49 +02:00
NRK
4c6d26bef4 Move over to codeberg (#293)
Reviewed-by: Berke Kocaoğlu <berke.kocaoglu@metu.edu.tr>
2022-06-11 15:38:07 +02:00
eylles
09d2d738ad
adds emblems of mirrors 2022-06-06 18:56:21 -06:00
NRK
e9a0096d6d code-style: simplify window title related code
instead of dancing around with some `init` parameter, directly give
`win_set_title()` what it needs. `get_win_title()` now also does *just*
what the name says.

this simplifies things quite a bit and the functions now do what their
name implies more closely instead of doing some `init` dance internally.
2022-06-02 08:09:51 +00:00
NRK
810a9651a3 reduce calls to win-title
rather than calling the script unconditionally per redraw, we now have
a `title_dirty` flag and keep track of when any of the relavent
information changes.

Co-authored-by: Arthur Williams <taaparthur@gmail.com>
Partially fixes: https://github.com/nsxiv/nsxiv/issues/258
2022-06-02 08:09:51 +00:00
N-R-K
364c3d6f01
avoid doing dynamic allocation for bar buffers (#279)
just use a static buffer since the size is constant and doesn't change.

as opposed to using malloc, this also sets the buffer's initial memory
region to 0 by default.

also remove BAR_{L,R}_LEN from nsxiv.h, not needed after commit b4268fbf38
2022-06-01 07:40:49 +06:00
N-R-K
57ff8afe02
Makefile: add utf8.h as window.o dependency (#280)
unlikely for utf8.h to change, other than syncing with upstream, but
doesn't hurt tracking it either ways.
2022-05-31 06:54:32 +00:00
NRK
c713186ce9 Makefile: use lowercase for internal macros
ref: 971f5d6694
2022-05-30 12:07:01 +00:00
NRK
6c30fb22cc config.mk: use c99 as default CC
See https://github.com/nsxiv/nsxiv/issues/262#issuecomment-1111216349
for related discussion.
2022-05-30 12:07:01 +00:00
NRK
0d202f0fe1 config.mk: add comments for OpenBSD users
Closes: https://github.com/nsxiv/nsxiv/issues/262
2022-05-30 12:07:01 +00:00
NRK
197afce935 introduce config.mk
this moves all the build variables intended to be modified by the user
over to `config.mk` similar to other suckless software.

also move CPPFLAGS down below for cosmetic purposes.
2022-05-30 12:07:01 +00:00
N-R-K
450797c573
fix: broken slideshow if redraw takes too long (#282)
currently the way check_timeout() is implemented, animate has higher
priority than slideshow. so if doing a redraw takes longer than the
frame delay of the animated image then it's going to continuously keep
animating and never reliably get to slideshow.

this issue can occur if the animated image has too fast of a delay or if
nsxiv is being run on a slow system where doing redraw takes too long.
the issue can be emulated by artificially slowing down img_render by
sticking a sleep in there.

	diff --git a/main.c b/main.c
	index 5dc52d4..0580011 100644
	--- a/main.c
	+++ b/main.c
	@@ -441,6 +441,7 @@ void redraw(void)

	 	if (mode == MODE_IMAGE) {
	 		img_render(&img);
	+		nanosleep(&(struct timespec){0, 62000000}, NULL); /* 62ms */
	 		if (img.ss.on) {
	 			t = img.ss.delay * 100;
	 			if (img.multi.cnt > 0 && img.multi.animate)

make it so that slideshow has higher priority than animate to fix
the issue.

Closes: https://github.com/nsxiv/nsxiv/issues/281
2022-05-28 06:48:44 +00:00
NRK
b4268fbf38 fix: broken statusbar after key-handler cancellation
to reproduce:
1. have an image-info script
2. invoke the key-handler
3. cancle invocation by pressing `escape`
at this point, the statusbar ends up being empty.

the regression seems to be caused by 6922d5d (changing select to poll),
unsure why that is.

in any case, this simplifies read_info quite a bit and solves the
regression as well. in short:

* read straight into the statusbar buffer
* if read succeeds, make sure buffer is null terminated and replace any
  newline with space
* close the script
2022-05-19 11:44:30 +00:00
NRK
f255e1cc12 fix: don't override statusbar if info script doesn't exist
this happens when the keyhandler is invoked while viewing an animated
image. if {image,thumb}-info scripts exists, everything works as
expected. but if they don't, then update_info will override the
statusbar.
2022-05-19 11:44:30 +00:00
NRK
3bf198ecd3 fix: broken thumbnail statusbar after running keyhandler 2022-05-19 11:44:30 +00:00
N-R-K
633a4f66d9
check_timeouts: avoid unnecessary conversions (#273)
before we were using select, which expected `struct timeval` as
arg. so we needed to do ms -> timeval conversions.

but now since we're using poll, which accepts milisec as arg, there's
no need to do ms -> timeval -> ms. instead have check_timeouts directly
return ms.
2022-05-12 14:47:46 +00:00
N-R-K
3a22e6a6c5
Declare every extern function/variable in nsxiv.h (#268)
with a couple exceptions as they cause too many -Wshadow warnings.

also moves the `extcmd_t` typedef on top for cosmetic purposes.

also enable `-Wmissing-prototypes` in the ci
2022-05-03 15:36:57 +00:00
N-R-K
591be8cecf
Add thumb-info (#265)
Closes: https://github.com/nsxiv/nsxiv/issues/88
Closes: https://github.com/nsxiv/nsxiv/pull/253
2022-05-03 15:34:23 +00:00
N-R-K
6922d5d01b
replace select() with poll() (#270)
usage of select (3) in modern programs is typically discouraged.
this simply replaces the select call with poll (3) instead.

and since poll conveniently ignores negative fds, this also reduces
needs for some special casing.

this also handles error if they occur, while old implementation didn't.
other than the error handling, no change in functionality should occur.
2022-04-28 03:12:15 +00:00
N-R-K
5bb1df4af3
README: some wording change and cosmetics (#269) 2022-04-28 01:11:27 +00:00
explosion-mental
f9662efb1f
merge autoreload_{inotify,nop}.c into autoreload.c (#263) 2022-04-27 01:43:27 +00:00
N-R-K
29c6b1456e
code-style: reduce some unnecessary if-elses (#261)
also change the condition inside img_frame_animate() to check for
positive value rather than comparing against 0.
2022-04-27 01:25:11 +00:00
Michael
7fb8a61c47
Update .desktop entry's mimetypes (#260)
Co-authored-by: NRK <nrk@disroot.org>
2022-04-17 19:59:07 +00:00
N-R-K
f05165a77a
don't quit if imlib_create_image() fails (#248)
...simply print an error msg and try (slower) fallback.

also adds a useful comment explaining why we're doing manual blending.
2022-04-12 17:05:59 +00:00
N-R-K
ec5a51d798
fix: correctly close the font (#250)
currently we immediately close the font on win_init_font(), which was
introduced in 0d8dcfd. this was probably not correct since we use `font`
later in win_draw_text().

instead, the font should be closed at exit/cleanup.
2022-04-10 12:36:09 +00:00
Kim Woelders
14e9c34ecc Improve starting in fullscreen mode
Instead of effectively first mapping the window at regular size and then
fullscreening it, tell the WM to map the window at fullscreen size by
setting _NET_WM_STATE_FULLSCREEN before mapping the window.
2022-03-31 14:52:50 +00:00
Kim Woelders
e9468d3d36 Correct setting of _NET_WM_PID
The property _NET_WM_PID is a CARDINAL which per definition has format
32, whatever the size of pid_t may be.
CARDINALS (and other format 32 items) must always be passed to Xlib in
long's, whatever the size of long may be.
2022-03-31 14:52:50 +00:00
N-R-K
bf6c062779
fix: thumbnail memory leak when removing file (#247) 2022-03-27 09:34:44 +00:00
Nick Morrott
590d9fe0a9
Fix typo and manpage improvement (#249)
* Fixes some typo and adds some consistency to the manpage

Typo detected automatically whilst packaging nsxiv for Debian

Co-authored-by: NRK <nrk@disroot.org>
2022-03-26 10:02:22 +00:00
N-R-K
1ef0c1f152
fix: close the file descriptor in get_win_title() (#245)
this would eventually end up opening too many fds and erroring out with
"too many open files".
2022-03-17 19:18:22 +00:00
Berke Kocaoğlu
7f71ddf4fc
Export known issues in readme to GitHub issues (#243)
Export known issues in readme to GitHub issues and link the issue
2022-03-08 10:23:35 +03:00