Commit graph

446 commits

Author SHA1 Message Date
Simon Ser 1817ef3df1 wl_window: fix buffer size not divisible by scale
Do not commit the surface with the new scale and the old buffer.
Leave it to the next rendering pass to commit the surface.

Fixes the following protocol error:

    wl_surface@10: error 2: Buffer size (717x795) is not divisible by scale (2)

Closes: https://todo.sr.ht/~exec64/imv/20
2023-01-18 21:37:38 +00:00
Cem Keylan 4448fb6104 console: update libgrapheme API to version 1 2021-12-22 18:23:07 +00:00
Harry Jeffery c7306a6325 wl_window: Fix segfault with latest wlroots
imv is currently binding to the latest version of all the interfaces,
but should instead bind the latest version that it supports. imv is not
compatible with wl_output v4 and so was crashing when the latest wlroots
offered it.

This patch pins a maximum version for each wayland interface that is
bound.

https://todo.sr.ht/~exec64/imv/1
2021-12-14 09:48:45 +00:00
Harry Jeffery 3b5a4d8cb7 x11_window: Fix typo in if statement 2021-12-08 22:03:26 +00:00
Cem Keylan a83304d4d6 Add support for libgrapheme as an icu replacement 2021-12-08 21:12:20 +00:00
aeghn 9ce7c5de6d Add '-w' option to specify window title at startup 2021-12-08 21:12:20 +00:00
Ivan Oleynikov 5e36d10afc Draw background rectangle behind the (possibly multiline) overlay text
Before this commit, the background rectangle was drawn to cover only one line
of text (which was ok since multiline overlay text was not supported). Now
the code correctly calculates the dimensions on the rendered text and put the
rectangle of the right size under it.
2021-11-30 18:14:43 +00:00
Ivan Oleynikov a810b71f14 Move Cairo layout creation and display code to two separate functions
This effectively splits the imv_canvas_printf function into two separate
functions, one to create a layout containing given text and the other one
to show it on the canvas. These functions can be useful for the future code
I will add to display text with a background rectangle behind it. Existing
imv_canvas_printf function does not allow this
2021-11-30 18:14:43 +00:00
Ivan Oleynikov 4690692154 Set IFS env variable to "" for overlay_text shell expansion
This prevents wordexp function from splitting the output of shell expansion
into “words” and, as a consequence, removing the newlines from it. With this
commit applied, setting

  overlay_text = $(echo -e 'hello\nworld!')

displays

  hello
  world!

in Imv window. Without this commit, the same overlay_text setting would display

  hello world!

since wordexp splits the string "hello\nworld!" into two words and connects
them with a space.

This should not break any of the commands executed in $(), because the IFS
variable is *not* inherited by their shell. The commands don't see this change
and run with the default IFS value.
2021-11-30 18:14:43 +00:00
Tuomas Siipola 9ae3ee1da1 Show chequered pattern on image instead of viewport
OpenGL is used for rendering because `cairo_rectangle` and
`cairo_pattern_t` had performance problems on zoomed and rotated images.

The size and contrast of the chequered pattern is also reduces to match
other image viewers and editors.

Closes #253
2021-11-30 18:13:24 +00:00
n3f4s 8935fafb40 Add limit for looking through STDIN 2021-11-30 18:09:29 +00:00
n3f4s 72bda973f4 Pull path from pipe when -n given 2021-11-30 18:09:29 +00:00
Issam E. Maghni ac30f34bd3 cairo: Replace <cairo/cairo.h> by <cairo.h>
See https://gitlab.freedesktop.org/cairo/cairo/-/blob/master/doc/tutorial/src/include/cairo-tutorial.h
2021-09-05 17:59:51 +00:00
Ivan Oleynikov f71548ce45 Make freeimage backend have preceedence over libjpeg
The current implementation of freeimage backend automatically rotates the
images based on EXIF info. Libjpeg backed doesn't do that (although libjpeg
itself may be able to, I didn't check). This commit makes Imv use freeimage for
jpeg files when both backends are available to enable automatic image rotation
when possible.

