summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.travis.yml29
-rw-r--r--COPYING2
-rw-r--r--ChangeLog83
-rw-r--r--README.md2
-rw-r--r--man/feh.pre550
-rw-r--r--src/collage.c2
-rw-r--r--src/debug.h2
-rw-r--r--src/events.c6
-rw-r--r--src/feh.h2
-rw-r--r--src/filelist.c4
-rw-r--r--src/gib_list.c1
-rw-r--r--src/imlib.c56
-rw-r--r--src/index.c15
-rw-r--r--src/index.h2
-rw-r--r--src/keyevents.c29
-rw-r--r--src/list.c2
-rw-r--r--src/main.c16
-rw-r--r--src/menu.c2
-rw-r--r--src/menu.h2
-rw-r--r--src/options.c8
-rw-r--r--src/options.h6
-rw-r--r--src/signals.c6
-rw-r--r--src/signals.h2
-rw-r--r--src/slideshow.c61
-rw-r--r--src/structs.h2
-rw-r--r--src/thumbnail.c30
-rw-r--r--src/thumbnail.h2
-rw-r--r--src/timers.c2
-rw-r--r--src/wallpaper.c75
-rw-r--r--src/wallpaper.h2
-rw-r--r--src/winwidget.c205
-rw-r--r--src/winwidget.h3
32 files changed, 719 insertions, 492 deletions
diff --git a/.travis.yml b/.travis.yml
new file mode 100644
index 0000000..f59e68c
--- /dev/null
+++ b/.travis.yml
@@ -0,0 +1,29 @@
+language: c
+addons:
+ apt:
+ packages:
+ - libcurl4-openssl-dev
+ - libx11-dev
+ - libxt-dev
+ - libimlib2-dev
+ - libxinerama-dev
+ - libjpeg-progs
+ - libtest-command-perl
+ - libtest-simple-perl
+ - libexif-dev
+ - libexif12
+script:
+ - make
+ - make test
+compiler:
+ - clang
+ - gcc
+env:
+ - default=1
+ - app=1
+ - curl=0
+ - exif=1
+ - help=1
+ - stat64=1
+ - verscmp=0
+ - xinerama=0
diff --git a/COPYING b/COPYING
index a71c9bd..5d6b707 100644
--- a/COPYING
+++ b/COPYING
@@ -1,5 +1,5 @@
Copyright (C) 1999,2000 Tom Gilbert.
-Copyright (C) 2010-2016 Daniel Friesel.
+Copyright (C) 2010-2018 Daniel Friesel.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to
diff --git a/ChangeLog b/ChangeLog
index 1258251..901afc0 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,86 @@
+Tue, 17 Jul 2018 17:33:10 +0200 Daniel Friesel <derf+feh@finalrewind.org>
+
+* Release v2.27.1
+ * Fix feh occasionally becoming unresponsive when asked to terminate
+ via SIGINT/SIGQUIT/SIGTERM (based on a patch by
+ <https://github.com/giladogit>)
+ * Fix --keep-zoom-vp issues introduced in 2.27
+ (patch by <https://github.com/ulteq>)
+
+Thu, 28 Jun 2018 17:26:54 +0200 Daniel Friesel <derf+feh@finalrewind.org>
+
+* Release v2.27
+ * Fix size_to_image ("w") command when both --scale-down and --keep-zoom-vp
+ are enabled
+ * Fix --auto-zoom not being triggered on window resize events when
+ --scale-down is enabled
+ * Fix --auto-zoom conflicting with manual zoom
+ * Fix feh_draw_checks not taking the zoom level into account properly
+ * Prevent --zoom <percent> from blocking --scale-down in fullscreen / fixed
+ geometry mode
+ * Prevent --keep-zoom-vp from blocking the dynamic window resizing
+ mechanism
+ * Prevent automatic recalculation of the zoom ratio when --keep_zoom_vp
+ is enabled
+ * All patches provided by <https://github.com/ulteq>. Thanks a lot!
+
+Tue, 26 Jun 2018 10:33:04 +0200 Daniel Friesel <derf+feh@finalrewind.org>
+
+* Release v2.26.4
+ * Correctly save --bg-max in ~/.fehbg (patch by Sebastian Bickerle)
+
+Fri, 18 May 2018 22:58:02 +0200 Daniel Friesel <derf+feh@finalrewind.org>
+
+* Release v2.26.3
+ * Properly escape --image-bg argument in ~/.fehbg (broken in 2.26.1)
+
+Sat, 12 May 2018 16:33:56 +0200 Daniel Friesel <derf+feh@finalrewind.org>
+
+* Release v2.26.2
+ * Show correct filelist position in windows opened from thumbnail mode.
+ Note that navigation is still not supported in those windows
+ * Improve support for key input from stdin
+ * Do not push menus off the screen when hitting screen limits
+
+Fri, 11 May 2018 15:11:17 +0200 Daniel Friesel <derf+feh@finalrewind.org>
+
+* Release v2.26.1
+ * Restore pre-2.21 ~/.fehbg behaviour. This fixes nondeterministic
+ wallpaper setting when using --bg-* --randomize, issues when specifying
+ --theme both in ~/.fehbg and on the commandline, and possibly other
+ edge cases
+ * Fix /tmp being cluttered with temporary ImageMagick files when using
+ --magick-timeout and a conversion takes longer than allowed
+
+Thu, 19 Apr 2018 21:43:12 +0200 Daniel Friesel <derf+feh@finalrewind.org>
+
+* Release v2.26
+ * Save absolute file paths in ~/.fehbg, similar to the behaviour prior to
+ feh 2.21
+ * Add %g (window dimensions) and %Z (precise zoom level) format specifiers
+ * Improve -z/--randomize randomness
+
+Wed, 07 Mar 2018 17:49:52 +0100 Daniel Friesel <derf+feh@finalrewind.org>
+
+* Release v2.25.1
+ * Fix compilation issues when using CFLAGS=-m64 on some gcc versions
+ * Re-render current image when toggle_fixed_geometry is input
+
+Sun, 04 Mar 2018 08:53:50 +0100 Daniel Friesel <derf+feh@finalrewind.org>
+
+* Release v2.25
+ * Add --version-sort option to enable natural sorting of file and directory
+ names. This requires a libc with strverscmp support, which is a
+ non-POSIX GNU extension. Use the new build flag `verscmp=0` to disable
+ this feature on systems which do not ship strverscmp
+ (patch by ulteq)
+ * Allow arbitrary X11 colors as -B/--image-bg argument (patch by ulteq)
+ * Improve --image-bg support and transparency handling in --bg-* mode
+ * Respect --geometry settings in --bg-fill mode
+ * Add keybinding toggle_auto_zoom (default "Z") to toggle --auto-zoom
+ * Fix filelists specified by -f/--filelist not being reloaded when using
+ --reload
+
Mon, 26 Feb 2018 21:41:38 +0100 Daniel Friesel <derf+feh@finalrewind.org>
* Release v2.24
diff --git a/README.md b/README.md
index 7848158..334e681 100644
--- a/README.md
+++ b/README.md
@@ -1,3 +1,5 @@
+[![build status](https://travis-ci.org/derf/feh.svg?branch=master)](https://travis-ci.org/derf/feh)
+
# feh
Imlib2 based image viewer
---
diff --git a/man/feh.pre b/man/feh.pre
index 7b1e791..28c1132 100644
--- a/man/feh.pre
+++ b/man/feh.pre
@@ -13,7 +13,7 @@
.
.Nm
.Op Ar options
-.Op Ar files No | Ar directories No | Ar URLs ...
+.Op Ar files | Ar directories | Ar URLs ...
.
.
.Sh VERSION
@@ -32,9 +32,9 @@ $MAN_XINERAMA$, builtin EXIF support $MAN_EXIF$$MAN_DEBUG$
.Sh DESCRIPTION
.
.Nm
-is a mode-based image viewer. It is especially aimed at command line users who
-need a fast image viewer without huge GUI dependencies, though it can also be
-started by
+is a mode-based image viewer.
+It is especially aimed at command line users who need a fast image viewer
+without huge GUI dependencies, though it can also be started by
.Pq graphical
file managers to view an image.
By default
@@ -75,8 +75,9 @@ options.
.
.Pp
.
-Slideshow mode is the default. It opens a window and displays the first
-image in it; the slideshow position can be advanced
+Slideshow mode is the default.
+It opens a window and displays the first image in it;
+the slideshow position can be advanced
.Pq or otherwise changed
using keyboard and mouse shortcuts.
In slideshow mode, images can be deleted either from the filelist or from the
@@ -87,14 +88,17 @@ An image can also be read from stdin via
.
.Pp
.
-Montage mode forms a montage from the filelist. The resulting image can be
-viewed or saved, and its size can be limited by height, width or both.
+Montage mode forms a montage from the filelist.
+The resulting image can be viewed or saved,
+and its size can be limited by height, width or both.
.
.Pp
.
-Index mode forms an index print from the filelist. Image thumbnails are shown
-along with the filename, filesize and pixel size, printed using a truetype
-font of your choice. The resulting image can be viewed or saved, and its size
+Index mode forms an index print from the filelist.
+Image thumbnails are shown along with the filename,
+filesize and pixel size, printed using a truetype
+font of your choice.
+The resulting image can be viewed or saved, and its size
can be limited by height, width or both.
.
.Pp
@@ -105,34 +109,40 @@ the selected image in a new window.
.Pp
.
Multiwindow mode shows images in multiple windows, instead of as a slideshow
-in one window. Don't use with a large filelist ;)
+in one window.
+Don't use with a large filelist ;)
.
.Pp
.
-List mode doesn't display images. Instead, it outputs an
+List mode doesn't display images.
+Instead, it outputs an
.Cm ls Ns No - Ns style
listing of the files in the filelist, including image info such as size, number
-of pixels, type, etc. There is also a Customlist mode which prints image info
+of pixels, type, etc.
+There is also a Customlist mode which prints image info
in a custom format specified by a printf-like format string.
.
.Pp
.
.Nm
can also list either all the loadable files in a filelist or all the
-unloadable files. This is useful for preening a directory.
+unloadable files.
+This is useful for preening a directory.
.
.
.Sh SUPPORTED FORMATS
.
.Nm
can open any format supported by Imlib2, most notably jpeg, png,
-pnm, tiff, and bmp. The gif format is also supported, but only for static
-images. In case of animations, only the first frame will be shown.
+pnm, tiff, and bmp.
+The gif format is also supported, but only for static images.
+In case of animations, only the first frame will be shown.
.
If the convert binary
.Pq supplied by ImageMagick
is available, it also has limited support for many other filetypes, such as
-svg, xcf and otf. Use
+svg, xcf and otf.
+Use
.Cm --magick-timeout Ar num
with a non-negative value to enable it.
.
@@ -143,11 +153,13 @@ with a non-negative value to enable it.
.
.It Cm -A , --action Oo Ar flag Oc Ns Oo [ Ar title ] Oc Ns Ar action
.
-Specify a shell command as an action to perform on the image. In slideshow or
-multiwindow mode, the action will be run when the action_0 key is pressed, in
-list mode, it will be run for each file. In loadable/unloadable mode, it will
-be run for each loadable/unloadable file, respectively. In thumbnail mode,
-clicking on an image will cause the action to run instead of opening the image.
+Specify a shell command as an action to perform on the image.
+In slideshow or multiwindow mode, the action will be run when
+the action_0 key is pressed, in list mode, it will be run for each file.
+In loadable/unloadable mode, it will be run for each loadable/unloadable
+file, respectively.
+In thumbnail mode, clicking on an image will cause the action to run instead
+of opening the image.
.
.Pp
.
@@ -164,7 +176,7 @@ after
executing the action.
.
If
-.No [ Ar title ]
+.Ar [ title ]
is specified
.Pq note the literal Qo \&[ Qc and Qo ] Qc ,
.Cm --draw-actions
@@ -172,10 +184,12 @@ will display
.Ar title
instead of
.Ar action
-in the action list. Note that
+in the action list.
+Note that
.Ar title
-must not start with a space. If it does, the action is handled as if it did
-not have a title. This special case exists for backwards compatibility reasons
+must not start with a space.
+If it does, the action is handled as if it did not have a title.
+This special case exists for backwards compatibility reasons
and makes sure that actions like
.Qq \&[ -L %F \&] && foo
still work.
@@ -183,10 +197,11 @@ still work.
.
.Pp
.
-The action will be executed by /bin/sh. Use format specifiers to refer to
-image info, see
+The action will be executed by /bin/sh.
+Use format specifiers to refer to image info, see
.Sx FORMAT SPECIFIERS
-for details. Example usage:
+for details.
+Example usage:
.Qq feh -A Qo mv ~/images/%N Qc * .
.
.It Cm --action1 No .. Cm --action9 Oo Ar flag Oc Ns Oo [ Ar title ] Oc Ns Ar action
@@ -196,7 +211,8 @@ Extra actions which can be set and triggered using the appropriate number key.
.It Cm --auto-rotate
.
.Pq optional feature, $MAN_EXIF$ in this build
-Automatically rotate images based on EXIF data. Does not alter the image files.
+Automatically rotate images based on EXIF data.
+Does not alter the image files.
.
.It Cm -Z , --auto-zoom
.
@@ -210,25 +226,30 @@ Create borderless windows.
.
Set Imlib2 in-memory cache to
.Ar size
-MiB. A higher cache size can
-significantly improve performance especially for small slide shows, however at
-the cost of increased memory consumption.
+MiB.
+A higher cache size can significantly improve performance especially for small
+slide shows, however at the cost of increased memory consumption.
.Ar size
must be between 0 and 2048 MiB and defaults to 4.
.
.It Cm -P , --cache-thumbnails
.
-Enable thumbnail caching in
-.Pa ~/.thumbnails .
-Only works with thumbnails <= 256x256 pixels.
+Enable thumbnail caching.
+Thumbnails are saved in
+.Pa $XDG_CACHE_HOME/thumbnails ,
+which defaults to
+.Pa ~/.cache/thumbnails .
+Note that thumbnails are only cached if the configured thumbnail size does
+not exceed 256x256 pixels.
.
.It Cm -K , --caption-path Ar path
.
-Path to directory containing image captions. This turns on caption viewing,
-and if captions are found in
+Path to directory containing image captions.
+This turns on caption viewing, and if captions are found in
.Ar path ,
which is relative to the directory of each image, they are overlayed on the
-displayed image. E.g. with caption path
+displayed image.
+E.g. with caption path
.Qq captions/ ,
and viewing image
.Qq images/foo.jpg ,
@@ -239,7 +260,8 @@ the caption will be looked for in
.
Don't display images, print image info according to
.Ar format
-instead. See
+instead.
+See
.Sx FORMAT SPECIFIERS .
.
.It Cm --cycle-once
@@ -271,7 +293,8 @@ on a semi-transparent background to improve their readability
.
.It Cm -f , --filelist Ar file
.
-This option is similar to the playlists used by music software. If
+This option is similar to the playlists used by music software.
+If
.Ar file
exists, it will be read for a list of files to load, in the order they appear.
The format is a list of image filenames, absolute or relative to the current
@@ -282,7 +305,8 @@ directory, one filename per line.
If
.Ar file
doesn't exist, it will be created from the internal filelist at the end of a
-viewing session. This is best used to store the results of complex sorts
+viewing session.
+This is best used to store the results of complex sorts
.Pq Cm -Spixels No for example
for later viewing.
.
@@ -294,7 +318,8 @@ will be saved to
.Ar file
when
.Nm
-exits. You can add files to filelists by specifying them on the command line
+exits.
+You can add files to filelists by specifying them on the command line
when also specifying the list.
.
.Pp
@@ -308,8 +333,9 @@ will read the filelist from its standard input.
.
.It Cm -e , --font Ar font
.
-Set global font. Should be a truetype font, resident in the current directory
-or the font directory, and should be defined in the form fontname/points, like
+Set global font.
+Should be a truetype font, resident in the current directory or the font
+directory, and should be defined in the form fontname/points, like
.Qq myfont/12 .
.
.It Cm -C , --fontpath Ar path
@@ -337,7 +363,8 @@ Note: This option needs to load all images to calculate the dimensions of the
.Nm
window, so when using it with many files it will take a while before a
.Nm
-window is visible. Use
+window is visible.
+Use
.Cm --preload
to get a progress bar.
.
@@ -348,7 +375,8 @@ Note that in this mode, large images will always be scaled down to fit the
screen,
.Cm --zoom Ar zoom
only affects smaller images and never scales larger than necessary to fit the
-screen size. The only exception is a
+screen size.
+The only exception is a
.Ar zoom
of 100, in which case images will always be shown at 100% zoom, no matter
their dimensions.
@@ -357,20 +385,22 @@ their dimensions.
.
When combined with
.Cm --thumbnails ,
-this option only affects images opened from the thumbnail overview. The
-thumbnail list itself will still be windowed.
+this option only affects images opened from the thumbnail overview.
+The thumbnail list itself will still be windowed.
.
-.It Cm -g , --geometry Oo Ar width No x Ar height Oc Op + Ar x No + Ar y
+.It Cm -g , --geometry Ar width Cm x Ar height | Cm + Ar x Cm + Ar y | Ar width Cm x Ar height Cm + Ar x Cm + Ar y
.
-Limit (and don't change) the window size. Takes an X-style geometry
+Limit (and don't change) the window size.
+Takes an X-style geometry
.Ar string
like 640x480 with optional +x+y window offset.
-Note that larger images will be zoomed out to fit, but you can see them at 1:1
-by clicking the zoom button.
+Use
+.Cm --scale-down
+to scale down larger images like in fullscreen mode.
.
Also note that this option does not enforce the geometry, changing it by a tiling
-WM or manually is still possible. After each resize, the resulting window size
-is used as the new size limit.
+WM or manually is still possible.
+After each resize, the resulting window size is used as the new size limit.
.
.It Cm -Y , --hide-pointer
.
@@ -392,9 +422,11 @@ default is black.
.
.It Cm -i , --index
.
-Enable Index mode. Index mode is similar to montage mode, and accepts the
-same options. It creates an index print of thumbnails, printing the image
-name beneath each thumbnail. Index mode enables certain other options, see
+Enable Index mode.
+Index mode is similar to montage mode, and accepts the same options.
+It creates an index print of thumbnails, printing the image name beneath
+each thumbnail.
+Index mode enables certain other options, see
.Sx INDEX AND THUMBNAIL MODE OPTIONS
and
.Sx MONTAGE MODE OPTIONS .
@@ -403,8 +435,9 @@ and
.
Execute
.Ar commandline
-and display its output in the bottom left corner of the image. Can be used to
-display e.g. image dimensions or EXIF information. Supports
+and display its output in the bottom left corner of the image.
+Can be used to display e.g. image dimensions or EXIF information.
+Supports
.Sx FORMAT SPECIFIERS .
.
If
@@ -427,8 +460,9 @@ or in the current working directory.
.It Cm --insecure
.
When viewing files with HTTPS, this option disables strict hostname and peer
-checking. This allows images on sites with self-signed certificates to be
-opened, but is no more secure than plain HTTP.
+checking.
+This allows images on sites with self-signed certificates to be opened, but is
+no more secure than plain HTTP.
.
.It Cm --keep-zoom-vp
.
@@ -437,30 +471,28 @@ When switching images, keep zoom and viewport settings
.
.It Cm -l , --list
.
-Don't display images. Analyze them and display an
+Don't display images.
+Analyze them and display an
.Xr ls 1 - No style
-listing. Useful in scripts to hunt out images of a certain
-size/resolution/type etc.
+listing.
+Useful in scripts to hunt out images of a certain size/resolution/type etc.
.
.It Cm -U , --loadable
.
-Don't display images. Just print out their names if imlib2 can successfully
-load them.
+Don't display images.
+Just print out their names if imlib2 can successfully load them.
Returns false if at least one image failed to load.
.
.It Cm --magick-timeout Ar timeout
.
Stop trying to convert unloadable files after
.Ar timeout
-seconds. A negative value disables covert / magick support altogether, a value
+seconds.
+A negative value disables covert / magick support altogether, a value
of zero causes
.Nm
-to try indefinitely. By default, magick support is disabled.
-.
-Note that feh may clutter
-.Pa /tmp
-with temporary files created by ImageMagick for each failed conversion attempt.
-This is a known bug.
+to try indefinitely.
+By default, magick support is disabled.
.
.It Cm --max-dimension Ar width No x Ar height
.
@@ -488,15 +520,18 @@ If you only care about one parameter, set the other to 0.
.
.It Cm -m , --montage
.
-Enable montage mode. Montage mode creates a new image consisting of a grid of
-thumbnails of the images in the filelist. When montage mode is selected,
-certain other options become available. See
+Enable montage mode.
+Montage mode creates a new image consisting of a grid of thumbnails of the
+images in the filelist.
+When montage mode is selected, certain other options become available.
+See
.Sx MONTAGE MODE OPTIONS .
.
.It Cm -w , --multiwindow
.
-Disable slideshow mode. With this setting, instead of opening multiple files
-in slideshow mode, multiple windows will be opened; one per file.
+Disable slideshow mode.
+With this setting, instead of opening multiple files in slideshow mode,
+multiple windows will be opened; one per file.
.
.It Cm --no-jump-on-resort
.
@@ -508,10 +543,10 @@ Don't load or show any menus.
.
.It Cm --no-screen-clip
.
-By default, window sizes are limited to the screen size. With this option,
-windows will have the size of the image inside them. Note that they may
-become very large this way, making them unmanageable in certain window
-managers.
+By default, window sizes are limited to the screen size.
+With this option, windows will have the size of the image inside them.
+Note that they may become very large this way, making them unmanageable
+in certain window managers.
.
.It Cm --no-xinerama
.
@@ -527,23 +562,27 @@ By default, files are saved in the current working directory.
.
.It Cm -p , --preload
.
-Preload images. This doesn't mean hold them in RAM, it means run through
-them and eliminate unloadable images first. Otherwise they will be removed
-as you flick through. This also analyses the images to get data for use in
-sorting, such as pixel size, type etc. A preload run will be automatically
-performed if you specify one of these sort modes.
+Preload images.
+This doesn't mean hold them in RAM, it means run through them and eliminate
+unloadable images first.
+Otherwise they will be removed as you flick through.
+This also analyses the images to get data for use in sorting, such as pixel
+size, type etc.
+A preload run will be automatically performed if you specify one of these
+sort modes.
.
.It Cm -q , --quiet
.
-Don't report non-fatal errors for failed loads. Verbose and quiet modes are
-not mutually exclusive, the first controls informational messages, the second
-only errors.
+Don't report non-fatal errors for failed loads.
+Verbose and quiet modes are not mutually exclusive, the first controls
+informational messages, the second only errors.
.
.It Cm -z , --randomize
.
When viewing multiple files in a slideshow, randomize the file list before
-displaying. The list is re-randomized whenever the slideshow cycles (that is,
-transitions from last to first image).
+displaying.
+The list is re-randomized whenever the slideshow cycles (that is, transitions
+from last to first image).
.
.It Cm -r , --recursive
.
@@ -559,29 +598,32 @@ Useful to override theme options.
.
Reload filelist and current image after
.Ar int
-seconds. Useful for viewing HTTP webcams or frequently changing directories.
+seconds.
+Useful for viewing HTTP webcams or frequently changing directories.
.Pq Note that the filelist reloading is still experimental.
.
.Pp
.
If an image is removed,
.Nm
-will either show the next one or quit. However, if an image still exists, but
-can no longer be loaded,
+will either show the next one or quit.
+However, if an image still exists, but can no longer be loaded,
.Nm
will continue to try loading it.
.
.It Cm -n , --reverse
.
-Reverse the sort order. Use this to invert the order of the filelist.
+Reverse the sort order.
+Use this to invert the order of the filelist.
E.g. to sort in reverse width order, use
.Cm -nSwidth .
.
.It Cm -. , --scale-down
.
Scale images to fit window geometry (defaults to screen size when no geometry
-was specified). Note that the window geometry is not updated when changing
-images at the moment. This option is recommended for tiling window managers.
+was specified).
+Note that the window geometry is not updated when changing images at the moment.
+This option is recommended for tiling window managers.
.
This option is ignored when in fullscreen and thumbnail list mode.
.
@@ -604,7 +646,8 @@ Default: 20
.
For slideshow mode, wait
.Ar float
-seconds between automatically changing slides. Useful for presentations.
+seconds between automatically changing slides.
+Useful for presentations.
Specify a negative number to set the delay
.Pq which will then be Ar float No * (-1) ,
but start
@@ -613,15 +656,16 @@ in paused mode.
.
.It Cm -S , --sort Ar sort_type
.
-The file list may be sorted according to image parameters. Allowed sort types
-are: name, filename, dirname, mtime, width, height, pixels, size, format. For
-sort modes other than name, filename, dirname, or mtime, a preload run will be
-necessary, causing a delay proportional to the number of images in the list.
+The file list may be sorted according to image parameters.
+Allowed sort types are: name, filename, dirname, mtime, width, height, pixels,
+size, format.
+For sort modes other than name, filename, dirname, or mtime, a preload run will
+be necessary, causing a delay proportional to the number of images in the list.
.
.Pp
.
-The mtime sort mode sorts images by most recently modified. To sort by oldest
-first, reverse the filelist with --reverse.
+The mtime sort mode sorts images by most recently modified.
+To sort by oldest first, reverse the filelist with --reverse.
.
.It Cm -| , --start-at Ar filename
.
@@ -632,12 +676,14 @@ Note that at the moment,
.Ar filename
must match an
.Pq expanded
-path in the filelist. So, if the file to be matched is passed via an absolute
-path in the filelist,
+path in the filelist.
+So, if the file to be matched is passed via an absolute path in the filelist,
.Ar filename
-must be an absolute path. If the file is passed via a relative path,
+must be an absolute path.
+If the file is passed via a relative path,
.Ar filename
-must be an identical relative path. This is a known issue.
+must be an identical relative path.
+This is a known issue.
See also
.Sx USAGE EXAMPLES .
.
@@ -647,7 +693,8 @@ Load options from config file with name
.Ar theme
- see
.Sx THEMES CONFIG SYNTAX
-for more info. Note that commandline options always override theme options.
+for more info.
+Note that commandline options always override theme options.
The theme can also be set via the program name
.Pq e.g. with symlinks ,
so by default
@@ -663,8 +710,8 @@ Note that
.Cm --fullscreen
and
.Cm --scale-down
-do not affect the thumbnail window. They do, however, work for image windows
-launched from thumbnail mode.
+do not affect the thumbnail window.
+They do, however, work for image windows launched from thumbnail mode.
Also supports
.Sx INDEX AND THUMBNAIL MODE OPTIONS
as well as
@@ -674,19 +721,21 @@ as well as
.
Set
.Ar title
-for windows opened from thumbnail mode. See also
+for windows opened from thumbnail mode.
+See also
.Sx FORMAT SPECIFIERS .
.
.It Cm -^ , --title Ar title
.
-Set window title. Applies to all windows except those opened from thumbnail
-mode. See
+Set window title.
+Applies to all windows except those opened from thumbnail mode.
+See
.Sx FORMAT SPECIFIERS .
.
.It Cm -u , --unloadable
.
-Don't display images. Just print out their names if imlib2 can NOT
-successfully load them.
+Don't display images.
+Just print out their names if imlib2 can NOT successfully load them.
Returns false if at least one image was loadable.
.
.It Cm -V , --verbose
@@ -700,8 +749,8 @@ output version information and exit.
.It Cm --version-sort
.
.Pq optional feature, $MAN_VERSCMP$ in this build
-Use natural sorting for file and directory names. In this mode, filenames are
-sorted as an ordinary human would expect, e.g.
+Use natural sorting for file and directory names.
+In this mode, filenames are sorted as an ordinary human would expect, e.g.
.Qq 2.jpg
comes before
.Qq 10.jpg .
@@ -711,8 +760,9 @@ comes before
.Pq optional feature, $MAN_XINERAMA$ in this build
Override
.Nm Ns No 's
-idea of the active Xinerama screen. May be useful in certain circumstances
-where the window manager places the feh window on Xinerama screen A while
+idea of the active Xinerama screen.
+May be useful in certain circumstances where the window manager places the feh
+window on Xinerama screen A while
.Nm
assumes that it will be placed on screen B.
.
@@ -724,18 +774,20 @@ Only set wallpaper on
.Ar screen .
All other screens will be filled black/white.
.
-This is most useful in a Xinerama configuration with
-overlapping screens. For instance, assume you have two overlapping displays
-(index 0 and 1), where index 0 is smaller. To center a background on the
-display with index 0 and fill the extra space on index 1 black/white, use
+This is most useful in a Xinerama configuration with overlapping screens.
+For instance, assume you have two overlapping displays (index 0 and 1),
+where index 0 is smaller.
+To center a background on the display with index 0 and fill the extra space
+on index 1 black/white, use
.Qq --xinerama-index 0
when setting the wallpaper.
.
-.It Cm --zoom Ar percent No | Cm max No | Cm fill
+.It Cm --zoom Ar percent | Cm max | Cm fill
.
Zoom images by
.Ar percent
-when in full screen mode or when window geometry is fixed. When combined with
+when in full screen mode or when window geometry is fixed.
+When combined with
.Cm --auto-zoom ,
zooming will be limited to the specified
.Ar percent .
@@ -768,14 +820,15 @@ When drawing thumbnails onto the background, set their transparency level to
.Ar int
.Pq 0 - 255 .
.
-.It Cm -b , --bg Ar file No | Cm trans
+.It Cm -b , --bg Ar file | Cm trans
.
Use
.Ar file
-as background for your montage. With this option specified, the montage size
-will default to the size of
+as background for your montage.
+With this option specified, the montage size will default to the size of
.Ar file
-if no size restrictions were specified. Alternatively, if
+if no size restrictions were specified.
+Alternatively, if
.Ar file
is
.Qq trans ,
@@ -784,8 +837,8 @@ the background will be made transparent.
.It Cm -X , --ignore-aspect
.
By default, the montage thumbnails will retain their aspect ratios, while
-fitting into thumb-width/-height. This options forces them to be the size set
-by
+fitting into thumb-width/-height.
+This options forces them to be the size set by
.Cm --thumb-width No and Cm --thumb-height .
This will prevent any empty space in the final montage.
.
@@ -819,8 +872,9 @@ without displaying it.
.It Cm -s , --stretch
.
Normally, if an image is smaller than the specified thumbnail size, it will
-not be enlarged. If this option is set, the image will be scaled up to fit
-the thumbnail size. Aspect ratio will be maintained unless
+not be enlarged.
+If this option is set, the image will be scaled up to fit the thumbnail size.
+Aspect ratio will be maintained unless
.Cm --ignore-aspect
is specified.
.
@@ -849,7 +903,8 @@ the following options can be used.
.
Show image information based on
.Ar format
-below thumbnails in index / thumbnail mode. See
+below thumbnails in index / thumbnail mode.
+See
.Sx FORMAT SPECIFIERS .
May contain newlines.
.
@@ -865,7 +920,8 @@ Note: If you specify image-related formats
needs to load all images to calculate the dimensions of its own window.
So when using them with many files, it will take a while before a
.Nm
-window becomes visible. Use
+window becomes visible.
+Use
.Cm --preload
to get a progress bar.
.
@@ -878,15 +934,16 @@ be printed.
.
Redraw thumbnail window every
.Ar n
-images. In
+images.
+In
.Nm
<= 1.5, the thumbnail image used to be redrawn after every computed thumbnail
.Pq so, it updated immediately .
However, since the redrawing takes quite long
.Pq especially for thumbnail mode on a large filelist ,
this turned out to be a major performance penalty.
-As a workaround, the thumbnail image is redrawn every 10th image now by
-default. Set
+As a workaround, the thumbnail image is redrawn every 10th image now by default.
+Set
.Ar n No = 1
to get the old behaviour,
.Ar n No = 0
@@ -899,26 +956,22 @@ will only redraw once all thumbnails are loaded.
.
In many desktop environments,
.Nm
-can also be used as a background setter. Unless you pass the
+can also be used as a background setter.
+Unless you pass the
.Cm --no-fehbg
option, it will write a script to set the current background to
.Pa ~/.fehbg .
So to have your background restored every time you start X, you can add
-.Qq sh ~/.fehbg &
+.Qq ~/.fehbg &
to your X startup script
.Pq such as Pa ~/.xinitrc .
-As of
-.Nm
-2.13, this script is executable, so
-.Qq ~/.fehbg &
-will work as well.
.
.Pp
.
Note that
.Nm
-does not support setting the wallpaper of GNOME shell desktops. In this
-environment, you can use
+does not support setting the wallpaper of GNOME shell desktops.
+In this environment, you can use
.Qq gsettings set org.gnome.desktop.background picture-uri file:/// Ns Ar path
instead.
.
@@ -930,10 +983,10 @@ and
.Cm --bg-max ,
you can use
.Cm --geometry
-to specify an offset from one side of the screen instead of
-centering the image. Positive values will offset from the left/top
-side, negative values from the bottom/right. +0 and -0 are both
-valid and distinct values.
+to specify an offset from one side of the screen instead of centering the image.
+Positive values will offset from the left/top side, negative values from the
+bottom/right.
++0 and -0 are both valid and distinct values.
.
.Pp
.
@@ -951,8 +1004,8 @@ on screen 0, the second on screen 1, and so on.
.
Use
.Cm --no-xinerama
-to treat the whole X display as one screen when setting wallpapers. You
-may also use
+to treat the whole X display as one screen when setting wallpapers.
+You may also use
.Cm --xinerama-index
to use
.Nm
@@ -962,16 +1015,16 @@ as a background setter for a specific screen.
.
.It Cm --bg-center
.
-Center the file on the background. If it is too small, it will be surrounded
-by a border as specified by
+Center the file on the background.
+If it is too small, it will be surrounded by a border as specified by
.Cm --image-bg .
.
.It Cm --bg-fill
.
Like
.Cm --bg-scale ,
-but preserves aspect ratio by zooming the image until it fits. Either a
-horizontal or a vertical part of the image will be cut off
+but preserves aspect ratio by zooming the image until it fits.
+Either a horizontal or a vertical part of the image will be cut off
.
.It Cm --bg-max
.
@@ -984,7 +1037,8 @@ The border color can be set using
.It Cm --bg-scale
.
Fit the file into the background without repeating it, cutting off stuff or
-using borders. But the aspect ratio is not preserved either
+using borders.
+But the aspect ratio is not preserved either
.
.It Cm --bg-tile
.
@@ -1014,6 +1068,10 @@ Image path/filename
Escaped image path/filename
.Pq for use in shell commands
.
+.It %g
+.
+w,h window dimensions in pixels (mnemonic: geometry)
+.
.It %h
.
Image height
@@ -1024,7 +1082,8 @@ Total number of files in filelist
.
.It %L
.
-Temporary copy of filelist. Multiple uses of %L within the same format string will return the same copy.
+Temporary copy of filelist.
+Multiple uses of %L within the same format string will return the same copy.
.
.It %m
.
@@ -1048,12 +1107,14 @@ Number of image pixels
.
.It \&%P
.
-Number of image pixels
+Number of image pixels in human-readable format with k/M
.Pq kilopixels / megapixels
+suffix
.
.It %r
.
-Image rotation. A half right turn equals pi.
+Image rotation.
+A half right turn equals pi.
.
.It %s
.
@@ -1087,7 +1148,11 @@ Process ID
.
.It %z
.
-current image zoom
+Current image zoom, rounded to two decimal places
+.
+.It %Z
+.
+Current image zoom, higher precision
.
.It %%
.
@@ -1140,8 +1205,9 @@ are the options which will be applied when the theme is used.
.
Note that the option parser does not behave like a normal shell: filename
expansion and backslash escape sequences are not supported and passed to
-feh's option parser as-is. However, quoting of arguments is respected
-and can be used for arguments with whitespace.
+feh's option parser as-is.
+However, quoting of arguments is respected and can be used for arguments
+with whitespace.
.
So, the sequence
.Qq --info Qq foo bar
@@ -1161,15 +1227,16 @@ An example entry is
.
.Pp
.
-You can use this theme in two ways. Either call
+You can use this theme in two ways.
+Either call
.Qo
.Nm
-Timagemap *.jpg
.Qc ,
or create a symbolic link to
.Nm
-with the name of the theme you want it to use. For the example above,
-this would be
+with the name of the theme you want it to use.
+For the example above, this would be
.Qo
ln -s `which
.Nm
@@ -1236,9 +1303,9 @@ without any keys unbinds it (i.e. the default bindings are removed).
.
.Pp
.
-.Em Note :
-Do not use the same keybinding for multiple actions. When binding an action
-to a new key
+.Em Note:\&
+Do not use the same keybinding for multiple actions.
+When binding an action to a new key
.Pq or mouse button ,
make sure to unbind it from its previous action, if present.
.Nm
@@ -1268,10 +1335,14 @@ The following actions and default key bindings can be used in an image window.
If
.Nm
is running inside a terminal and its standard input is not used for images or
-filelists, key input from the terminal is also accepted. However, terminal
-input support is currently limited to most alphanumeric characters
+filelists, key input from the terminal is also accepted.
+However, terminal input support is currently limited to most alphanumeric
+characters
.Pq 0-9 a-z A-Z and some more ,
-return and backspace.
+arrow keys, return and backspace.
+The Alt
+.Pq Mod1
+modifier is also supported.
.
.Bl -tag -width indent
.
@@ -1286,12 +1357,13 @@ Enable/Disable anti-aliasing
.
.It c Bq toggle_caption
.
-Caption entry mode. If
+Caption entry mode.
+If
.Cm --caption-path
-has been specified, then this enables caption editing. The caption at the
-bottom of the screen will turn yellow and can be edited. Hit return to confirm
-and save the caption, or escape to cancel editing. Note that you can insert
-an actual newline into the caption using
+has been specified, then this enables caption editing.
+The caption at the bottom of the screen will turn yellow and can be edited.
+Hit return to confirm and save the caption, or escape to cancel editing.
+Note that you can insert an actual newline into the caption using
.Aq Ctrl+return .
.
.It d Bq toggle_filenames
@@ -1315,8 +1387,8 @@ Enable/Disable automatic window resize when changing images.
.
.It h Bq toggle_pause
.
-Pause/Continue the slideshow. When it is paused, it will not automatically
-change slides based on
+Pause/Continue the slideshow.
+When it is paused, it will not automatically change slides based on
.Cm --slideshow-delay .
.
.It i Bq toggle_info
@@ -1326,19 +1398,22 @@ Toggle info display
.
.It k Bq toggle_keep_vp
.
-Toggle zoom and viewport keeping. When enabled,
+Toggle zoom and viewport keeping.
+When enabled,
.Nm
will keep zoom and X, Y offset when switching images.
.
.It m Bq toggle_menu
.
-Show menu. Use the arrow keys and return to select items,
+Show menu.
+Use the arrow keys and return to select items,
.Aq escape
to close the menu.
.
.It n , Ao space Ac , Ao Right Ac Bq next_img
.
-Show next image. Selects the next image in thumbnail mode.
+Show next image.
+Selects the next image in thumbnail mode.
.
.It o Bq toggle_pointer
.
@@ -1346,7 +1421,8 @@ Toggle pointer visibility
.
.It p , Ao BackSpace Ac , Ao Left Ac Bq prev_img
.
-Show previous image. Selects the previous image in thumbnail mode.
+Show previous image.
+Selects the previous image in thumbnail mode.
.
.It q , Ao Escape Ac Bq quit
.
@@ -1355,7 +1431,8 @@ Quit
.
.It r Bq reload_image
.
-Reload current image. Useful for webcams
+Reload current image.
+Useful for webcams
.
.It s Bq save_image
.
@@ -1370,8 +1447,7 @@ Toggle fullscreen
.
Change window size to fit current image size
.Pq plus/minus zoom, if set .
-In scale-down and fixed-geometry mode, this also updates the window size
-limits.
+In scale-down and fixed-geometry mode, this also updates the window size limits.
.
.It x Bq close
.
@@ -1388,24 +1464,28 @@ Toggle auto-zoom.
.It \&[, \&] Bq prev_dir, next_dir
.
Jump to the first image of the previous or next sequence of images sharing
-a directory name in the current filelist. Use --sort dirname if you would
-like to ensure that all images in a directory are grouped together.
+a directory name in the current filelist.
+Use --sort dirname if you would like to ensure that all images in a directory
+are grouped together.
.
.It < , > Bq orient_3 , orient_1
.
In place editing - rotate the image 90 degrees (counter)clockwise.
The rotation is lossless, but may create artifacts in some image corners when
-used with JPEG images. Rotating in the reverse direction will make them go
-away. See
+used with JPEG images.
+Rotating in the reverse direction will make them go away.
+See
.Xr jpegtran 1
for more about lossless JPEG rotation.
.
-.Em Note:
+.Em Note:\&
.Nm
-assumes that this feature is used to normalize image orientation. For JPEG
-images, it will unconditionally set the EXIF orientation tag to 1
+assumes that this feature is used to normalize image orientation.
+For JPEG images, it will unconditionally set the EXIF orientation
+tag to 1
.Pq Qq 0,0 is top left
-after every rotation. See
+after every rotation.
+See
.Xr jpegexiforient 1
for details on how to change this flag.
.
@@ -1566,8 +1646,8 @@ This works like the keys config file: the entries are of the form
.
Each
.Ar binding
-is a button number. It may optionally start with modifiers for things like
-Control, in which case
+is a button number.
+It may optionally start with modifiers for things like Control, in which case
.Ar binding
looks like
.Ar mod Ns No - Ns Ar button
@@ -1575,7 +1655,7 @@ looks like
.
.Pp
.
-.Em Note :
+.Em Note:\&
Do not use the same button for multiple actions.
.Nm
does not check for conflicting bindings, so their behaviour is undefined.
@@ -1677,11 +1757,12 @@ will warp your cursor to the opposite border so you can continue panning.
.Pp
.
When clicking the zoom button and immediately releasing it, the image will be
-back at 100% zoom. When clicking it and moving the mouse while holding the
-button down, the zoom will be continued at the previous zoom level. The zoom
-will always happen so that the pixel on which you entered the zoom mode
-remains stationary. So, to enlarge a specific part of an image, click the
-zoom button on that part.
+back at 100% zoom.
+When clicking it and moving the mouse while holding the button down, the zoom
+will be continued at the previous zoom level.
+The zoom will always happen so that the pixel on which you entered the zoom mode
+remains stationary.
+So, to enlarge a specific part of an image, click the zoom button on that part.
.
.
.Sh SIGNALS
@@ -1705,7 +1786,8 @@ Switch to previous image
.
.Sh USAGE EXAMPLES
.
-Here are some examples of useful option combinations. See also:
+Here are some examples of useful option combinations.
+See also:
.Aq http://feh.finalrewind.org/examples/
.
.Bl -tag -width indent
@@ -1720,8 +1802,8 @@ Recursively show all images found in ~/Pictures and subdirectories
.
.It feh -rSfilename --version-sort ~/Pictures
.
-Same as above, but sort naturally. By default, feh will show files in the
-string order of their names, meaning e.g.
+Same as above, but sort naturally.
+By default, feh will show files in the string order of their names, meaning e.g.
.Qq foo 10.jpg
will come before
.Qq foo 2.jpg .
@@ -1733,15 +1815,14 @@ Show 128x128 pixel thumbnails, limit window width to 1024 pixels.
.
.It feh -t -Sfilename -E 128 -y 128 -W 1024 -P -C /usr/share/fonts/truetype/ttf-dejavu/ -e DejaVuSans/8 ~/Pictures
.
-Same as above, but enable thumbnail caching in ~/.thumbnails and use a smaller
-font.
+Same as above, but enable thumbnail caching and use a smaller font.
.
.It feh -irFarial/14 -O index.jpg ~/Pictures
.
Make an index print of ~/Pictures and all directories below it, using 14 point
-Arial to write the image info under each thumbnail. Save the image as
-index.jpg and don't display it, just exit. Note that this even works without
-a running X server
+Arial to write the image info under each thumbnail.
+Save the image as index.jpg and don't display it, just exit.
+Note that this even works without a running X server
.
.It feh --unloadable -r ~/Pictures
.
@@ -1768,8 +1849,8 @@ View all images in ~/Pictures and below, sorted by width, move an image to
.
.It feh --start-at ./foo.jpg \&.
.
-View all images in the current directory, starting with foo.jpg. All other
-images are still in the slideshow and can be viewed normally
+View all images in the current directory, starting with foo.jpg.
+All other images are still in the slideshow and can be viewed normally
.
.It feh --start-at foo.jpg *
.
@@ -1802,24 +1883,25 @@ for lossless rotation.
.
To view images from URLs such as http://, you need
.Nm
-compiled with libcurl support (enabled by default). See the
+compiled with libcurl support (enabled by default).
+See the
.Sx VERSION
section.
.
.
.Sh BUGS
.
-.Pp
-.
On systems with giflib 5.1.2,
.Nm
-may be unable to load gif images. For affected mips, mipsel and arm devices,
-gif support is completely broken, while on x86 / x86_64 gifs can usually
-only be loaded if they are the first image in the filelist.
+may be unable to load gif images.
+For affected mips, mipsel and arm devices, gif support is completely
+broken, while on x86 / x86_64 gifs can usually only be loaded if they are
+the first image in the filelist.
This appears to be a bug in giflib,
see
.Aq https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=813729
-for details. Workaround: Use
+for details.
+Workaround: Use
.Cm --magick-timeout 5
.Pq or some other positive value
to load gifs with imagemagick instead, or downgrade to giflib 5.1.1, or
@@ -1836,15 +1918,6 @@ as it could be.
does not take window decorations into account and may therefore make the
window slightly too large.
.
-.Pp
-.
-When enabled,
-.Cm --magick-timeout
-may clutter
-.Pa /tmp
-with temporary files produced by ImageMagick. This happens whenever an image
-is not loaded due to the conversion taking longer than the specified timeout.
-.
.Ss REPORTING BUGS
.
If you find a bug, please report it to
@@ -1877,7 +1950,7 @@ Make zoom options more intuitive
.
Copyright (C) 1999, 2000 by Paul Duncan.
Copyright (C) 1999, 2000 by Tom Gilbert (and various contributors).
-Copyright (C) 2010-2016 by Daniel Friesel (and even more contributors).
+Copyright (C) 2010-2018 by Daniel Friesel (and even more contributors).
.
.Pp
.
@@ -1899,10 +1972,11 @@ used.
.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
-THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
-IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
-CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
.
.Pp
.
diff --git a/src/collage.c b/src/collage.c
index 431d3b6..2a4d9f9 100644
--- a/src/collage.c
+++ b/src/collage.c
@@ -1,7 +1,7 @@
/* collage.c
Copyright (C) 1999-2003 Tom Gilbert.
-Copyright (C) 2010-2011 Daniel Friesel.
+Copyright (C) 2010-2018 Daniel Friesel.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to
diff --git a/src/debug.h b/src/debug.h
index eb929e3..38cf83f 100644
--- a/src/debug.h
+++ b/src/debug.h
@@ -1,7 +1,7 @@
/* debug.h
Copyright (C) 1999-2003 Tom Gilbert.
-Copyright (C) 2010-2011 Daniel Friesel.
+Copyright (C) 2010-2018 Daniel Friesel.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to
diff --git a/src/events.c b/src/events.c
index 947e69f..89eaab8 100644
--- a/src/events.c
+++ b/src/events.c
@@ -1,7 +1,7 @@
/* events.c
Copyright (C) 1999-2003 Tom Gilbert.
-Copyright (C) 2010-2011 Daniel Friesel.
+Copyright (C) 2010-2018 Daniel Friesel.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to
@@ -509,6 +509,8 @@ static void feh_event_handle_MotionNotify(XEvent * ev)
dy = scr_height - (m->y + m->h);
dx = dx < 0 ? dx : 0;
dy = dy < 0 ? dy : 0;
+ dx = m->x + dx < 0 ? -m->x : dx;
+ dy = m->y + dy < 0 ? -m->y : dy;
if (dx || dy)
feh_menu_slide_all_menus_relative(dx, dy);
}
@@ -521,6 +523,8 @@ static void feh_event_handle_MotionNotify(XEvent * ev)
dy = scr->height - (m->next->y + m->next->h);
dx = dx < 0 ? dx : 0;
dy = dy < 0 ? dy : 0;
+ dx = m->x + dx < 0 ? -m->x : dx;
+ dy = m->y + dy < 0 ? -m->y : dy;
if (dx || dy)
feh_menu_slide_all_menus_relative(dx, dy);
}
diff --git a/src/feh.h b/src/feh.h
index 3e0cdda..009f45b 100644
--- a/src/feh.h
+++ b/src/feh.h
@@ -1,7 +1,7 @@
/* feh.h
Copyright (C) 1999-2003 Tom Gilbert.
-Copyright (C) 2010-2011 Daniel Friesel.
+Copyright (C) 2010-2018 Daniel Friesel.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to
diff --git a/src/filelist.c b/src/filelist.c
index 453f795..eb8e294 100644
--- a/src/filelist.c
+++ b/src/filelist.c
@@ -1,7 +1,7 @@
/* filelist.c
Copyright (C) 1999-2003 Tom Gilbert.
-Copyright (C) 2010-2011 Daniel Friesel.
+Copyright (C) 2010-2018 Daniel Friesel.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to
@@ -398,7 +398,7 @@ void feh_file_dirname(char *dst, feh_file * f, int maxlen)
}
#ifdef HAVE_VERSCMP
-inline int strcmp_or_strverscmp(const char *s1, const char *s2)
+static inline int strcmp_or_strverscmp(const char *s1, const char *s2)
{
if (!opt.version_sort)
return(strcmp(s1, s2));
diff --git a/src/gib_list.c b/src/gib_list.c
index 281f528..5384d98 100644
--- a/src/gib_list.c
+++ b/src/gib_list.c
@@ -360,7 +360,6 @@ gib_list_randomize(gib_list * list)
{
farray[i] = f;
}
- srand(getpid() * time(NULL) % ((unsigned int) -1));
for (i = 0; i < len - 1; i++)
{
r = i + rand() / (RAND_MAX / (len - i) + 1 );
diff --git a/src/imlib.c b/src/imlib.c
index b6041fc..2d1b47a 100644
--- a/src/imlib.c
+++ b/src/imlib.c
@@ -1,7 +1,7 @@
/* imlib.c
Copyright (C) 1999-2003 Tom Gilbert.
-Copyright (C) 2010-2011 Daniel Friesel.
+Copyright (C) 2010-2018 Daniel Friesel.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to
@@ -135,9 +135,6 @@ void init_x_and_imlib(void)
imlib_set_cache_size(opt.cache_size * 1024 * 1024);
- /* Initialise random numbers */
- srand(getpid() * time(NULL) % ((unsigned int) -1));
-
return;
}
@@ -404,8 +401,10 @@ static char *feh_magick_load_image(char *filename)
char *basename;
char *tmpname;
char *sfn;
+ char tempdir[] = "/tmp/.feh-magick-tmp-XXXXXX";
int fd = -1, devnull = -1;
int status;
+ char created_tempdir = 0;
basename = strrchr(filename, '/');
@@ -436,6 +435,22 @@ static char *feh_magick_load_image(char *filename)
*/
argv_fn = estrjoin(":", "png", sfn, NULL);
+ /*
+ * By default, ImageMagick saves (occasionally lots of) temporary files
+ * in /tmp. It doesn't remove them if it runs into a timeout and is killed
+ * by us, no matter whether we use SIGINT, SIGTERM or SIGKILL. So, unless
+ * MAGICK_TMPDIR has already been set by the user, we create our own
+ * temporary directory for ImageMagick and remove its contents at the end of
+ * this function.
+ */
+ if (getenv("MAGICK_TMPDIR") == NULL) {
+ if (mkdtemp(tempdir) == NULL) {
+ weprintf("%s: ImageMagick may leave temporary files in /tmp. mkdtemp failed:", filename);
+ } else {
+ created_tempdir = 1;
+ }
+ }
+
if ((childpid = fork()) < 0) {
weprintf("%s: Can't load with imagemagick. Fork failed:", filename);
unlink(sfn);
@@ -457,6 +472,11 @@ static char *feh_magick_load_image(char *filename)
*/
setpgid(0, 0);
+ if (created_tempdir) {
+ // no error checking - this is a best-effort code path
+ setenv("MAGICK_TMPDIR", tempdir, 0);
+ }
+
execlp("convert", "convert", filename, argv_fn, NULL);
_exit(1);
}
@@ -470,13 +490,39 @@ static char *feh_magick_load_image(char *filename)
sfn = NULL;
if (!opt.quiet) {
- weprintf("%s - Conversion took too long, skipping", filename);
+ weprintf("%s: Conversion took too long, skipping", filename);
}
}
close(fd);
childpid = 0;
}
+ if (created_tempdir) {
+ DIR *dir;
+ struct dirent *de;
+ if ((dir = opendir(tempdir)) == NULL) {
+ weprintf("%s: Cannot remove temporary ImageMagick files from %s:", filename, tempdir);
+ } else {
+ while ((de = readdir(dir)) != NULL) {
+ if (de->d_name[0] != '.') {
+ char *temporary_file_name = estrjoin("/", tempdir, de->d_name, NULL);
+ /*
+ * We assume that ImageMagick only creates temporary files and
+ * not directories.
+ */
+ if (unlink(temporary_file_name) == -1) {
+ weprintf("unlink %s:", temporary_file_name);
+ }
+ free(temporary_file_name);
+ }
+ }
+ if (rmdir(tempdir) == -1) {
+ weprintf("rmdir %s:", tempdir);
+ }
+ }
+ closedir(dir);
+ }
+
free(argv_fn);
return sfn;
}
diff --git a/src/index.c b/src/index.c
index c8c34c5..af3adea 100644
--- a/src/index.c
+++ b/src/index.c
@@ -1,7 +1,7 @@
/* index.c
Copyright (C) 1999-2003 Tom Gilbert.
-Copyright (C) 2010-2011 Daniel Friesel.
+Copyright (C) 2010-2018 Daniel Friesel.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to
@@ -147,9 +147,16 @@ void init_index_mode(void)
index_image_height = h + title_area_h;
im_main = imlib_create_image(index_image_width, index_image_height);
- if (!im_main)
- eprintf("Failed to create %dx%d pixels (%d MB) index image. Do you have enough RAM?",
- index_image_width, index_image_height, index_image_width * index_image_height * 4 / (1024*1024));
+ if (!im_main) {
+ if (index_image_height >= 32768 || index_image_width >= 32768) {
+ eprintf("Failed to create %dx%d pixels (%d MB) index image.\n"
+ "This is probably due to Imlib2 issues when dealing with images larger than 32k x 32k pixels.",
+ index_image_width, index_image_height, index_image_width * index_image_height * 4 / (1024*1024));
+ } else {
+ eprintf("Failed to create %dx%d pixels (%d MB) index image. Do you have enough RAM?",
+ index_image_width, index_image_height, index_image_width * index_image_height * 4 / (1024*1024));
+ }
+ }
if (bg_im)
gib_imlib_blend_image_onto_image(im_main, bg_im,
diff --git a/src/index.h b/src/index.h
index 08ab337..b022f1a 100644
--- a/src/index.h
+++ b/src/index.h
@@ -1,6 +1,6 @@
/* index.h
-Copyright (C) 2011 Daniel Friesel.
+Copyright (C) 2018 Daniel Friesel.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to
diff --git a/src/keyevents.c b/src/keyevents.c
index 793767b..689aebd 100644
--- a/src/keyevents.c
+++ b/src/keyevents.c
@@ -1,7 +1,7 @@
/* keyevents.c
Copyright (C) 1999-2003 Tom Gilbert.
-Copyright (C) 2010-2011 Daniel Friesel.
+Copyright (C) 2010-2018 Daniel Friesel.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to
@@ -317,6 +317,7 @@ void feh_event_invoke_action(winwidget winwid, unsigned char action)
void feh_event_handle_stdin()
{
char stdin_buf[2];
+ static char is_esc = 0;
KeySym keysym = NoSymbol;
if (read(STDIN_FILENO, &stdin_buf, 1) == -1) {
control_via_stdin = 0;
@@ -328,17 +329,40 @@ void feh_event_handle_stdin()
}
stdin_buf[1] = '\0';
+ // escape?
+ if (stdin_buf[0] == 0x1b) {
+ is_esc = 1;
+ return;
+ }
+ if ((is_esc == 1) && (stdin_buf[0] == '[')) {
+ is_esc = 2;
+ return;
+ }
+
if (stdin_buf[0] == ' ')
keysym = XK_space;
else if (stdin_buf[0] == '\n')
keysym = XK_Return;
else if ((stdin_buf[0] == '\b') || (stdin_buf[0] == 127))
keysym = XK_BackSpace;
+ else if (is_esc == 2) {
+ if (stdin_buf[0] == 'A')
+ keysym = XK_Up;
+ else if (stdin_buf[0] == 'B')
+ keysym = XK_Down;
+ else if (stdin_buf[0] == 'C')
+ keysym = XK_Right;
+ else if (stdin_buf[0] == 'D')
+ keysym = XK_Left;
+ is_esc = 0;
+ }
else
keysym = XStringToKeysym(stdin_buf);
if (window_num)
- feh_event_handle_generic(windows[0], 0, keysym, 0);
+ feh_event_handle_generic(windows[0], is_esc * Mod1Mask, keysym, 0);
+
+ is_esc = 0;
}
void feh_event_handle_keypress(XEvent * ev)
@@ -774,6 +798,7 @@ void feh_event_handle_generic(winwidget winwid, unsigned int state, KeySym keysy
opt.geom_w = winwid->w;
opt.geom_h = winwid->h;
}
+ winwidget_render_image(winwid, 1, 0);
}
return;
}
diff --git a/src/list.c b/src/list.c
index 09b23f4..2f6cf76 100644
--- a/src/list.c
+++ b/src/list.c
@@ -1,7 +1,7 @@
/* list.c
Copyright (C) 1999-2003 Tom Gilbert.
-Copyright (C) 2010-2011 Daniel Friesel.
+Copyright (C) 2010-2018 Daniel Friesel.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to
diff --git a/src/main.c b/src/main.c
index 840919f..1a76e2d 100644
--- a/src/main.c
+++ b/src/main.c
@@ -1,7 +1,7 @@
/* main.c
Copyright (C) 1999-2003 Tom Gilbert.
-Copyright (C) 2010-2011 Daniel Friesel.
+Copyright (C) 2010-2018 Daniel Friesel.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to
@@ -42,6 +42,8 @@ int main(int argc, char **argv)
{
atexit(feh_clean_exit);
+ srand(getpid() * time(NULL) % ((unsigned int) -1));
+
setup_signal_handlers();
init_parse_options(argc, argv);
@@ -85,7 +87,7 @@ int main(int argc, char **argv)
/* main event loop */
while (feh_main_iteration(1));
- return(0);
+ return(sig_exit);
}
/* Return 0 to stop iterating, 1 if ok to continue. */
@@ -102,7 +104,7 @@ int feh_main_iteration(int block)
double t1 = 0.0, t2 = 0.0;
fehtimer ft;
- if (window_num == 0)
+ if (window_num == 0 || sig_exit != 0)
return(0);
if (first) {
@@ -135,7 +137,7 @@ int feh_main_iteration(int block)
if (ev_handler[ev.type])
(*(ev_handler[ev.type])) (&ev);
- if (window_num == 0)
+ if (window_num == 0 || sig_exit != 0)
return(0);
}
XFlush(disp);
@@ -189,7 +191,7 @@ int feh_main_iteration(int block)
in that */
feh_handle_timer();
}
- else if (count && (FD_ISSET(0, &fdset)))
+ else if ((count > 0) && (FD_ISSET(0, &fdset)))
feh_event_handle_stdin();
}
} else {
@@ -202,11 +204,11 @@ int feh_main_iteration(int block)
&& ((errno == ENOMEM) || (errno == EINVAL)
|| (errno == EBADF)))
eprintf("Connection to X display lost");
- else if (count && (FD_ISSET(0, &fdset)))
+ else if ((count > 0) && (FD_ISSET(0, &fdset)))
feh_event_handle_stdin();
}
}
- if (window_num == 0)
+ if (window_num == 0 || sig_exit != 0)
return(0);
return(1);
diff --git a/src/menu.c b/src/menu.c
index ddb2db1..2f8875d 100644
--- a/src/menu.c
+++ b/src/menu.c
@@ -1,7 +1,7 @@
/* menu.c
Copyright (C) 1999-2003 Tom Gilbert.
-Copyright (C) 2010-2011 Daniel Friesel.
+Copyright (C) 2010-2018 Daniel Friesel.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to
diff --git a/src/menu.h b/src/menu.h
index 403728f..b53b32f 100644
--- a/src/menu.h
+++ b/src/menu.h
@@ -1,7 +1,7 @@
/* menu.h
Copyright (C) 1999-2003 Tom Gilbert.
-Copyright (C) 2010-2011 Daniel Friesel.
+Copyright (C) 2010-2018 Daniel Friesel.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to
diff --git a/src/options.c b/src/options.c
index 29ce836..b0d67cd 100644
--- a/src/options.c
+++ b/src/options.c
@@ -1,7 +1,7 @@
/* options.c
Copyright (C) 1999-2003 Tom Gilbert.
-Copyright (C) 2010-2011 Daniel Friesel.
+Copyright (C) 2010-2018 Daniel Friesel.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to
@@ -418,6 +418,7 @@ static void feh_parse_option_array(int argc, char **argv, int finalrun)
{"cache-size" , 1, 0, 243},
{"dcraw-timeout" , 1, 0, 245},
{"version-sort" , 0, 0, 246},
+ {"offset" , 1, 0, 247},
{0, 0, 0, 0}
};
int optch = 0, cmdx = 0;
@@ -593,6 +594,7 @@ static void feh_parse_option_array(int argc, char **argv, int finalrun)
opt.filelistfile = estrdup(optarg);
break;
case 'g':
+ opt.geom_enabled = 1;
opt.geom_flags = XParseGeometry(optarg, &opt.geom_x,
&opt.geom_y, &opt.geom_w, &opt.geom_h);
break;
@@ -789,6 +791,10 @@ static void feh_parse_option_array(int argc, char **argv, int finalrun)
case 246:
opt.version_sort = 1;
break;
+ case 247:
+ opt.offset_flags = XParseGeometry(optarg, &opt.offset_x,
+ &opt.offset_y, (unsigned int *)&discard, (unsigned int *)&discard);
+ break;
default:
break;
}
diff --git a/src/options.h b/src/options.h
index 88121e6..741b0c7 100644
--- a/src/options.h
+++ b/src/options.h
@@ -1,7 +1,7 @@
/* options.h
Copyright (C) 1999-2003 Tom Gilbert.
-Copyright (C) 2010-2011 Daniel Friesel.
+Copyright (C) 2010-2018 Daniel Friesel.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to
@@ -106,11 +106,15 @@ struct __fehoptions {
int sort;
int version_sort;
int debug;
+ int geom_enabled;
int geom_flags;
int geom_x;
int geom_y;
unsigned int geom_w;
unsigned int geom_h;
+ int offset_flags;
+ int offset_x;
+ int offset_y;
int default_zoom;
int zoom_mode;
unsigned char adjust_reload;
diff --git a/src/signals.c b/src/signals.c
index 8a3a8f7..aeaf889 100644
--- a/src/signals.c
+++ b/src/signals.c
@@ -1,6 +1,6 @@
/* signals.c
-Copyright (C) 2010 by Daniel Friesel
+Copyright (C) 2010-2018 by Daniel Friesel
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to
@@ -28,6 +28,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include "options.h"
void feh_handle_signal(int);
+int sig_exit = 0;
void setup_signal_handlers()
{
@@ -86,7 +87,8 @@ void feh_handle_signal(int signo)
case SIGQUIT:
if (childpid)
killpg(childpid, SIGINT);
- exit(128 + signo);
+ sig_exit = 128 + signo;
+ return;
}
winwid = winwidget_get_first_window_of_type(WIN_TYPE_SLIDESHOW);
diff --git a/src/signals.h b/src/signals.h
index 526285d..090ab0b 100644
--- a/src/signals.h
+++ b/src/signals.h
@@ -27,5 +27,5 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#define SIGNALS_H
void setup_signal_handlers();
-
+extern int sig_exit;
#endif
diff --git a/src/slideshow.c b/src/slideshow.c
index effdcaf..b27a7e8 100644
--- a/src/slideshow.c
+++ b/src/slideshow.c
@@ -1,7 +1,7 @@
/* slideshow.c
Copyright (C) 1999-2003 Tom Gilbert.
-Copyright (C) 2010-2011 Daniel Friesel.
+Copyright (C) 2010-2018 Daniel Friesel.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to
@@ -143,16 +143,6 @@ void feh_reload_image(winwidget w, int resize, int force_new)
Imlib_Image tmp;
int old_w, old_h;
- unsigned char tmode =0;
- int tim_x =0;
- int tim_y =0;
- double tzoom =0;
-
- tmode = w->mode;
- tim_x = w->im_x;
- tim_y = w->im_y;
- tzoom = w->zoom;
-
if (!w->file) {
im_weprintf(w, "couldn't reload, this image has no file associated with it.");
winwidget_render_image(w, 0, 0);
@@ -217,16 +207,7 @@ void feh_reload_image(winwidget w, int resize, int force_new)
w->im_w = gib_imlib_image_get_width(w->im);
w->im_h = gib_imlib_image_get_height(w->im);
}
- if (opt.keep_zoom_vp) {
- /* put back in: */
- w->mode = tmode;
- w->im_x = tim_x;
- w->im_y = tim_y;
- w->zoom = tzoom;
- winwidget_render_image(w, 0, 0);
- } else {
- winwidget_render_image(w, resize, 0);
- }
+ winwidget_render_image(w, resize, 0);
return;
}
@@ -241,11 +222,6 @@ void slideshow_change_image(winwidget winwid, int change, int render)
*/
int our_filelist_len = filelist_len;
- unsigned char tmode =0;
- int tim_x =0;
- int tim_y =0;
- double tzoom =0;
-
/* Without this, clicking a one-image slideshow reloads it. Not very *
intelligent behaviour :-) */
if (filelist_len < 2 && opt.cycle_once == 0)
@@ -356,14 +332,6 @@ void slideshow_change_image(winwidget winwid, int change, int render)
last = NULL;
}
- if (opt.keep_zoom_vp) {
- /* pre loadimage - record settings */
- tmode = winwid->mode;
- tim_x = winwid->im_x;
- tim_y = winwid->im_y;
- tzoom = winwid->zoom;
- }
-
if (winwidget_loadimage(winwid, FEH_FILE(current_file->data))) {
int w = gib_imlib_image_get_width(winwid->im);
int h = gib_imlib_image_get_height(winwid->im);
@@ -378,19 +346,8 @@ void slideshow_change_image(winwidget winwid, int change, int render)
winwidget_reset_image(winwid);
winwid->im_w = w;
winwid->im_h = h;
- if (opt.keep_zoom_vp) {
- /* put back in: */
- winwid->mode = tmode;
- winwid->im_x = tim_x;
- winwid->im_y = tim_y;
- winwid->zoom = tzoom;
- }
if (render) {
- if (opt.keep_zoom_vp) {
- winwidget_render_image(winwid, 0, 0);
- } else {
- winwidget_render_image(winwid, 1, 0);
- }
+ winwidget_render_image(winwid, 1, 0);
}
break;
} else
@@ -468,6 +425,12 @@ char *feh_printf(char *str, feh_file * file, winwidget winwid)
if (file)
strncat(ret, shell_escape(file->filename), sizeof(ret) - strlen(ret) - 1);
break;
+ case 'g':
+ if (winwid) {
+ snprintf(buf, sizeof(buf), "%d,%d", winwid->w, winwid->h);
+ strncat(ret, buf, sizeof(ret) - strlen(ret) - 1);
+ }
+ break;
case 'h':
if (file && (file->info || !feh_file_info_load(file, NULL))) {
snprintf(buf, sizeof(buf), "%d", file->info->height);
@@ -564,6 +527,12 @@ char *feh_printf(char *str, feh_file * file, winwidget winwid)
strncat(ret, "1.00", sizeof(ret) - strlen(ret) - 1);
}
break;
+ case 'Z':
+ if (winwid) {
+ snprintf(buf, sizeof(buf), "%f", winwid->zoom);
+ strncat(ret, buf, sizeof(ret) - strlen(ret) - 1);
+ }
+ break;
case '%':
strncat(ret, "%", sizeof(ret) - strlen(ret) - 1);
break;
diff --git a/src/structs.h b/src/structs.h
index 3942bc0..ce30eb9 100644
--- a/src/structs.h
+++ b/src/structs.h
@@ -1,7 +1,7 @@
/* structs.h
Copyright (C) 1999-2003 Tom Gilbert.
-Copyright (C) 2010-2011 Daniel Friesel.
+Copyright (C) 2010-2018 Daniel Friesel.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to
diff --git a/src/thumbnail.c b/src/thumbnail.c
index 003c7b4..45fbabe 100644
--- a/src/thumbnail.c
+++ b/src/thumbnail.c
@@ -1,7 +1,7 @@
/* thumbnail.c
Copyright (C) 1999-2003 Tom Gilbert.
-Copyright (C) 2010-2011 Daniel Friesel.
+Copyright (C) 2010-2018 Daniel Friesel.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to
@@ -149,9 +149,16 @@ void init_thumbnail_mode(void)
D(("imlib_create_image(%d, %d)\n", index_image_width, index_image_height));
td.im_main = imlib_create_image(index_image_width, index_image_height);
- if (!td.im_main)
- eprintf("Failed to create %dx%d pixels (%d MB) index image. Do you have enough RAM?",
- index_image_width, index_image_height, index_image_width * index_image_height * 4 / (1024*1024));
+ if (!td.im_main) {
+ if (index_image_height >= 32768 || index_image_width >= 32768) {
+ eprintf("Failed to create %dx%d pixels (%d MB) index image.\n"
+ "This is probably due to Imlib2 issues when dealing with images larger than 32k x 32k pixels.",
+ index_image_width, index_image_height, index_image_width * index_image_height * 4 / (1024*1024));
+ } else {
+ eprintf("Failed to create %dx%d pixels (%d MB) index image. Do you have enough RAM?",
+ index_image_width, index_image_height, index_image_width * index_image_height * 4 / (1024*1024));
+ }
+ }
gib_imlib_image_set_has_alpha(td.im_main, 1);
@@ -766,17 +773,26 @@ int feh_thumbnail_get_generated(Imlib_Image * image, feh_file * file,
void feh_thumbnail_show_fullsize(feh_file *thumbfile)
{
winwidget thumbwin = NULL;
+ gib_list *l;
+
+ for (l = filelist; l; l = l->next) {
+ if (FEH_FILE(l->data) == thumbfile) {
+ break;
+ }
+ }
+ if (!l) {
+ eprintf("Cannot find %s in filelist, wtf", thumbfile->filename);
+ }
thumbwin = winwidget_get_first_window_of_type(WIN_TYPE_THUMBNAIL_VIEWER);
if (!thumbwin) {
thumbwin = winwidget_create_from_file(
- gib_list_add_front(NULL, thumbfile),
+ l,
WIN_TYPE_THUMBNAIL_VIEWER);
if (thumbwin)
winwidget_show(thumbwin);
} else if (FEH_FILE(thumbwin->file->data) != thumbfile) {
- free(thumbwin->file);
- thumbwin->file = gib_list_add_front(NULL, thumbfile);
+ thumbwin->file = l;
feh_reload_image(thumbwin, 1, 1);
}
}
diff --git a/src/thumbnail.h b/src/thumbnail.h
index f22ff77..09cd771 100644
--- a/src/thumbnail.h
+++ b/src/thumbnail.h
@@ -1,7 +1,7 @@
/* thumbnail.h
Copyright (C) 1999-2003 Tom Gilbert.
-Copyright (C) 2010-2011 Daniel Friesel.
+Copyright (C) 2010-2018 Daniel Friesel.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to
diff --git a/src/timers.c b/src/timers.c
index 1cac94b..95fc9f8 100644
--- a/src/timers.c
+++ b/src/timers.c
@@ -1,7 +1,7 @@
/* timers.c
Copyright (C) 1999-2003 Tom Gilbert.
-Copyright (C) 2010-2011 Daniel Friesel.
+Copyright (C) 2010-2018 Daniel Friesel.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to
diff --git a/src/wallpaper.c b/src/wallpaper.c
index 2d3d3bc..db14a8c 100644
--- a/src/wallpaper.c
+++ b/src/wallpaper.c
@@ -1,7 +1,7 @@
/* wallpaper.c
Copyright (C) 1999-2003 Tom Gilbert.
-Copyright (C) 2010-2011 Daniel Friesel.
+Copyright (C) 2010-2018 Daniel Friesel.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to
@@ -453,36 +453,69 @@ void feh_wm_set_bg(char *fil, Imlib_Image im, int centered, int scaled,
if (home) {
FILE *fp;
char *path;
+ char *absolute_path;
struct stat s;
+ gib_list *filelist_pos = filelist;
path = estrjoin("/", home, ".fehbg", NULL);
if ((fp = fopen(path, "w")) == NULL) {
weprintf("Can't write to %s", path);
} else {
fputs("#!/bin/sh\n", fp);
+ fputs(cmdargv[0], fp);
+ fputs(" --bg-", fp);
+ if (centered)
+ fputs("center", fp);
+ else if (scaled)
+ fputs("scale", fp);
+ else if (filled == 1)
+ fputs("fill", fp);
+ else if (filled == 2)
+ fputs("max", fp);
+ else
+ fputs("tile", fp);
+ if (opt.image_bg) {
+ fputs(" --image-bg ", fp);
+ fputs(shell_escape(opt.image_bg), fp);
+ }
+#ifdef HAVE_LIBXINERAMA
+ if (opt.xinerama) {
+ if (opt.xinerama_index >= 0) {
+ fprintf(fp, " --xinerama-index %d", opt.xinerama_index);
+ }
+ }
+ else {
+ fputs(" --no-xinerama", fp);
+ }
+#endif /* HAVE_LIBXINERAMA */
+ if (opt.geom_flags & XValue) {
+ fprintf(fp, " --geometry %c%d",
+ opt.geom_flags & XNegative ? '-' : '+',
+ opt.geom_flags & XNegative ? abs(opt.geom_x) : opt.geom_x);
+ if (opt.geom_flags & YValue) {
+ fprintf(fp, "%c%d",
+ opt.geom_flags & YNegative ? '-' : '+',
+ opt.geom_flags & YNegative ? abs(opt.geom_y) : opt.geom_y);
+ }
+ }
+ if (opt.force_aliasing) {
+ fputs(" --force-aliasing", fp);
+ }
+ fputc(' ', fp);
if (use_filelist) {
for (int i = 0; i < cmdargc; i++) {
- fputs(shell_escape(cmdargv[i]), fp);
- fputc(' ', fp);
+ if (filelist_pos && !strcmp(FEH_FILE(filelist_pos->data)->filename, cmdargv[i])) {
+ /* argument is a file */
+ absolute_path = feh_absolute_path(cmdargv[i]);
+ fputs(shell_escape(absolute_path), fp);
+ filelist_pos = filelist_pos->next;
+ free(absolute_path);
+ fputc(' ', fp);
+ }
}
} else if (fil) {
- fputs("feh --bg-", fp);
- if (centered)
- fputs("center", fp);
- else if (scaled)
- fputs("scale", fp);
- else if (filled)
- fputs("fill", fp);
- else
- fputs("tile", fp);
-
- if (opt.force_aliasing)
- fputs(" --force-aliasing", fp);
-#ifdef HAVE_LIBXINERAMA
- if (!opt.xinerama)
- fputs(" --no-xinerama", fp);
-#endif
- fputc(' ', fp);
- fputs(shell_escape(fil), fp);
+ absolute_path = feh_absolute_path(fil);
+ fputs(shell_escape(absolute_path), fp);
+ free(absolute_path);
}
fputc('\n', fp);
fclose(fp);
diff --git a/src/wallpaper.h b/src/wallpaper.h
index 0921129..02a6997 100644
--- a/src/wallpaper.h
+++ b/src/wallpaper.h
@@ -1,7 +1,7 @@
/* wallpaper.h
Copyright (C) 1999-2003 Tom Gilbert.
-Copyright (C) 2010-2011 Daniel Friesel.
+Copyright (C) 2010-2018 Daniel Friesel.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to
diff --git a/src/winwidget.c b/src/winwidget.c
index bb6181a..fe0b505 100644
--- a/src/winwidget.c
+++ b/src/winwidget.c
@@ -1,7 +1,7 @@
/* winwidget.c
Copyright (C) 1999-2003 Tom Gilbert.
-Copyright (C) 2010-2011 Daniel Friesel.
+Copyright (C) 2010-2018 Daniel Friesel.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to
@@ -323,11 +323,12 @@ void winwidget_create_window(winwidget ret, int w, int h)
winwidget_register(ret);
/* do not scale down a thumbnail list window, only those created from it */
- if (opt.scale_down && (ret->type != WIN_TYPE_THUMBNAIL)) {
+ if (opt.geom_enabled && (ret->type != WIN_TYPE_THUMBNAIL)) {
opt.geom_w = w;
opt.geom_h = h;
opt.geom_flags |= WidthValue | HeightValue;
}
+
return;
}
@@ -422,138 +423,65 @@ void winwidget_render_image(winwidget winwid, int resize, int force_alias)
int sx, sy, sw, sh, dx, dy, dw, dh;
int calc_w, calc_h;
int antialias = 0;
- int need_center = winwid->had_resize;
if (!winwid->full_screen && resize) {
winwidget_resize(winwid, winwid->im_w, winwid->im_h, 0);
winwidget_reset_image(winwid);
}
- /* bounds checks for panning */
- if (winwid->im_x > winwid->w)
- winwid->im_x = winwid->w;
- if (winwid->im_y > winwid->h)
- winwid->im_y = winwid->h;
-
D(("winwidget_render_image resize %d force_alias %d im %dx%d\n",
resize, force_alias, winwid->im_w, winwid->im_h));
- winwidget_setup_pixmaps(winwid);
-
- if (!winwid->full_screen && ((gib_imlib_image_has_alpha(winwid->im))
- || (opt.geom_flags & (WidthValue | HeightValue))
- || (winwid->im_x || winwid->im_y) || (winwid->zoom != 1.0)
- || (winwid->w > winwid->im_w || winwid->h > winwid->im_h)
- || (winwid->has_rotated)))
- feh_draw_checks(winwid);
+ /* winwidget_setup_pixmaps(winwid) resets the winwid->had_resize flag */
+ int had_resize = winwid->had_resize || resize;
- if (!winwid->full_screen && opt.zoom_mode && (winwid->type != WIN_TYPE_THUMBNAIL)
- && (winwid->zoom == 1.0) && ! (opt.geom_flags & (WidthValue | HeightValue))
- && (winwid->w > winwid->im_w) && (winwid->h > winwid->im_h))
- feh_calc_needed_zoom(&(winwid->zoom), winwid->im_w, winwid->im_h, winwid->w, winwid->h);
+ winwidget_setup_pixmaps(winwid);
- /*
- * In case of a resize, the geomflags (and im_w, im_h) get updated by
- * the ConfigureNotify handler.
- */
- if (need_center && !winwid->full_screen && (winwid->type != WIN_TYPE_THUMBNAIL)
- && (opt.geom_flags & (WidthValue | HeightValue))
- && ((winwid->w < winwid->im_w) || (winwid->h < winwid->im_h)))
- feh_calc_needed_zoom(&(winwid->zoom), winwid->im_w, winwid->im_h, winwid->w, winwid->h);
+ if (had_resize && !opt.keep_zoom_vp && (winwid->type != WIN_TYPE_THUMBNAIL)) {
+ double required_zoom = 1.0;
+ feh_calc_needed_zoom(&required_zoom, winwid->im_w, winwid->im_h, winwid->w, winwid->h);
+ winwid->zoom = opt.default_zoom ? (0.01 * opt.default_zoom) : 1.0;
- if (resize && (winwid->type != WIN_TYPE_THUMBNAIL) &&
- (winwid->full_screen || (opt.geom_flags & (WidthValue | HeightValue)))) {
- int smaller; /* Is the image smaller than screen? */
- int max_w = 0, max_h = 0;
+ if ((opt.scale_down || (winwid->full_screen && !opt.default_zoom))
+ && winwid->zoom > required_zoom)
+ winwid->zoom = required_zoom;
+ else if ((opt.zoom_mode && required_zoom > 1)
+ && (!opt.default_zoom || required_zoom < winwid->zoom))
+ winwid->zoom = required_zoom;
- if (winwid->full_screen) {
- max_w = scr->width;
- max_h = scr->height;
-#ifdef HAVE_LIBXINERAMA
- if (opt.xinerama && xinerama_screens) {
- max_w = xinerama_screens[xinerama_screen].width;
- max_h = xinerama_screens[xinerama_screen].height;
+ if (opt.offset_flags & XValue) {
+ if (opt.offset_flags & XNegative) {
+ winwid->im_x = winwid->w - (winwid->im_w * winwid->zoom) - opt.offset_x;
+ } else {
+ winwid->im_x = - opt.offset_x * winwid->zoom;
}
-#endif /* HAVE_LIBXINERAMA */
} else {
- if (opt.geom_flags & WidthValue) {
- max_w = opt.geom_w;
- }
- if (opt.geom_flags & HeightValue) {
- max_h = opt.geom_h;
- }
+ winwid->im_x = (int) (winwid->w - (winwid->im_w * winwid->zoom)) >> 1;
}
-
- D(("Calculating for fullscreen/fixed geom render\n"));
- smaller = ((winwid->im_w < max_w)
- && (winwid->im_h < max_h));
-
- if (!smaller || opt.zoom_mode) {
- /* contributed by Jens Laas <jens.laas@data.slu.se>
- * What it does:
- * zooms images by a fixed amount but never larger than the screen.
- *
- * Why:
- * This is nice if you got a collection of images where some
- * are small and can stand a small zoom. Large images are unaffected.
- *
- * When does it work, and how?
- * You have to be in fullscreen mode _and_ have auto-zoom turned on.
- * "feh -FZ --zoom 130 imagefile" will do the trick.
- * -zoom percent - the new switch.
- * 100 = orignal size,
- * 130 is 30% larger.
- */
- if (opt.default_zoom) {
- double old_zoom = winwid->zoom;
-
- winwid->zoom = 0.01 * opt.default_zoom;
- if (opt.default_zoom != 100) {
- if ((winwid->im_h * winwid->zoom) > max_h)
- winwid->zoom = old_zoom;
- else if ((winwid->im_w * winwid->zoom) > max_w)
- winwid->zoom = old_zoom;
- }
-
- winwid->im_x = ((int)
- (max_w - (winwid->im_w * winwid->zoom))) >> 1;
- winwid->im_y = ((int)
- (max_h - (winwid->im_h * winwid->zoom))) >> 1;
+ if (opt.offset_flags & YValue) {
+ if (opt.offset_flags & YNegative) {
+ winwid->im_y = winwid->h - (winwid->im_h * winwid->zoom) - opt.offset_y;
} else {
- /* Image is larger than the screen (so wants shrinking), or it's
- smaller but wants expanding to fill it */
- double ratio = feh_calc_needed_zoom(&(winwid->zoom), winwid->im_w, winwid->im_h, max_w, max_h);
-
- if (ratio > 1.0) {
- /* height is the factor */
- winwid->im_x = 0;
- winwid->im_y = ((int)
- (max_h - (winwid->im_h * winwid->zoom))) >> 1;
- } else {
- /* width is the factor */
- winwid->im_x = ((int)
- (max_w - (winwid->im_w * winwid->zoom))) >> 1;
- winwid->im_y = 0;
- }
+ winwid->im_y = - opt.offset_y * winwid->zoom;
}
} else {
- /* my modification to jens hack, allow --zoom without auto-zoom mode */
- if (opt.default_zoom) {
- winwid->zoom = 0.01 * opt.default_zoom;
- } else {
- winwid->zoom = 1.0;
- }
- /* Just center the image in the window */
- winwid->im_x = (int) (max_w - (winwid->im_w * winwid->zoom)) >> 1;
- winwid->im_y = (int) (max_h - (winwid->im_h * winwid->zoom)) >> 1;
+ winwid->im_y = (int) (winwid->h - (winwid->im_h * winwid->zoom)) >> 1;
}
}
- else if (need_center && !winwid->full_screen
- && (winwid->type != WIN_TYPE_THUMBNAIL) && !opt.keep_zoom_vp) {
- winwid->im_x = (int) (winwid->w - (winwid->im_w * winwid->zoom)) >> 1;
- winwid->im_y = (int) (winwid->h - (winwid->im_h * winwid->zoom)) >> 1;
- }
+
+ winwid->had_resize = 0;
+
+ if (opt.keep_zoom_vp)
+ winwidget_sanitise_offsets(winwid);
+
+ if (!winwid->full_screen && ((gib_imlib_image_has_alpha(winwid->im))
+ || (opt.geom_flags & (WidthValue | HeightValue))
+ || (winwid->im_x || winwid->im_y)
+ || (winwid->w > winwid->im_w * winwid->zoom)
+ || (winwid->h > winwid->im_h * winwid->zoom)
+ || (winwid->has_rotated)))
+ feh_draw_checks(winwid);
/* Now we ensure only to render the area we're looking at */
dx = winwid->im_x;
@@ -706,13 +634,6 @@ Pixmap feh_create_checks(void)
return(checks_pmap);
}
-void winwidget_clear_background(winwidget w)
-{
- XSetWindowBackgroundPixmap(disp, w->win, feh_create_checks());
- /* XClearWindow(disp, w->win); */
- return;
-}
-
void feh_draw_checks(winwidget win)
{
static GC gc = None;
@@ -747,8 +668,6 @@ void winwidget_destroy(winwidget winwid)
free(winwid->name);
if (winwid->gc)
XFreeGC(disp, winwid->gc);
- if ((winwid->type == WIN_TYPE_THUMBNAIL_VIEWER) && (winwid->file != NULL))
- gib_list_free(winwid->file);
if (winwid->im)
gib_imlib_free_image_and_decache(winwid->im);
free(winwid);
@@ -874,24 +793,30 @@ void winwidget_resize(winwidget winwid, int w, int h, int force_resize)
D((" x %d y %d w %d h %d\n", attributes.x, attributes.y, winwid->w,
winwid->h));
- if ((opt.geom_flags & (WidthValue | HeightValue)) && !force_resize) {
- winwid->had_resize = 1;
- return;
- }
+ if ((opt.geom_flags & (WidthValue | HeightValue)) && !force_resize) {
+ winwid->had_resize = 1;
+ return;
+ }
if (winwid && ((winwid->w != w) || (winwid->h != h))) {
- /* winwidget_clear_background(winwid); */
if (opt.screen_clip) {
- winwid->w = (w > scr_width) ? scr_width : w;
- winwid->h = (h > scr_height) ? scr_height : h;
+ double required_zoom = winwid->zoom;
+ if (opt.scale_down && !opt.keep_zoom_vp) {
+ int max_w = (w > scr_width) ? scr_width : w;
+ int max_h = (h > scr_height) ? scr_height : h;
+ feh_calc_needed_zoom(&required_zoom, winwid->im_w, winwid->im_h, max_w, max_h);
+ }
+ int desired_w = winwid->im_w * required_zoom;
+ int desired_h = winwid->im_h * required_zoom;
+ winwid->w = (desired_w > scr_width) ? scr_width : desired_w;
+ winwid->h = (desired_h > scr_height) ? scr_height : desired_h;
}
if (winwid->full_screen) {
- XTranslateCoordinates(disp, winwid->win, attributes.root,
- -attributes.border_width -
- attributes.x,
- -attributes.border_width - attributes.y, &tc_x, &tc_y, &dw);
- winwid->x = tc_x;
- winwid->y = tc_y;
- XMoveResizeWindow(disp, winwid->win, tc_x, tc_y, winwid->w, winwid->h);
+ XTranslateCoordinates(disp, winwid->win, attributes.root,
+ -attributes.border_width - attributes.x,
+ -attributes.border_width - attributes.y, &tc_x, &tc_y, &dw);
+ winwid->x = tc_x;
+ winwid->y = tc_y;
+ XMoveResizeWindow(disp, winwid->win, tc_x, tc_y, winwid->w, winwid->h);
} else
XResizeWindow(disp, winwid->win, winwid->w, winwid->h);
@@ -1019,10 +944,12 @@ void feh_debug_print_winwid(winwidget w)
void winwidget_reset_image(winwidget winwid)
{
- winwid->zoom = 1.0;
- winwid->old_zoom = 1.0;
- winwid->im_x = 0;
- winwid->im_y = 0;
+ if (!opt.keep_zoom_vp) {
+ winwid->zoom = 1.0;
+ winwid->old_zoom = 1.0;
+ winwid->im_x = 0;
+ winwid->im_y = 0;
+ }
winwid->im_angle = 0.0;
winwid->has_rotated = 0;
return;
diff --git a/src/winwidget.h b/src/winwidget.h
index dd8489a..0a707ac 100644
--- a/src/winwidget.h
+++ b/src/winwidget.h
@@ -1,7 +1,7 @@
/* winwidget.h
Copyright (C) 1999-2003 Tom Gilbert.
-Copyright (C) 2010-2011 Daniel Friesel.
+Copyright (C) 2010-2018 Daniel Friesel.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to
@@ -146,7 +146,6 @@ winwidget winwidget_create_from_image(Imlib_Image im, char type);
void winwidget_rename(winwidget winwid, char *newname);
void winwidget_destroy(winwidget winwid);
void winwidget_create_window(winwidget ret, int w, int h);
-void winwidget_clear_background(winwidget w);
Pixmap feh_create_checks(void);
double feh_calc_needed_zoom(double *zoom, int orig_w, int orig_h, int dest_w, int dest_h);
void feh_debug_print_winwid(winwidget winwid);