Commit Graph

863 Commits

Author SHA1 Message Date
N-R-K 1a18523772
fix: reset statusbar after failed keyhandler (#191)
currently if the keyhandler invocation fails, for example due to it not
being present, the statusbar does not reset and stays on "getting
keyhandler input" message.

now the return value from run_key_handler() is used to determine if the
function was successful or not. and if the function failed, we call
handle_key_handler() with false which resets the statusbar.

we also no longer call redraw() within run_key_handler() and instead assign
it's return value to dirty which does a redraw if true.
2022-01-03 09:24:26 +00:00
N-R-K f7145db7f8
remove unused function and typedef (#199)
byteorder_t and size_readable is not used anywhere within the code.

byteorder_t seems to be a remain from some time sxiv handled exif data itself instead of relying on a library, introduced in 691c6d7, and probably became irrelevant when libexif was added as dependency again. And size_readable from some time it displayed the file size in the window title, introduced in bad9a70.
2022-01-02 23:13:23 +03:00
N-R-K 0f3766eaab
fix: animation slowdown when zoomed in (#200)
rendering is a pretty expensive operation, especially when scaling with
anti-aliasing. by waiting for the image to render before setting
timeout, the actual timeout ends up being (render time + actual delay).

this pretty much fixes the slowdown entirely on all the images i've
tested. it should also improve things noticeably even in cases where
the delay between frames is shorter than how fast we can render.
although on such images, the issue may not be fixed entirely.

Closes: https://github.com/nsxiv/nsxiv/issues/70
2022-01-03 02:07:43 +06:00
N-R-K e839638156
fix: jpeg exif orientation on Imlib2 v1.7.5 (#188)
since Imlib2 v1.7.5, it is capable of parsing exif data on jpeg files
and auto orienting them. this caused nsxiv to rotate the image twice.

Closes: https://github.com/nsxiv/nsxiv/issues/187
2022-01-02 02:28:19 +06:00
MahouShoujoMivutilde e777adf985
Allow setting cache size based on memory percentage (#184)
The problem:

1. For the most people imlib2's default 4MiB is unreasonably low;

2. Hardcoding cache size to ~256MiB has performance benefits and doesn't
   increase RAM usage too much on relatively modern systems;

3. But we can't do that, because that would be detrimental to low spec systems
   that (apparently) not (?) building nsxiv from source, as been discussed
   #171

Solution:

Calculate cache size based on total memory.

Default is set as 3%, which means:
* ~245MiB for 8GiB
* ~30MiB for 1GiB
* and so on

CACHE_SIZE_LIMIT (256MiB by default) sets the highest possible value. And in
case we cannot determine the total memory (e.g since _SC_PHYS_PAGES isn't
POSIX) use CACHE_SIZE_FALLBACK (32MiB by default) instead.

Co-authored-by: NRK <nrk@disroot.org>
2022-01-01 14:55:59 +06:00
N-R-K 1a691d42f6
fix: broken compilation when using HAVE_LIBFONTS=0 (#194)
compilation currently fails with `make HAVE_LIBFONTS=0` due to
`EXIT_SUCCESS` not being defined. I assume Xft.h includes stdlib.h which
is why compilation works with HAVE_LIBFONTS=1

this switches to using 0 as cg_quit argument in keybindings. if my
interpretation of the C99 standard is correct, then 0 and EXIT_SUCCESS
means the same thing.

> If the value of status is zero or EXIT_SUCCESS, an
> implementation-defined form of the status successful termination is
> returned.
2021-12-29 22:21:59 -04:00
NRK 1c8ea413f3 add github actions (#195)
this runs both default and minimal build with gcc, clang and tcc.
2021-12-29 17:16:24 +06:00
mamg22 2e2942d926
Cleanup manpage (#186)
* Move `-T` option in manpage

The `-T` option breaks the alphabetical order of options in both the
SYNOPSIS and OPTION sections

* Reword "on bottom of" in manpage

* Pluralize "count pixel"

* Fix typos

* Reword `M` keyboard binding description

* rename info bar -> statusbar for consistency

* document all the thumbnail bindings

* Add website to HOMEPAGE section

* Add missing maintainers

* Sort maintainers by activity

Co-authored-by: NRK <nrk@disroot.org>
2021-12-24 05:25:49 +06:00
N-R-K ff88908531
specify func argument and related cleanup (#183)
* specifies the function argument type in commands.h compared to leaving
  it unspecified. all the functions in cmd_t must have arg_t as it's
  argument.
* changes to commands.h will now trigger a rebuild - this restores old
  behavior prior to 12efa0e
* cg_quit now uses it's argument as exit status
* DestroyNotify invokes cg_quit rather than calling exit directly.
* Explicitly pass EXIT_SUCCESS to cgquit in keybinding

Co-authored-by: Berke Kocaoğlu <berke.kocaoglu@metu.edu.tr>
2021-12-19 23:05:35 +06:00
Sanjay Pavan 494578cebb
README: Fix version badge (#185) 2021-12-12 12:14:33 +00:00
NRK 61da0a8ca9 refactor: move shared code into a function 2021-12-12 17:58:17 +06:00
NRK b0b16f1d0f img_load_webp: close the file handler and use errno 2021-12-12 17:58:17 +06:00
NRK 22ca3b567d img_load_webp: simplify multi-frame allocation
C89 standard specifies:
If ptr is a null pointer, the realloc function behaves like the malloc
function for the specified size.
2021-12-12 17:58:17 +06:00
NRK 3b6db44267 img_load_webp: remove unnecessary casting 2021-12-12 17:58:17 +06:00
NRK eccd7de532 remove unneeded animated-webp hacks
now that imlib2 (v1.7.5) is able to load the first frame of an
animated-webp file, we no longer need the `is_webp` check to bypass
imlib2.

ref: https://phab.enlightenment.org/T8964
2021-12-12 17:58:17 +06:00
N-R-K 7a94a5ecc6
Release version 28
Co-authored-by: Berke Kocaoğlu <berke.kocaoglu@metu.edu.tr>
2021-12-12 08:03:12 +00:00
N-R-K 36a4847bcf
fix: compile error (#182)
* fix compile error

* use variable instead of macro

* Revert "use variable instead of macro"

This reverts commit a14ef0b231c50e49906761010a4d4231ce4e3e36.

* use local variable instead of macro

* Revert "use local variable instead of macro"

This reverts commit 7e049d55d94f5c003d90e1a10187356f6a7f54b2.
2021-12-09 22:03:18 +03:00
N-R-K 79b8fefcc4
bring back zoom_levels (#156)
this still keeps the shorter zoom logic, but adds back the zoom_levels
array so that stay close to sxiv.

for users who would like to have the zoom step behavior see:
https://github.com/nsxiv/nsxiv/pull/156#issuecomment-975182631
2021-12-01 12:27:17 +00:00
N-R-K 5e0b715ecd
clarify project goals (#173)
Closes: https://github.com/nsxiv/nsxiv/issues/148
2021-12-01 12:24:45 +00:00
mamg22 127abbea77
fix crash when zooming out on small images (#178)
When rendering images, destination image width and height may become
zero due to float-to-int conversion after zoom calculation, later
crashing when creating an image using those dimensions. This sets
a minimum of 1 to both variables.

Closes #82
2021-12-01 05:52:09 +06:00
N-R-K 3bc7082f4e
fix: send implicit_mod to process_bindings (#176)
* fix: send implicit_mod to process_bindings

this solves the edge case where someone might have `ShiftMask + A` in
their keybindings compared to a plain `A`.

Closes: https://github.com/nsxiv/nsxiv/pull/166#issuecomment-978853136

* code-style: smuggle small style fix in

win_draw_bar now mimics autoreload_nop.c functions
2021-12-01 05:41:22 +06:00
Berke Kocaoğlu 68ddbe28d8
Reference customization in readme (#175)
* Document customization more thoroughly

* sneak a small doc change in

at the request of explosion-mental:
https://github.com/nsxiv/nsxiv/pull/170#issuecomment-979600811

Co-authored-by: NRK <nrk@disroot.org>
2021-11-26 14:38:00 +00:00
NRK 470f50f9f8 fix: img_load_gif: out-of-bound access
according to imlib2's gif loader, bg should already be transparent black
if bg > cmap->ColorCount
2021-11-26 15:36:05 +06:00
NRK ca7368aa89 Revert "fix: out-of-bounds access when bg not in color map"
with this patch certain gif images will fail to play. one other problem
here is that it suddenly breaks the loop without free-ing data and rows,
leading to a memory leak.

regardless, this needs to be investigated further.

here's an example image where this happens:
https://i.postimg.cc/SQf1TJJg/awoo-study.gif

This reverts commit cca7834e67.
2021-11-26 15:36:05 +06:00
N-R-K 0639047dde allow configuring imlib2's cache size (#171)
by default imlib2 uses a 4mb cache, which is quite small. this allows
users who have more memory to spare to set a bigger cache size and avoid
reloading an already viewed image if it fits into the cache.

Co-authored-by: Berke Kocaoğlu <berke.kocaoglu@metu.edu.tr>
2021-11-26 03:09:46 +06:00
N-R-K 4396031233
switch back to whitelisting modifers (#150)
* Revert "Allow any set of modifiers to be used in keybindings"

this keeps things equal with sxiv while giving users possibility to
customize USED_MODMASK if they wish.

This reverts commit 3234b0e521.

Closes: https://github.com/nsxiv/nsxiv/issues/149
Closes: https://github.com/nsxiv/nsxiv/issues/123

Co-authored-by: Berke Kocaoğlu <berke.kocaoglu@metu.edu.tr>
2021-11-24 11:44:05 +00:00
N-R-K 0262988671
rename: keyhandler_abort -> KEYHANDLER_ABORT (#172)
with the exception of arrays, all other var names in config.h are in ALL
CAPS. since keyhandler_abort is an unreleased feature, it should be okay
to rename it for consistency.

though.. in the future we should be more careful about naming when
adding new vars to config.h (or the codebase in general.)
2021-11-24 14:38:25 +03:00
N-R-K 7d87e6e412
add related projects and some doc fixes (#170)
* README: add related projects

Closes: https://github.com/nsxiv/nsxiv/issues/169

* fix readme feature section

correct animations part (we support webp animation as well) and mention
key-handler

* remove duplicate Contribution Guideline heading
2021-11-23 07:27:14 +00:00
N-R-K c6275374b0
mark functions and vars as static (#146)
the goal here to mark functions and variables not used outside the
translation unit as static. main reason for this is cleanliness. however
as a side-effect this can help compilers optimize better as it now has
guarantee that a certain function won't be called outside of that
translation unit.

one other side-effect of this is that accessing these vars/function from
config.h is now different.

if one wants to access a static var/func from different translation unit
in config.h, he would have to create a wrapper function under the right
ifdef. for static functions one would also need to forward declare it.
here's a dummy example of accessing the function `run_key_handler` from
config.h under _MAPPINGS_CONFIG

```
static void run_key_handler(const char *, unsigned);
bool send_with_ctrl(arg_t key) {
	run_key_handler(XKeysymToString(key), ControlMask);
	return false;
}
```
2021-11-20 03:51:49 +00:00
NRK 43fcd2e02e set env var NSXIV_USING_NULL for key-handler and update docs
Co-authored-by: Berke Kocaoğlu <berke.kocaoglu@metu.edu.tr>
2021-11-19 17:02:50 +06:00
NRK 2df33208d7 apply -0 to stdin/-i as well
while i was initially against this since it can be done via `xargs -0`.
the problem with this approach is that there's a limit to how many args
a command can recieve, leading to problem like this [0] when opening
large (1k~) amount of images.

there's no limit on how big stdin can be, so being able to read a
null-separated list from stdin doesn't have this problem.

[0]: https://github.com/ranger/ranger/pull/2307#issuecomment-818683515
2021-11-19 17:02:50 +06:00
N-R-K 4a282da692
use dedicated function to process key/button bindings (#166)
Co-authored-by: Arthur Williams <taaparthur@gmail.com>
2021-11-19 05:49:42 +00:00
mamg22 8f6ba7b868
Embed new nsxiv icon (#163)
Co-authored-by: Berke Kocaoğlu <berke.kocaoglu@metu.edu.tr>
Co-authored-by: NRK <nrk@disroot.org>
2021-11-13 17:43:15 +00:00
Sanjay Pavan a841d1c8de
Adding shields.io badges for Readme (#159)
* shields.io badges for Readme

* Changed up the colors a little bit

* Once again a color change

* Changed badge from code size to total lines
2021-11-06 02:02:02 -06:00
mamg22 22a6911484
Update FAQ regarding piping images (#158) 2021-11-05 07:17:08 +03:00
LuXu 36f42081d0
make width of navigation area configurable (#155)
this allows users to configure navigation width from config.h. it also
allows disabling the navigation function entirely by using a 0 width.

one extra functionality this adds is being able to define an absolute
width (in pixels) instead of just percentage via `NAV_IS_REL`.

Co-authored-by: NRK <nrk@disroot.org>
2021-11-04 04:20:28 +00:00
N-R-K abf316a066
add links to labels in CONTRIBUTING (#154) 2021-11-03 05:28:12 +00:00
Guilherme Rugai Freire d8a4d71af1
fix: man page title for neo sxiv (#152) 2021-11-01 03:13:40 +00:00
NRK d0b5005a02 -0 sends NULL separated file-list to key-handler
with this change `-0` is turned into a more generic switch which can be
used to send NULL-separated file-list to the key-handler as well.
this also means `-0` no longer implicitly enables `-o`

Closes: https://github.com/nsxiv/nsxiv/issues/140
2021-10-29 17:45:55 -06:00
Arthur Williams 8934744c60 Add colors and fonts to config.h (#115)
Adds a set of config vars to control window fg/bg, bar fg/bg, mark
color and bar font. This allows everything that can be done from
.Xresources to be configurable from config.h.

Co-authored-by: N-R-K <79544946+N-R-K@users.noreply.github.com>
2021-10-29 12:53:49 +06:00
N-R-K 850bc788c3
code-style: general cleanups (#137)
* tns_clean_cache: remove unused function arg

* remove malloc casting

* improve consistency

use sizeof(T) at the end

* avoid comparing integers of different signedness

* use Window type for embed and parent

* remove unnecessary comparisons

* remove cpp style comments

* improve consistency: remove comma from the end of enumerator list

* Removed useless _IMAGE_CONFIG defines

* consistency: use the same order as snprintf

* Resolve c89 warnings


Co-authored-by: uidops <uidops@protonmail.com>
Co-authored-by: Arthur Williams <taaparthur@gmail.com>
2021-10-29 02:00:53 +06:00
N-R-K 03eb664e89
remove unnecessary animated webp related check
this code snippet was introduced in
2703809a23
but does not seem to be needed.

from what i can tell this is some sort of hack that might've been needed
back when we didn't bypass imlib2 when loading webp.
2021-10-28 16:45:26 +06:00
eylles 5b3221cfa6
update copyright notice (#139) 2021-10-28 16:41:16 +06:00
N-R-K f46d30591a
eleminate padding from struct img on 64bit systems (#136)
on 64bit systems this reduces the size of the struct from 104 bytes down
to 96 bytes.

on 32bits system this change shouldn't have any affect.
2021-10-28 16:38:32 +06:00
N-R-K 7e7eaf08f1
fix: memory leak due to not destroying XrmDatabase (#134) 2021-10-28 01:57:03 +00:00
LuXu 57754572bc Add default key-binding for DRAG_RELATIVE (#117)
Ctrl-Button1 now has a relative drag using the XC_fleur cursor.
XC_fleur is normally the cursor for "size all" action, which has 4
arrows pointing to 4 directions.

Co-authored-by: NRK <nrk@disroot.org>
2021-10-27 09:02:07 +06:00
N-R-K 1f01c670c5
fix: memory leak in img_load_webp (#135)
if `multi.cap` is >0 that means `multi.frames` has already been malloc-ed. by
unconditionally malloc-ing again, we're losing all the old memory.

this makes it so we're only malloc-ing (or realloc-ing) when needed.
2021-10-26 17:41:11 +00:00
javad bbebd45ce6 code-style: remove extra casts (#130)
Co-authored-by: N-R-K <79544946+N-R-K@users.noreply.github.com>
2021-10-24 06:41:17 +06:00
N-R-K 7b08b0a31b
remove TODO.md (#127)
it's one extra file that serves no real purpose. Instead TODO.md has
been converted into open issues:
https://github.com/nsxiv/nsxiv/issues/126
https://github.com/nsxiv/nsxiv/issues/125

Co-authored-by: Berke Kocaoğlu <berke.kocaoglu@metu.edu.tr>
2021-10-19 13:24:22 +00:00
N-R-K 804a0f4304
README: add package manager section (#111)
Closes: https://github.com/nsxiv/nsxiv/issues/72
2021-10-19 13:00:23 +00:00