A cleaner solution could be to add automatic rotaiton functionality to libjpeg
backend as well, but this quick hack is better than nothing ☺
2021-08-05 21:01:30 +00:00
kat witch b194997c20 Fix lack of X11 window deletion event handling 2021-07-29 17:02:35 +00:00
Ivan Oleynikov 33560e8e2e WIP: Use set_size instead of set_absolute_size for font
This seems to have a better behavior, this way, the fonts in Imv seem to have
the same size as the fonts in other programs (Sway, Waybar) when configured in
the same way.
2021-07-29 17:01:31 +00:00
Ivan Oleynikov 3c1d27d885 Scale fonts when Wayland updates scaling factor
Before this commit, the code in src/wl_window.c seemed to handle the Wayland
scaling [1] correctly, it was sending resize events to imv to update the buffer
size accordingly. One thing it didn't update is the scaling of fonts that Pango
renders on Cairo.

This commit simply forwards the scaling factor (computed as [1] requests)
together with updated buffer dimentions in resize event, and when the resize
event is handled it calls cairo_surface_set_device_scale to notify Pango/Cairo
of the scaling.

For X11, I simply assume the scaline factor is always 1. This seems to be what
the old code did: `grep scale src/x11_window.c` gives no matches. AFAIK, X11
does not have an established way of telling clients what scaling factor to use
(and never updates it at runtime).

[1]: https://wayland-book.com/surfaces-in-depth/hidpi.html
2021-07-29 17:01:31 +00:00
Harry Jeffery eeaf5e3cb9 Also suppress TIFF errors from stdin 2021-07-09 00:18:47 +01:00
Harry Jeffery 8d91875207 Suppress annoying TIFF errors
Fixes #252
2021-07-09 00:00:44 +01:00
Harry Jeffery 27df0fb8fe Fix image skipping when reading slow filesystems
Fixes #201
2021-07-08 23:46:16 +01:00
Ronan Dalton eccd3cf912 Fix zoom speed dependence on buffer/image width 2021-07-08 23:17:35 +01:00
n3f4s 22cd0b3813 Don't stop listing files in dir when stat fail
Check errno when stat fail during traversal of a directory: doesn't stop
traversing for all stat errors
2021-07-08 23:16:08 +01:00
mx deb8b5a864 fix double-free when backend libjpeg is used 2021-06-24 21:22:13 +01:00
Aleksander Szczygieł ff0b802c03 Resolve path in imv_navigator_find_path()
All items' pathes are resolved in add_item() so path used in imv_navigator_find_path() should be resolved too. This patch fixes #308
2021-04-14 15:33:32 +01:00
Pascal Sommer 8e46aa0238 use exponential increments for zooming 2021-04-14 15:29:38 +01:00
Matthias Coppens 2c0f10a91b Include string header 2021-04-14 15:28:52 +01:00
Harry Jeffery 1b85ba53b0 Wayland: Perform display roundtrip after changing scale
Fixes #305
2021-01-09 16:15:10 +00:00
Harry Jeffery 49ba898e92 Fix first/last image indexing bug
Fixes #301
2020-12-17 20:18:09 +00:00
Matthias Coppens e3f135a0ad Add include limits.h 2020-12-17 19:48:00 +00:00
Scott Moreau 91e06fff2d wayland: Fix initial black screen due to size of 0x0
https://gitlab.freedesktop.org/wayland/wayland-protocols/-/blob/master/stable/xdg-shell/xdg-shell.xml#L1037
states regarding xdg_toplevel.configure "The width and height arguments specify a hint to the window". imv
was using these dimensions even if they are 0x0, which is valid for the compositor to send. Clearly this is
a bad hint and should be ignored. This patch does that, and fixes #293.
2020-12-02 00:20:01 +00:00
Stephan Lachnit 84a1f7aa83 Use system inih if available
* inih is now widely available as a system library
* if not, a fallback from Wrap DB can be used

Signed-off-by: Stephan Lachnit <stephanlachnit@protonmail.com>
2020-12-02 00:19:14 +00:00
Érico Rolim 82960d3c41 imv: don't rely on glibc's lack of FILE sync on exit.
This issue was spotted on musl, where killing imv with the Q shortcut
while it was waiting for image paths in stdin led to the application
hanging until stdin received an EOF manually with ^D, since the stdin
stream was locked by the fgets() function.

