Skip to content
This repository has been archived by the owner on Jan 16, 2023. It is now read-only.

Navigate if not scroll command #368

Open
wants to merge 31 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
f5b7c26
navigate if not scroll command
Naheel-Azawy Jul 12, 2019
7d2a810
bar bg + configs
Naheel-Azawy Jul 30, 2019
a7817d2
Start at file
Naheel-Azawy Jul 30, 2019
35a7788
fit zoom scale up too
Naheel-Azawy Aug 2, 2019
e9f1cc2
catch up with main repo (fullscreen stuff)
Naheel-Azawy Aug 2, 2019
51283f9
bar bg and fg
Naheel-Azawy Aug 2, 2019
7d92358
upstream sync
Naheel-Azawy May 28, 2020
c1005fa
square thumbs patch
Naheel-Azawy May 28, 2020
dea1ce9
readme
Naheel-Azawy May 28, 2020
7beaf7d
wider thumbs, smarter opts
Naheel-Azawy May 28, 2020
eca1c09
video
Naheel-Azawy May 29, 2020
1c053a0
mkv, better info for video, readme
Naheel-Azawy May 30, 2020
3d1c3fc
readme
Naheel-Azawy May 30, 2020
f5ed5ca
applied https://github.com/muennich/sxiv/pull/403
Naheel-Azawy Jul 13, 2020
47e25a7
3gp
Naheel-Azawy Jul 13, 2020
98f03f2
window titles
Naheel-Azawy Feb 11, 2021
a7d5b59
image info filename first
Naheel-Azawy Feb 11, 2021
f2bba27
added .desktop to makefile install
Naheel-Azawy Apr 5, 2021
c395f4c
svg
Naheel-Azawy Apr 9, 2021
819b262
breaking change: bar is hidden by default. -b shows the bar
Naheel-Azawy Apr 10, 2021
4dad44d
breaking change: bar is hidden by default. -b shows the bar
Naheel-Azawy Apr 13, 2021
ee2b17e
updated svg
Naheel-Azawy Apr 15, 2021
3824e50
added ms icon mime
Naheel-Azawy Apr 15, 2021
6564eaf
better video checking with libmagic
Naheel-Azawy Nov 26, 2021
8889815
updated readme
Naheel-Azawy Nov 26, 2021
9dba902
mpv video hack
Naheel-Azawy Aug 12, 2022
2d7d5c2
added mimetypes to desktop file from mpv.desktop
Naheel-Azawy Aug 12, 2022
a0f4a71
env font
Naheel-Azawy Aug 12, 2022
bdcbd12
better defaults for dragging
Naheel-Azawy Aug 12, 2022
1d387cc
file count at the begining of title
Naheel-Azawy Aug 31, 2022
f02eccf
navigation on release
Naheel-Azawy Aug 31, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 14 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ srcdir = .
VPATH = $(srcdir)

PREFIX = /usr/local
APP_PREFIX = /usr/share/applications/
MANPREFIX = $(PREFIX)/share/man

# autoreload backend: inotify/nop
Expand All @@ -15,20 +16,26 @@ HAVE_GIFLIB = 1
# enable features requiring libexif (-lexif)
HAVE_LIBEXIF = 1

cflags = -std=c99 -Wall -pedantic $(CFLAGS)
# enable checking mimetypes for videos
HAVE_LIBMAGIC = 1

cflags = -std=c99 -Wall -pedantic $(CFLAGS) `pkg-config --cflags --libs librsvg-2.0 cairo`
cppflags = -I. $(CPPFLAGS) -D_XOPEN_SOURCE=700 \
-DHAVE_GIFLIB=$(HAVE_GIFLIB) -DHAVE_LIBEXIF=$(HAVE_LIBEXIF) \
-DHAVE_LIBMAGIC=$(HAVE_LIBMAGIC) \
-I/usr/include/freetype2 -I$(PREFIX)/include/freetype2

lib_exif_0 =
lib_exif_1 = -lexif
lib_gif_0 =
lib_gif_1 = -lgif
lib_magic_0 =
lib_magic_1 = -lmagic
ldlibs = $(LDLIBS) -lImlib2 -lX11 -lXft -lfontconfig \
$(lib_exif_$(HAVE_LIBEXIF)) $(lib_gif_$(HAVE_GIFLIB))
$(lib_exif_$(HAVE_LIBEXIF)) $(lib_gif_$(HAVE_GIFLIB)) $(lib_magic_$(HAVE_LIBMAGIC))

objs = autoreload_$(AUTORELOAD).o commands.o image.o main.o options.o \
thumbs.o util.o window.o
thumbs.o util.o window.o video.o

all: sxiv

Expand All @@ -39,7 +46,7 @@ $(V).SILENT:

sxiv: $(objs)
@echo "LINK $@"
$(CC) $(LDFLAGS) -o $@ $(objs) $(ldlibs)
$(CC) $(LDFLAGS) -o $@ $(objs) $(ldlibs) $(cflags)

$(objs): Makefile sxiv.h commands.lst config.h
options.o: version.h
Expand Down Expand Up @@ -77,6 +84,8 @@ install: all
mkdir -p $(DESTDIR)$(PREFIX)/share/sxiv/exec
cp exec/* $(DESTDIR)$(PREFIX)/share/sxiv/exec/
chmod 755 $(DESTDIR)$(PREFIX)/share/sxiv/exec/*
cp -f sxiv.desktop $(DESTDIR)$(APP_PREFIX)
update-desktop-database

uninstall:
@echo "REMOVE bin/sxiv"
Expand All @@ -85,4 +94,5 @@ uninstall:
rm -f $(DESTDIR)$(MANPREFIX)/man1/sxiv.1
@echo "REMOVE share/sxiv/"
rm -rf $(DESTDIR)$(PREFIX)/share/sxiv
rm -f $(DESTDIR)$(APP_PREFIX)/fmz.desktop

195 changes: 27 additions & 168 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
![sxiv](http://muennich.github.com/sxiv/img/logo.png "sxiv")

**Simple X Image Viewer**

The sole purpose of sxiv is to be the perfect image viewer for me. It is free
software so that you can use it and modify it for your needs. Please file a bug
report if something does not work as documented or expected. Contributions are
welcome but there is no guarantee that they will be incorporated.

**IMPORTANT**

This repo is a fork of the [main sxiv repo](https://github.com/muennich/sxiv). Below are the reasons this fork exist.

Features
SXIV Main Features
--------

* Basic image operations, e.g. zooming, panning, rotating
Expand All @@ -19,17 +20,35 @@ Features
* Load all frames from GIF files and play GIF animations
* Display image information in status bar

Fork Features
-------------

Here are the key points that diverge from the main repo

* Video support
* Navigate with arrows when not zoomed
* Logarithmic zoom steps
* Fit image zoom by default
* Start with a file name (`-F` option)
* Match bar colors
* Window titles match the bar
* Square thumbnails [patch](https://github.com/i-tsvetkov/sxiv-patches/blob/master/sxiv-square-thumbnails.patch) by i-tsvetkov
* SVG support [patch](https://github.com/muennich/sxiv/pull/440) by Dhruv Vanjari

Screenshots
-----------

**Image mode:**

![Image](http://muennich.github.com/sxiv/img/image.png "Image mode")
![Image](screenshots/image.png "Image mode")

**Video mode:**

![Image](screenshots/video.png "Video mode")

**Thumbnail mode:**

![Thumb](http://muennich.github.com/sxiv/img/thumb.png "Thumb mode")
![Thumb](screenshots/thumb.png "Thumb mode")


Dependencies
Expand All @@ -44,6 +63,8 @@ sxiv requires the following software to be installed:
* fontconfig
* giflib (optional, disabled with `HAVE_GIFLIB=0`)
* libexif (optional, disabled with `HAVE_LIBEXIF=0`)
* libmagic (optional, disabled with `HAVE_LIBMAGIC=0`)
* ffmpegthumbnailer for video thumbnails

Please make sure to install the corresponding development packages in case that
you want to build sxiv on a distribution with separate runtime and development
Expand Down Expand Up @@ -78,167 +99,5 @@ the following command:
Usage
-----

Please see the [man page](http://muennich.github.com/sxiv/sxiv.1.html) for
information on how to use sxiv.


Download & Changelog
--------------------

You can [browse](https://github.com/muennich/sxiv) the source code repository
on GitHub or get a copy using git with the following command:

git clone https://github.com/muennich/sxiv.git

**Stable releases**

**[v26](https://github.com/muennich/sxiv/archive/v26.tar.gz)**
*(January 16, 2020)*

* Maintenance release

**[v25](https://github.com/muennich/sxiv/archive/v25.tar.gz)**
*(January 26, 2019)*

* Support font fallback for missing glyphs
* Fix busy loop when built without inotify
* Use background/foreground colors from X resource database

**[v24](https://github.com/muennich/sxiv/archive/v24.tar.gz)**
*(October 27, 2017)*

* Automatically reload the current image whenever it changes
* Support embedding into other X windows with -e (e.g. tabbed)
* New option -p prevents sxiv from creating cache and temporary files
* Simpler mouse mappings, the most basic features are accessible with the
mouse only (navigate, zoom, pan)

**[v1.3.2](https://github.com/muennich/sxiv/archive/v1.3.2.tar.gz)**
*(December 20, 2015)*

* external key handler gets file paths on stdin, not as arguments
* Cache out-of-view thumbnails in the background
* Apply gamma correction to thumbnails

**[v1.3.1](https://github.com/muennich/sxiv/archive/v1.3.1.tar.gz)**
*(November 16, 2014)*

* Fixed build error, caused by delayed config.h creation
* Fixed segfault when run with -c

**[v1.3](https://github.com/muennich/sxiv/archive/v1.3.tar.gz)**
*(October 24, 2014)*

* Extract thumbnails from EXIF tags (requires libexif)
* Zoomable thumbnails, supported sizes defined in config.h
* Fixed build error with giflib version >= 5.1.0

**[v1.2](https://github.com/muennich/sxiv/archive/v1.2.tar.gz)**
*(April 24, 2014)*

* Added external key handler, called on keys prefixed with `Ctrl-x`
* New keybinding `{`/`}` to change gamma (by András Mohari)
* Support for slideshows, enabled with `-S` option & toggled with `s`
* Added application icon (created by 0ion9)
* Checkerboard background for alpha layer
* Option `-o` only prints files marked with `m` key
* Fixed rotation/flipping of multi-frame images (gifs)

**[v1.1.1](https://github.com/muennich/sxiv/archive/v1.1.1.tar.gz)**
*(June 2, 2013)*

* Various bug fixes

**[v1.1](https://github.com/muennich/sxiv/archive/v1.1.tar.gz)**
*(March 30, 2013)*

* Added status bar on bottom of window with customizable content
* New keyboard shortcuts `\`/`|`: flip image vertically/horizontally
* New keyboard shortcut `Ctrl-6`: go to last/alternate image
* Added own EXIF orientation handling, removed dependency on libexif
* Fixed various bugs

**[v1.0](https://github.com/muennich/sxiv/archive/v1.0.tar.gz)**
*(October 31, 2011)*

* Support for multi-frame images & GIF animations
* POSIX compliant (IEEE Std 1003.1-2001)

**[v0.9](https://github.com/muennich/sxiv/archive/v0.9.tar.gz)**
*(August 17, 2011)*

* Made key and mouse mappings fully configurable in config.h
* Complete code refactoring

**[v0.8.2](https://github.com/muennich/sxiv/archive/v0.8.2.tar.gz)**
*(June 29, 2011)*

* POSIX-compliant Makefile; compiles under NetBSD

**[v0.8.1](https://github.com/muennich/sxiv/archive/v0.8.1.tar.gz)**
*(May 8, 2011)*

* Fixed fullscreen under window managers, which are not fully EWMH-compliant

**[v0.8](https://github.com/muennich/sxiv/archive/v0.8.tar.gz)**
*(April 18, 2011)*

* Support for thumbnail caching
* Ability to run external commands (e.g. jpegtran, convert) on current image

**[v0.7](https://github.com/muennich/sxiv/archive/v0.7.tar.gz)**
*(February 26, 2011)*

* Sort directory entries when using `-r` command line option
* Hide cursor in image mode
* Full functional thumbnail mode, use Return key to switch between image and
thumbnail mode

**[v0.6](https://github.com/muennich/sxiv/archive/v0.6.tar.gz)**
*(February 16, 2011)*

* Bug fix: Correctly display filenames with umlauts in window title
* Basic support of thumbnails

**[v0.5](https://github.com/muennich/sxiv/archive/v0.5.tar.gz)**
*(February 6, 2011)*

* New command line option: `-r`: open all images in given directories
* New key shortcuts: `w`: resize image to fit into window; `W`: resize window
to fit to image

**[v0.4](https://github.com/muennich/sxiv/archive/v0.4.tar.gz)**
*(February 1, 2011)*

* New command line option: `-F`, `-g`: use fixed window dimensions and apply
a given window geometry
* New key shortcut: `r`: reload current image

**[v0.3.1](https://github.com/muennich/sxiv/archive/v0.3.1.tar.gz)**
*(January 30, 2011)*

* Bug fix: Do not set setuid bit on executable when using `make install`
* Pan image with mouse while pressing middle mouse button

**[v0.3](https://github.com/muennich/sxiv/archive/v0.3.tar.gz)**
*(January 29, 2011)*

* New command line options: `-d`, `-f`, `-p`, `-s`, `-v`, `-w`, `-Z`, `-z`
* More mouse mappings: Go to next/previous image with left/right click,
scroll image with mouse wheel (horizontally if Shift key is pressed),
zoom image with mouse wheel if Ctrl key is pressed

**[v0.2](https://github.com/muennich/sxiv/archive/v0.2.tar.gz)**
*(January 23, 2011)*

* Bug fix: Handle window resizes correctly
* New keyboard shortcuts: `g`/`G`: go to first/last image; `[`/`]`: go 10
images back/forward
* Support for mouse wheel zooming (by Dave Reisner)
* Added fullscreen mode

**[v0.1](https://github.com/muennich/sxiv/archive/v0.1.tar.gz)**
*(January 21, 2011)*

* Initial release
Please see the man page for information on how to use sxiv.

46 changes: 42 additions & 4 deletions commands.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

#include "sxiv.h"
#define _IMAGE_CONFIG
#define _VIDEO_CONFIG
#include "config.h"

#include <stdlib.h>
Expand Down Expand Up @@ -101,10 +102,6 @@ bool cg_toggle_bar(arg_t _)
{
win_toggle_bar(&win);
if (mode == MODE_IMAGE) {
if (win.bar.h > 0)
open_info();
else
close_info();
img.checkpan = img.dirty = true;
} else {
tns.dirty = true;
Expand Down Expand Up @@ -306,8 +303,34 @@ bool ci_navigate_frame(arg_t d)
return !img.multi.animate && img_frame_navigate(&img, d);
}

pid_t run_mpv(int xwin, const char *video)
{
// TODO: be portable?
const static char *mpv = "/usr/bin/mpv";
pid_t pid = fork();
if (pid < 0) {
return -1;
} else if (pid == 0) {
if (xwin > 0) {
char wid[16];
sprintf(wid, "%d", xwin);
execl(mpv, "mpv", "-wid", wid, video, NULL);
} else {
execl(mpv, "mpv", video, NULL);
}
return 0; // unreachable
} else {
return pid;
}
}

bool ci_toggle_animation(arg_t _)
{
if (files[fileidx].video_thumb != NULL) {
run_mpv(win.xwin, files[fileidx].path);
return false;
}

bool dirty = false;

if (img.multi.cnt > 0) {
Expand All @@ -332,6 +355,21 @@ bool ci_scroll_to_edge(arg_t dir)
return img_pan_edge(&img, dir);
}

bool ci_scroll_or_navigate(arg_t dir)
{
if (img_zoom_diff(&img, NULL) >= 0) {
arg_t n;
switch (dir) {
case DIR_LEFT: n = -1; break;
case DIR_RIGHT: n = 1; break;
default: n = 0; break;
}
return ci_navigate(n);
} else {
return ci_scroll(dir);
}
}

bool ci_drag(arg_t mode)
{
int x, y, ox, oy;
Expand Down
1 change: 1 addition & 0 deletions commands.lst
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ I_CMD(navigate_frame)
I_CMD(toggle_animation)
I_CMD(scroll)
I_CMD(scroll_to_edge)
I_CMD(scroll_or_navigate)
I_CMD(drag)
I_CMD(set_zoom)
I_CMD(fit_to_win)
Expand Down
Loading