Switching to pipes and a helper thread allows us to use read() for
reading from STDIN_FILENO while still taking advantage of the fgets()
logic for handling newlines and buffer size. read() is a thread
cancellation point (fgets() is only an optional one), which makes it
possible to cancel the helper thread cleanly and force the thread using
fgets() to exit when the write-end of the pipe it's reading from is
closed.
2020-12-02 00:11:51 +00:00
Érico Rolim 489421b9e7 imv, ipc: improve error checking for ipc creation.
Since this isn't essential functionality, it's ok to simply not provide
it. In cases where XDG_RUNTIME_DIR was empty (but not unset) or set to a
directory where the user didn't have write permissions, socket creation
would fail and lead to segmentation faults in imv, due to the return
value of imv_ipc_create() not being checked.
2020-11-16 22:12:07 +00:00
Érico Rolim 6cb2b8495f imv: fix stdin prompt and use fputs.
Add newline to the prompt for reading paths from stdin.

Since string formatting isn't being used, it's possible to use fputs()
directly in the logging callback in imv.c.
2020-11-16 22:11:32 +00:00
Harry Jeffery 0131ab6f97 Fix bug handling multi-key binds 2020-08-31 14:21:24 +01:00
Torstein Husebø 90cc7adbd2 treewide: fix typos 2020-08-31 13:56:50 +01:00
Andreas Stallinger df0d1cf7c2 colored overlay: config options in man, split rgba
split color_rgba into color_rgb and alpha
added configuration options to man pages

cleanup gitignore: the man pages output is now in the build directory,
so there is no to ignore man pages individually
2020-08-31 13:53:03 +01:00
Andreas Stallinger d1e4f7fcff colored overlay
* first steps for colored overlay
* overlay color wip
* add option for overlay position
    if overlay_positiion_bottom is true overlay is at the bottom
* remove enum for overlay position
2020-08-31 13:53:03 +01:00
Tuomas Siipola afe155dcea Support rotate and flip commands on SVG 2020-07-21 01:54:17 +01:00
Clownacy 61533df66c Sort directory entries alphabetically
Previously, they would be sorted by however readdir returned them.

I suppose a proper configuration option to control sorting would be
nice, but for now, I think replacing forced random order with forced
alphabetical order is an improvement.
2020-07-21 01:52:17 +01:00
Aleksei Bavshin 500a6b3acc Use private mapping for memfd with keymap.
mmap with MAP_SHARED would fail if the compositor provides a read-only
descriptor with keymap. And at least weston applies F_SEAL_WRITE to the
memfd if supported by the platform.

Fixes #263
2020-07-21 01:50:01 +01:00
Tuomas Siipola ebcca13452 Fix XVisualInfo leak
It's not documented when this value should be freed but other GLX
applications free it here.
2020-07-21 01:47:24 +01:00
Tuomas Siipola b37902d438 Fix X11 window cleanup 2020-07-21 01:47:24 +01:00
Tuomas Siipola d457ced783 Fix keymap leak 2020-07-21 01:47:24 +01:00
Tuomas Siipola a200fbf945 Fix librsvg usage to prevent memory leak
Calling `rsvg_handle_close` doesn't do anything here because the handle
is already constructed with data or file. `g_object_unref` is called
instead to free memory.
2020-07-21 01:47:24 +01:00
Kenny Levinsen ef2231b7d0 wayland: Do not commit surface until configure 2020-07-21 01:45:53 +01:00
Kenny Levinsen 05a4d5b359 wayland: Use wl_display_roundtrip to wait for globals 2020-07-21 01:45:53 +01:00
Anton Älgmyr 8fac7401bc Make rotation clockwise
The documentation already stated that it should be clockwise,
seems like I switched/intended to switch and some point.
2020-06-12 01:00:10 +01:00
Anton Älgmyr 19ed1931be Reset transforms on image switch. 2020-06-12 01:00:10 +01:00
Anton Älgmyr a71709b889 Unify rotation commands, reset transformation properly 2020-06-12 01:00:10 +01:00