aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile4
-rw-r--r--commands.c110
-rw-r--r--commands.h26
-rw-r--r--exif.c38
-rw-r--r--exif.h26
-rw-r--r--image.c101
-rw-r--r--image.h26
-rw-r--r--main.c86
-rw-r--r--options.c35
-rw-r--r--options.h26
-rw-r--r--thumbs.c65
-rw-r--r--thumbs.h26
-rw-r--r--types.h27
-rw-r--r--util.c62
-rw-r--r--util.h26
-rw-r--r--window.c85
-rw-r--r--window.h26
17 files changed, 467 insertions, 328 deletions
diff --git a/Makefile b/Makefile
index eff9067..ef3bd79 100644
--- a/Makefile
+++ b/Makefile
@@ -1,10 +1,10 @@
-VERSION = git-20130129
+VERSION = git-20130208
PREFIX = /usr/local
MANPREFIX = $(PREFIX)/share/man
CC = gcc
-CFLAGS = -Wall -pedantic -O2 -I$(PREFIX)/include -DHAVE_GIFLIB
+CFLAGS = -std=c99 -Wall -pedantic -O2 -I$(PREFIX)/include -DHAVE_GIFLIB
LDFLAGS = -L$(PREFIX)/lib
LIBS = -lX11 -lImlib2 -lgif
diff --git a/commands.c b/commands.c
index e742016..7274475 100644
--- a/commands.c
+++ b/commands.c
@@ -1,19 +1,19 @@
-/* sxiv: commands.c
- * Copyright (c) 2012 Bert Muennich <be.muennich at googlemail.com>
+/* Copyright 2011, 2012 Bert Muennich
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2 of the License, or (at your
- * option) any later version.
+ * This file is part of sxiv.
*
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
+ * sxiv is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published
+ * by the Free Software Foundation; either version 2 of the License,
+ * or (at your option) any later version.
*
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * sxiv is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with sxiv. If not, see <http://www.gnu.org/licenses/>.
*/
#define _POSIX_C_SOURCE 200112L
@@ -54,12 +54,14 @@ const int ss_delays[] = {
1, 2, 3, 5, 10, 15, 20, 30, 60, 120, 180, 300, 600
};
-bool it_quit(arg_t a) {
+bool it_quit(arg_t a)
+{
cleanup();
exit(EXIT_SUCCESS);
}
-bool it_switch_mode(arg_t a) {
+bool it_switch_mode(arg_t a)
+{
if (mode == MODE_IMAGE) {
if (tns.thumbs == NULL)
tns_init(&tns, filecnt, &win);
@@ -75,7 +77,8 @@ bool it_switch_mode(arg_t a) {
return true;
}
-bool it_toggle_fullscreen(arg_t a) {
+bool it_toggle_fullscreen(arg_t a)
+{
win_toggle_fullscreen(&win);
/* redraw after next ConfigureNotify event */
set_timeout(redraw, TO_REDRAW_RESIZE, false);
@@ -86,7 +89,8 @@ bool it_toggle_fullscreen(arg_t a) {
return false;
}
-bool it_toggle_bar(arg_t a) {
+bool it_toggle_bar(arg_t a)
+{
win_toggle_bar(&win);
if (mode == MODE_IMAGE)
img.checkpan = img.dirty = true;
@@ -95,7 +99,8 @@ bool it_toggle_bar(arg_t a) {
return true;
}
-bool t_reload_all(arg_t a) {
+bool t_reload_all(arg_t a)
+{
if (mode == MODE_THUMB) {
tns_free(&tns);
tns_init(&tns, filecnt, &win);
@@ -105,7 +110,8 @@ bool t_reload_all(arg_t a) {
}
}
-bool it_reload_image(arg_t a) {
+bool it_reload_image(arg_t a)
+{
if (mode == MODE_IMAGE) {
load_image(fileidx);
} else {
@@ -120,7 +126,8 @@ bool it_reload_image(arg_t a) {
return true;
}
-bool it_remove_image(arg_t a) {
+bool it_remove_image(arg_t a)
+{
if (mode == MODE_IMAGE) {
remove_file(fileidx, true);
load_image(fileidx >= filecnt ? filecnt - 1 : fileidx);
@@ -136,7 +143,8 @@ bool it_remove_image(arg_t a) {
}
}
-bool i_navigate(arg_t a) {
+bool i_navigate(arg_t a)
+{
long n = (long) a;
if (mode == MODE_IMAGE) {
@@ -156,7 +164,8 @@ bool i_navigate(arg_t a) {
return false;
}
-bool i_alternate(arg_t a) {
+bool i_alternate(arg_t a)
+{
if (mode == MODE_IMAGE) {
load_image(alternate);
return true;
@@ -165,7 +174,8 @@ bool i_alternate(arg_t a) {
}
}
-bool it_first(arg_t a) {
+bool it_first(arg_t a)
+{
if (mode == MODE_IMAGE && fileidx != 0) {
load_image(0);
return true;
@@ -178,7 +188,8 @@ bool it_first(arg_t a) {
}
}
-bool it_n_or_last(arg_t a) {
+bool it_n_or_last(arg_t a)
+{
int n = prefix != 0 && prefix - 1 < filecnt ? prefix - 1 : filecnt - 1;
if (mode == MODE_IMAGE && fileidx != n) {
@@ -193,14 +204,16 @@ bool it_n_or_last(arg_t a) {
}
}
-bool i_navigate_frame(arg_t a) {
+bool i_navigate_frame(arg_t a)
+{
if (mode == MODE_IMAGE && !img.multi.animate)
return img_frame_navigate(&img, (long) a);
else
return false;
}
-bool i_toggle_animation(arg_t a) {
+bool i_toggle_animation(arg_t a)
+{
if (mode != MODE_IMAGE)
return false;
@@ -213,7 +226,8 @@ bool i_toggle_animation(arg_t a) {
return true;
}
-bool it_scroll_move(arg_t a) {
+bool it_scroll_move(arg_t a)
+{
direction_t dir = (direction_t) a;
if (mode == MODE_IMAGE)
@@ -222,7 +236,8 @@ bool it_scroll_move(arg_t a) {
return tns_move_selection(&tns, dir, prefix);
}
-bool it_scroll_screen(arg_t a) {
+bool it_scroll_screen(arg_t a)
+{
direction_t dir = (direction_t) a;
if (mode == MODE_IMAGE)
@@ -231,7 +246,8 @@ bool it_scroll_screen(arg_t a) {
return tns_scroll(&tns, dir, true);
}
-bool i_scroll_to_edge(arg_t a) {
+bool i_scroll_to_edge(arg_t a)
+{
direction_t dir = (direction_t) a;
if (mode == MODE_IMAGE)
@@ -241,11 +257,13 @@ bool i_scroll_to_edge(arg_t a) {
}
/* Xlib helper function for i_drag() */
-Bool is_motionnotify(Display *d, XEvent *e, XPointer a) {
+Bool is_motionnotify(Display *d, XEvent *e, XPointer a)
+{
return e != NULL && e->type == MotionNotify;
}
-bool i_drag(arg_t a) {
+bool i_drag(arg_t a)
+{
int dx = 0, dy = 0, i, ox, oy, x, y;
unsigned int ui;
bool dragging = true, next = false;
@@ -297,7 +315,8 @@ bool i_drag(arg_t a) {
return false;
}
-bool i_zoom(arg_t a) {
+bool i_zoom(arg_t a)
+{
long scale = (long) a;
if (mode != MODE_IMAGE)
@@ -311,14 +330,16 @@ bool i_zoom(arg_t a) {
return false;
}
-bool i_set_zoom(arg_t a) {
+bool i_set_zoom(arg_t a)
+{
if (mode == MODE_IMAGE)
return img_zoom(&img, (prefix ? prefix : (long) a) / 100.0);
else
return false;
}
-bool i_fit_to_win(arg_t a) {
+bool i_fit_to_win(arg_t a)
+{
bool ret = false;
scalemode_t sm = (scalemode_t) a;
@@ -329,7 +350,8 @@ bool i_fit_to_win(arg_t a) {
return ret;
}
-bool i_fit_to_img(arg_t a) {
+bool i_fit_to_img(arg_t a)
+{
int x, y;
unsigned int w, h;
bool ret = false;
@@ -348,7 +370,8 @@ bool i_fit_to_img(arg_t a) {
return ret;
}
-bool i_rotate(arg_t a) {
+bool i_rotate(arg_t a)
+{
direction_t dir = (direction_t) a;
if (mode == MODE_IMAGE) {
@@ -363,7 +386,8 @@ bool i_rotate(arg_t a) {
return false;
}
-bool i_flip(arg_t a) {
+bool i_flip(arg_t a)
+{
flipdir_t dir = (flipdir_t) a;
if (mode == MODE_IMAGE) {
@@ -374,7 +398,8 @@ bool i_flip(arg_t a) {
}
}
-bool i_toggle_antialias(arg_t a) {
+bool i_toggle_antialias(arg_t a)
+{
if (mode == MODE_IMAGE) {
img_toggle_antialias(&img);
return true;
@@ -383,7 +408,8 @@ bool i_toggle_antialias(arg_t a) {
}
}
-bool it_toggle_alpha(arg_t a) {
+bool it_toggle_alpha(arg_t a)
+{
img.alpha = tns.alpha = !img.alpha;
if (mode == MODE_IMAGE)
img.dirty = true;
@@ -392,7 +418,8 @@ bool it_toggle_alpha(arg_t a) {
return true;
}
-bool it_open_with(arg_t a) {
+bool it_open_with(arg_t a)
+{
const char *prog = (const char*) a;
pid_t pid;
@@ -410,7 +437,8 @@ bool it_open_with(arg_t a) {
return false;
}
-bool it_shell_cmd(arg_t a) {
+bool it_shell_cmd(arg_t a)
+{
int n, status;
const char *cmdline = (const char*) a;
pid_t pid;
diff --git a/commands.h b/commands.h
index f6d381d..7a6752f 100644
--- a/commands.h
+++ b/commands.h
@@ -1,19 +1,19 @@
-/* sxiv: commands.h
- * Copyright (c) 2012 Bert Muennich <be.muennich at googlemail.com>
+/* Copyright 2011 Bert Muennich
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2 of the License, or (at your
- * option) any later version.
+ * This file is part of sxiv.
*
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
+ * sxiv is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published
+ * by the Free Software Foundation; either version 2 of the License,
+ * or (at your option) any later version.
*
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * sxiv is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with sxiv. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef COMMANDS_H
diff --git a/exif.c b/exif.c
index 5244028..ae2c2d1 100644
--- a/exif.c
+++ b/exif.c
@@ -1,19 +1,19 @@
-/* sxiv: exif.c
- * Copyright (c) 2012 Bert Muennich <be.muennich at googlemail.com>
+/* Copyright 2012 Bert Muennich
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2 of the License, or (at your
- * option) any later version.
+ * This file is part of sxiv.
*
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
+ * sxiv is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published
+ * by the Free Software Foundation; either version 2 of the License,
+ * or (at your option) any later version.
*
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * sxiv is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with sxiv. If not, see <http://www.gnu.org/licenses/>.
*/
#define _POSIX_C_SOURCE 200112L
@@ -26,7 +26,8 @@
#include "exif.h"
#include "util.h"
-ssize_t s_read(int fd, const char *fn, void *buf, size_t n) {
+ssize_t s_read(int fd, const char *fn, void *buf, size_t n)
+{
ssize_t ret;
ret = read(fd, buf, n);
@@ -38,7 +39,8 @@ ssize_t s_read(int fd, const char *fn, void *buf, size_t n) {
}
}
-unsigned short btous(unsigned char *buf, byteorder_t order) {
+unsigned short btous(unsigned char *buf, byteorder_t order)
+{
if (buf == NULL)
return 0;
if (order == BO_BIG_ENDIAN)
@@ -47,7 +49,8 @@ unsigned short btous(unsigned char *buf, byteorder_t order) {
return buf[1] << 8 | buf[0];
}
-unsigned int btoui(unsigned char *buf, byteorder_t order) {
+unsigned int btoui(unsigned char *buf, byteorder_t order)
+{
if (buf == NULL)
return 0;
if (order == BO_BIG_ENDIAN)
@@ -56,7 +59,8 @@ unsigned int btoui(unsigned char *buf, byteorder_t order) {
return buf[3] << 24 | buf[2] << 16 | buf[1] << 8 | buf[0];
}
-int exif_orientation(const fileinfo_t *file) {
+int exif_orientation(const fileinfo_t *file)
+{
int fd;
unsigned char data[EXIF_MAX_LEN];
byteorder_t order = BO_BIG_ENDIAN;
diff --git a/exif.h b/exif.h
index aa43a30..b37b2cc 100644
--- a/exif.h
+++ b/exif.h
@@ -1,19 +1,19 @@
-/* sxiv: exif.h
- * Copyright (c) 2012 Bert Muennich <be.muennich at googlemail.com>
+/* Copyright 2012 Bert Muennich
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2 of the License, or (at your
- * option) any later version.
+ * This file is part of sxiv.
*
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
+ * sxiv is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published
+ * by the Free Software Foundation; either version 2 of the License,
+ * or (at your option) any later version.
*
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * sxiv is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with sxiv. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef EXIF_H
diff --git a/image.c b/image.c
index fa74eda..7e3329a 100644
--- a/image.c
+++ b/image.c
@@ -1,19 +1,19 @@
-/* sxiv: image.c
- * Copyright (c) 2012 Bert Muennich <be.muennich at googlemail.com>
+/* Copyright 2011, 2012 Bert Muennich
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2 of the License, or (at your
- * option) any later version.
+ * This file is part of sxiv.
*
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
+ * sxiv is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published
+ * by the Free Software Foundation; either version 2 of the License,
+ * or (at your option) any later version.
*
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * sxiv is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with sxiv. If not, see <http://www.gnu.org/licenses/>.
*/
#define _POSIX_C_SOURCE 200112L
@@ -38,11 +38,13 @@ enum { MIN_GIF_DELAY = 25 };
float zoom_min;
float zoom_max;
-int zoomdiff(float z1, float z2) {
+int zoomdiff(float z1, float z2)
+{
return (int) (z1 * 1000.0 - z2 * 1000.0);
}
-void img_init(img_t *img, win_t *win) {
+void img_init(img_t *img, win_t *win)
+{
zoom_min = zoom_levels[0] / 100.0;
zoom_max = zoom_levels[ARRLEN(zoom_levels) - 1] / 100.0;
@@ -66,7 +68,8 @@ void img_init(img_t *img, win_t *win) {
img->multi.animate = false;
}
-void exif_auto_orientate(const fileinfo_t *file) {
+void exif_auto_orientate(const fileinfo_t *file)
+{
switch (exif_orientation(file)) {
case 5:
imlib_image_orientate(1);
@@ -95,7 +98,8 @@ void exif_auto_orientate(const fileinfo_t *file) {
}
#if HAVE_GIFLIB
-bool img_load_gif(img_t *img, const fileinfo_t *file) {
+bool img_load_gif(img_t *img, const fileinfo_t *file)
+{
GifFileType *gif;
GifRowType *rows = NULL;
GifRecordType rec;
@@ -266,7 +270,8 @@ bool img_load_gif(img_t *img, const fileinfo_t *file) {
}
#endif /* HAVE_GIFLIB */
-bool img_load(img_t *img, const fileinfo_t *file) {
+bool img_load(img_t *img, const fileinfo_t *file)
+{
const char *fmt;
if (img == NULL || file == NULL || file->name == NULL || file->path == NULL)
@@ -303,7 +308,8 @@ bool img_load(img_t *img, const fileinfo_t *file) {
return true;
}
-void img_close(img_t *img, bool decache) {
+void img_close(img_t *img, bool decache)
+{
int i;
if (img == NULL)
@@ -326,7 +332,8 @@ void img_close(img_t *img, bool decache) {
}
}
-void img_check_pan(img_t *img, bool moved) {
+void img_check_pan(img_t *img, bool moved)
+{
win_t *win;
int ox, oy;
@@ -358,7 +365,8 @@ void img_check_pan(img_t *img, bool moved) {
img->dirty = true;
}
-bool img_fit(img_t *img) {
+bool img_fit(img_t *img)
+{
float z, zmax, zw, zh;
if (img == NULL || img->im == NULL || img->win == NULL)
@@ -394,7 +402,8 @@ bool img_fit(img_t *img) {
}
}
-void img_render(img_t *img) {
+void img_render(img_t *img)
+{
win_t *win;
int sx, sy, sw, sh;
int dx, dy, dw, dh;
@@ -464,7 +473,8 @@ void img_render(img_t *img) {
img->dirty = false;
}
-bool img_fit_win(img_t *img, scalemode_t sm) {
+bool img_fit_win(img_t *img, scalemode_t sm)
+{
if (img == NULL || img->im == NULL)
return false;
@@ -472,7 +482,8 @@ bool img_fit_win(img_t *img, scalemode_t sm) {
return img_fit(img);
}
-bool img_center(img_t *img) {
+bool img_center(img_t *img)
+{
int ox, oy;
if (img == NULL || img->im == NULL || img->win == NULL)
@@ -492,7 +503,8 @@ bool img_center(img_t *img) {
}
}
-bool img_zoom(img_t *img, float z) {
+bool img_zoom(img_t *img, float z)
+{
if (img == NULL || img->im == NULL || img->win == NULL)
return false;
@@ -513,7 +525,8 @@ bool img_zoom(img_t *img, float z) {
}
}
-bool img_zoom_in(img_t *img) {
+bool img_zoom_in(img_t *img)
+{
int i;
float z;
@@ -528,7 +541,8 @@ bool img_zoom_in(img_t *img) {
return false;
}
-bool img_zoom_out(img_t *img) {
+bool img_zoom_out(img_t *img)
+{
int i;
float z;
@@ -543,7 +557,8 @@ bool img_zoom_out(img_t *img) {
return false;
}
-bool img_move(img_t *img, float dx, float dy) {
+bool img_move(img_t *img, float dx, float dy)
+{
float ox, oy;
if (img == NULL || img->im == NULL)
@@ -565,7 +580,8 @@ bool img_move(img_t *img, float dx, float dy) {
}
}
-bool img_pan(img_t *img, direction_t dir, int d) {
+bool img_pan(img_t *img, direction_t dir, int d)
+{
/* d < 0: screen-wise
* d = 0: 1/5 of screen
* d > 0: num of pixels
@@ -595,7 +611,8 @@ bool img_pan(img_t *img, direction_t dir, int d) {
return false;
}
-bool img_pan_edge(img_t *img, direction_t dir) {
+bool img_pan_edge(img_t *img, direction_t dir)
+{
int ox, oy;
if (img == NULL || img->im == NULL || img->win == NULL)
@@ -629,7 +646,8 @@ bool img_pan_edge(img_t *img, direction_t dir) {
}
}
-void img_rotate(img_t *img, int d) {
+void img_rotate(img_t *img, int d)
+{
win_t *win;
int ox, oy, tmp;
@@ -654,15 +672,18 @@ void img_rotate(img_t *img, int d) {
img->dirty = true;
}
-void img_rotate_left(img_t *img) {
+void img_rotate_left(img_t *img)
+{
img_rotate(img, 3);
}
-void img_rotate_right(img_t *img) {
+void img_rotate_right(img_t *img)
+{
img_rotate(img, 1);
}
-void img_flip(img_t *img, flipdir_t d) {
+void img_flip(img_t *img, flipdir_t d)
+{
if (img == NULL || img->im == NULL)
return;
@@ -679,7 +700,8 @@ void img_flip(img_t *img, flipdir_t d) {
img->dirty = true;
}
-void img_toggle_antialias(img_t *img) {
+void img_toggle_antialias(img_t *img)
+{
if (img == NULL || img->im == NULL)
return;
@@ -689,7 +711,8 @@ void img_toggle_antialias(img_t *img) {
img->dirty = true;
}
-bool img_frame_goto(img_t *img, int n) {
+bool img_frame_goto(img_t *img, int n)
+{
if (img == NULL || img->im == NULL)
return false;
if (n < 0 || n >= img->multi.cnt || n == img->multi.sel)
@@ -707,7 +730,8 @@ bool img_frame_goto(img_t *img, int n) {
return true;
}
-bool img_frame_navigate(img_t *img, int d) {
+bool img_frame_navigate(img_t *img, int d)
+{
if (img == NULL|| img->im == NULL || img->multi.cnt == 0 || d == 0)
return false;
@@ -720,7 +744,8 @@ bool img_frame_navigate(img_t *img, int d) {
return img_frame_goto(img, d);
}
-bool img_frame_animate(img_t *img, bool restart) {
+bool img_frame_animate(img_t *img, bool restart)
+{
if (img == NULL || img->im == NULL || img->multi.cnt == 0)
return false;
diff --git a/image.h b/image.h
index 034922a..dbb249e 100644
--- a/image.h
+++ b/image.h
@@ -1,19 +1,19 @@
-/* sxiv: image.h
- * Copyright (c) 2012 Bert Muennich <be.muennich at googlemail.com>
+/* Copyright 2011 Bert Muennich
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2 of the License, or (at your
- * option) any later version.
+ * This file is part of sxiv.
*
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
+ * sxiv is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published
+ * by the Free Software Foundation; either version 2 of the License,
+ * or (at your option) any later version.
*
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * sxiv is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with sxiv. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef IMAGE_H
diff --git a/main.c b/main.c
index 1be4cd3..9ff3c1e 100644
--- a/main.c
+++ b/main.c
@@ -1,19 +1,19 @@
-/* sxiv: main.c
- * Copyright (c) 2012 Bert Muennich <be.muennich at googlemail.com>
+/* Copyright 2011-2013 Bert Muennich
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2 of the License, or (at your
- * option) any later version.
+ * This file is part of sxiv.
*
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
+ * sxiv is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published
+ * by the Free Software Foundation; either version 2 of the License,
+ * or (at your option) any later version.
*
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * sxiv is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with sxiv. If not, see <http://www.gnu.org/licenses/>.
*/
#define _POSIX_C_SOURCE 200112L
@@ -84,7 +84,8 @@ timeout_t timeouts[] = {
{ { 0, 0 }, false, clear_resize },
};
-void cleanup(void) {
+void cleanup(void)
+{
static bool in = false;
if (!in) {
@@ -95,7 +96,8 @@ void cleanup(void) {
}
}
-void check_add_file(char *filename) {
+void check_add_file(char *filename)
+{
const char *bn;
if (filename == NULL || *filename == '\0')
@@ -128,7 +130,8 @@ void check_add_file(char *filename) {
fileidx++;
}
-void remove_file(int n, bool manual) {
+void remove_file(int n, bool manual)
+{
if (n < 0 || n >= filecnt)
return;
@@ -156,7 +159,8 @@ void remove_file(int n, bool manual) {
tns.cnt--;
}
-void set_timeout(timeout_f handler, int time, bool overwrite) {
+void set_timeout(timeout_f handler, int time, bool overwrite)
+{
int i;
for (i = 0; i < ARRLEN(timeouts); i++) {
@@ -171,7 +175,8 @@ void set_timeout(timeout_f handler, int time, bool overwrite) {
}
}
-void reset_timeout(timeout_f handler) {
+void reset_timeout(timeout_f handler)
+{
int i;
for (i = 0; i < ARRLEN(timeouts); i++) {
@@ -182,7 +187,8 @@ void reset_timeout(timeout_f handler) {
}
}
-bool check_timeouts(struct timeval *t) {
+bool check_timeouts(struct timeval *t)
+{
int i = 0, tdiff, tmin = -1;
struct timeval now;
@@ -206,7 +212,8 @@ bool check_timeouts(struct timeval *t) {
return tmin > 0;
}
-void read_info(void) {
+void read_info(void)
+{
char cmd[4096];
FILE *outp;
int c, i = 0, n = sizeof(bar.l) - 1;
@@ -236,7 +243,8 @@ end:
bar.l[i] = '\0';
}
-void load_image(int new) {
+void load_image(int new)
+{
if (new < 0 || new >= filecnt)
return;
@@ -261,7 +269,8 @@ void load_image(int new) {
reset_timeout(animate);
}
-void update_info(void) {
+void update_info(void)
+{
unsigned int i, fn, fw, n, len = sizeof(bar.r);
int sel;
char *t = bar.r, title[TITLE_LEN];
@@ -309,7 +318,8 @@ void update_info(void) {
win_set_bar_info(&win, bar.l, bar.r);
}
-void redraw(void) {
+void redraw(void)
+{
if (mode == MODE_IMAGE)
img_render(&img);
else
@@ -320,7 +330,8 @@ void redraw(void) {
reset_cursor();
}
-void reset_cursor(void) {
+void reset_cursor(void)
+{
int i;
cursor_t cursor = CURSOR_NONE;
@@ -341,27 +352,32 @@ void reset_cursor(void) {
win_set_cursor(&win, cursor);
}
-void animate(void) {
+void animate(void)
+{
if (img_frame_animate(&img, false)) {
redraw();
set_timeout(animate, img.multi.frames[img.multi.sel].delay, true);
}
}
-void clear_resize(void) {
+void clear_resize(void)
+{
resized = false;
}
-bool keymask(const keymap_t *k, unsigned int state) {
+bool keymask(const keymap_t *k, unsigned int state)
+{
return (k->ctrl ? ControlMask : 0) == (state & ControlMask);
}
-bool buttonmask(const button_t *b, unsigned int state) {
+bool buttonmask(const button_t *b, unsigned int state)
+{
return ((b->ctrl ? ControlMask : 0) | (b->shift ? ShiftMask : 0)) ==
(state & (ControlMask | ShiftMask));
}
-void on_keypress(XKeyEvent *kev) {
+void on_keypress(XKeyEvent *kev)
+{
int i;
KeySym ksym;
char key;
@@ -389,7 +405,8 @@ void on_keypress(XKeyEvent *kev) {
}
}
-void on_buttonpress(XButtonEvent *bev) {
+void on_buttonpress(XButtonEvent *bev)
+{
int i, sel;
if (bev == NULL)
@@ -436,7 +453,8 @@ void on_buttonpress(XButtonEvent *bev) {
}
}
-void run(void) {
+void run(void)
+{
int xfd;
fd_set fds;
struct timeval timeout;
@@ -531,11 +549,13 @@ void run(void) {
}
}
-int fncmp(const void *a, const void *b) {
+int fncmp(const void *a, const void *b)
+{
return strcoll(((fileinfo_t*) a)->name, ((fileinfo_t*) b)->name);
}
-int main(int argc, char **argv) {
+int main(int argc, char **argv)
+{
int i, start;
size_t n;
ssize_t len;
diff --git a/options.c b/options.c
index 224fa2c..0354616 100644
--- a/options.c
+++ b/options.c
@@ -1,19 +1,19 @@
-/* sxiv: options.c
- * Copyright (c) 2012 Bert Muennich <be.muennich at googlemail.com>
+/* Copyright 2011 Bert Muennich
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2 of the License, or (at your
- * option) any later version.
+ * This file is part of sxiv.
*
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
+ * sxiv is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published
+ * by the Free Software Foundation; either version 2 of the License,
+ * or (at your option) any later version.
*
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * sxiv is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with sxiv. If not, see <http://www.gnu.org/licenses/>.
*/
#define _POSIX_C_SOURCE 200112L
@@ -31,16 +31,19 @@
options_t _options;
const options_t *options = (const options_t*) &_options;
-void print_usage(void) {
+void print_usage(void)
+{
printf("usage: sxiv [-bcdFfhpqrstvZ] [-g GEOMETRY] [-n NUM] "
"[-N name] [-z ZOOM] FILES...\n");
}
-void print_version(void) {
+void print_version(void)
+{
printf("sxiv %s - Simple X Image Viewer\n", VERSION);
}
-void parse_options(int argc, char **argv) {
+void parse_options(int argc, char **argv)
+{
int opt, t;
_options.recursive = false;
diff --git a/options.h b/options.h
index eb32cfc..f21410e 100644
--- a/options.h
+++ b/options.h
@@ -1,19 +1,19 @@
-/* sxiv: options.h
- * Copyright (c) 2012 Bert Muennich <be.muennich at googlemail.com>
+/* Copyright 2011 Bert Muennich
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2 of the License, or (at your
- * option) any later version.
+ * This file is part of sxiv.
*
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
+ * sxiv is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published
+ * by the Free Software Foundation; either version 2 of the License,
+ * or (at your option) any later version.
*
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * sxiv is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with sxiv. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef OPTIONS_H
diff --git a/thumbs.c b/thumbs.c
index 5453815..48b3a75 100644
--- a/thumbs.c
+++ b/thumbs.c
@@ -1,19 +1,19 @@
-/* sxiv: thumbs.c
- * Copyright (c) 2012 Bert Muennich <be.muennich at googlemail.com>
+/* Copyright 2011 Bert Muennich
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2 of the License, or (at your
- * option) any later version.
+ * This file is part of sxiv.
*
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
+ * sxiv is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published
+ * by the Free Software Foundation; either version 2 of the License,
+ * or (at your option) any later version.
*
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * sxiv is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with sxiv. If not, see <http://www.gnu.org/licenses/>.
*/
#define _POSIX_C_SOURCE 200112L
@@ -36,14 +36,16 @@ static const int thumb_dim = THUMB_SIZE + 10;
static const char * const CACHE_DIR = ".sxiv/cache";
static char *cache_dir = NULL;
-bool tns_cache_enabled(void) {
+bool tns_cache_enabled(void)
+{
struct stat stats;
return cache_dir != NULL && stat(cache_dir, &stats) == 0 &&
S_ISDIR(stats.st_mode) && access(cache_dir, W_OK) == 0;
}
-char* tns_cache_filepath(const char *filepath) {
+char* tns_cache_filepath(const char *filepath)
+{
size_t len;
char *cfile = NULL;
@@ -59,7 +61,8 @@ char* tns_cache_filepath(const char *filepath) {
return cfile;
}
-Imlib_Image* tns_cache_load(const char *filepath) {
+Imlib_Image* tns_cache_load(const char *filepath)
+{
char *cfile;
struct stat cstats, fstats;
Imlib_Image *im = NULL;
@@ -77,7 +80,8 @@ Imlib_Image* tns_cache_load(const char *filepath) {
return im;
}
-void tns_cache_write(thumb_t *t, bool force) {
+void tns_cache_write(thumb_t *t, bool force)
+{
char *cfile, *dirend;
struct stat cstats, fstats;
struct utimbuf times;
@@ -118,7 +122,8 @@ void tns_cache_write(thumb_t *t, bool force) {
}
}
-void tns_clean_cache(tns_t *tns) {
+void tns_clean_cache(tns_t *tns)
+{
int dirlen;
bool delete;
char *cfile, *filename, *tpos;
@@ -154,7 +159,8 @@ void tns_clean_cache(tns_t *tns) {
}
-void tns_init(tns_t *tns, int cnt, win_t *win) {
+void tns_init(tns_t *tns, int cnt, win_t *win)
+{
int len;
char *homedir;
@@ -185,7 +191,8 @@ void tns_init(tns_t *tns, int cnt, win_t *win) {
}
}
-void tns_free(tns_t *tns) {
+void tns_free(tns_t *tns)
+{
int i;
if (tns == NULL)
@@ -282,7 +289,8 @@ bool tns_load(tns_t *tns, int n, const fileinfo_t *file,
return true;
}
-void tns_check_view(tns_t *tns, bool scrolled) {
+void tns_check_view(tns_t *tns, bool scrolled)
+{
int r;
if (tns == NULL)
@@ -309,7 +317,8 @@ void tns_check_view(tns_t *tns, bool scrolled) {
}
}
-void tns_render(tns_t *tns) {
+void tns_render(tns_t *tns)
+{
thumb_t *t;
win_t *win;
int i, cnt, r, x, y;
@@ -364,7 +373,8 @@ void tns_render(tns_t *tns) {
tns_highlight(tns, tns->sel, true);
}
-void tns_highlight(tns_t *tns, int n, bool hl) {
+void tns_highlight(tns_t *tns, int n, bool hl)
+{
thumb_t *t;
win_t *win;
int x, y;
@@ -392,7 +402,8 @@ void tns_highlight(tns_t *tns, int n, bool hl) {
}
}
-bool tns_move_selection(tns_t *tns, direction_t dir, int cnt) {
+bool tns_move_selection(tns_t *tns, direction_t dir, int cnt)
+{
int old, max;
if (tns == NULL || tns->thumbs == NULL)
@@ -427,7 +438,8 @@ bool tns_move_selection(tns_t *tns, direction_t dir, int cnt) {
return tns->sel != old;
}
-bool tns_scroll(tns_t *tns, direction_t dir, bool screen) {
+bool tns_scroll(tns_t *tns, direction_t dir, bool screen)
+{
int d, max, old;
if (tns == NULL)
@@ -452,7 +464,8 @@ bool tns_scroll(tns_t *tns, direction_t dir, bool screen) {
return tns->first != old;
}
-int tns_translate(tns_t *tns, int x, int y) {
+int tns_translate(tns_t *tns, int x, int y)
+{
int n;
if (tns == NULL || tns->thumbs == NULL)
diff --git a/thumbs.h b/thumbs.h
index 0aadcd1..aa95961 100644
--- a/thumbs.h
+++ b/thumbs.h
@@ -1,19 +1,19 @@
-/* sxiv: thumbs.h
- * Copyright (c) 2012 Bert Muennich <be.muennich at googlemail.com>
+/* Copyright 2011 Bert Muennich
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2 of the License, or (at your
- * option) any later version.
+ * This file is part of sxiv.
*
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
+ * sxiv is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published
+ * by the Free Software Foundation; either version 2 of the License,
+ * or (at your option) any later version.
*
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * sxiv is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with sxiv. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef THUMBS_H
diff --git a/types.h b/types.h
index f09a379..1b15c73 100644
--- a/types.h
+++ b/types.h
@@ -1,14 +1,25 @@
+/* Copyright 2011 Bert Muennich
+ *
+ * This file is part of sxiv.
+ *
+ * sxiv is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published
+ * by the Free Software Foundation; either version 2 of the License,
+ * or (at your option) any later version.
+ *
+ * sxiv is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with sxiv. If not, see <http://www.gnu.org/licenses/>.
+ */
+
#ifndef TYPES_H
#define TYPES_H
-#undef bool
-#undef false
-#undef true
-
-typedef enum {
- false,
- true
-} bool;
+#include <stdbool.h>
typedef enum {
BO_BIG_ENDIAN,
diff --git a/util.c b/util.c
index c73953c..7abded2 100644
--- a/util.c
+++ b/util.c
@@ -1,19 +1,19 @@
-/* sxiv: util.c
- * Copyright (c) 2012 Bert Muennich <be.muennich at googlemail.com>
+/* Copyright 2011 Bert Muennich
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2 of the License, or (at your
- * option) any later version.
+ * This file is part of sxiv.
*
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
+ * sxiv is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published
+ * by the Free Software Foundation; either version 2 of the License,
+ * or (at your option) any later version.
*
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * sxiv is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with sxiv. If not, see <http://www.gnu.org/licenses/>.
*/
#define _POSIX_C_SOURCE 200112L
@@ -36,7 +36,8 @@ enum {
void cleanup(void);
-void* s_malloc(size_t size) {
+void* s_malloc(size_t size)
+{
void *ptr;
ptr = malloc(size);
@@ -45,14 +46,16 @@ void* s_malloc(size_t size) {
return ptr;
}
-void* s_realloc(void *ptr, size_t size) {
+void* s_realloc(void *ptr, size_t size)
+{
ptr = realloc(ptr, size);
if (ptr == NULL)
die("could not allocate memory");
return ptr;
}
-char* s_strdup(char *s) {
+char* s_strdup(char *s)
+{
char *d = NULL;
if (s != NULL) {
@@ -64,7 +67,8 @@ char* s_strdup(char *s) {
return d;
}
-void warn(const char* fmt, ...) {
+void warn(const char* fmt, ...)
+{
va_list args;
if (fmt == NULL || options->quiet)
@@ -77,7 +81,8 @@ void warn(const char* fmt, ...) {
va_end(args);
}
-void die(const char* fmt, ...) {
+void die(const char* fmt, ...)
+{
va_list args;
if (fmt == NULL)
@@ -93,7 +98,8 @@ void die(const char* fmt, ...) {
exit(EXIT_FAILURE);
}
-ssize_t get_line(char **buf, size_t *n, FILE *stream) {
+ssize_t get_line(char **buf, size_t *n, FILE *stream)
+{
size_t len;
char *s;
@@ -125,7 +131,8 @@ ssize_t get_line(char **buf, size_t *n, FILE *stream) {
return s - *buf + len;
}
-void size_readable(float *size, const char **unit) {
+void size_readable(float *size, const char **unit)
+{
const char *units[] = { "", "K", "M", "G" };
int i;
@@ -134,7 +141,8 @@ void size_readable(float *size, const char **unit) {
*unit = units[MIN(i, ARRLEN(units) - 1)];
}
-char* absolute_path(const char *filename) {
+char* absolute_path(const char *filename)
+{
size_t len;
const char *basename;
char *dir, *dirname = NULL, *path = NULL, *s;
@@ -206,7 +214,8 @@ end:
return path;
}
-int r_opendir(r_dir_t *rdir, const char *dirname) {
+int r_opendir(r_dir_t *rdir, const char *dirname)
+{
if (rdir == NULL || dirname == NULL || *dirname == '\0')
return -1;
@@ -226,7 +235,8 @@ int r_opendir(r_dir_t *rdir, const char *dirname) {
return 0;
}
-int r_closedir(r_dir_t *rdir) {
+int r_closedir(r_dir_t *rdir)
+{
int ret = 0;
if (rdir == NULL)
@@ -252,7 +262,8 @@ int r_closedir(r_dir_t *rdir) {
return ret;
}
-char* r_readdir(r_dir_t *rdir) {
+char* r_readdir(r_dir_t *rdir)
+{
size_t len;
char *filename;
struct dirent *dentry;
@@ -304,7 +315,8 @@ char* r_readdir(r_dir_t *rdir) {
return NULL;
}
-int r_mkdir(const char *path) {
+int r_mkdir(const char *path)
+{
char *dir, *d;
struct stat stats;
int err = 0;
diff --git a/util.h b/util.h
index f1f4f14..e7a567d 100644
--- a/util.h
+++ b/util.h
@@ -1,19 +1,19 @@
-/* sxiv: util.h
- * Copyright (c) 2012 Bert Muennich <be.muennich at googlemail.com>
+/* Copyright 2011 Bert Muennich
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2 of the License, or (at your
- * option) any later version.
+ * This file is part of sxiv.
*
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
+ * sxiv is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published
+ * by the Free Software Foundation; either version 2 of the License,
+ * or (at your option) any later version.
*
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * sxiv is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with sxiv. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef UTIL_H
diff --git a/window.c b/window.c
index 5c41be3..e011953 100644
--- a/window.c
+++ b/window.c
@@ -1,19 +1,19 @@
-/* sxiv: window.c
- * Copyright (c) 2012 Bert Muennich <be.muennich at googlemail.com>
+/* Copyright 2011-2013 Bert Muennich
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2 of the License, or (at your
- * option) any later version.
+ * This file is part of sxiv.
*
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
+ * sxiv is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published
+ * by the Free Software Foundation; either version 2 of the License,
+ * or (at your option) any later version.
*
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * sxiv is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with sxiv. If not, see <http://www.gnu.org/licenses/>.
*/
#define _POSIX_C_SOURCE 200112L
@@ -52,7 +52,8 @@ static struct {
static int fontheight;
static int barheight;
-void win_init_font(Display *dpy, const char *fontstr) {
+void win_init_font(Display *dpy, const char *fontstr)
+{
int n;
char *def, **missing;
@@ -84,7 +85,8 @@ void win_init_font(Display *dpy, const char *fontstr) {
barheight = fontheight + 2 * V_TEXT_PAD;
}
-unsigned long win_alloc_color(win_t *win, const char *name) {
+unsigned long win_alloc_color(win_t *win, const char *name)
+{
XColor col;
if (win == NULL)
@@ -98,7 +100,8 @@ unsigned long win_alloc_color(win_t *win, const char *name) {
return col.pixel;
}
-void win_init(win_t *win) {
+void win_init(win_t *win)
+{
win_env_t *e;
if (win == NULL)
@@ -135,7 +138,8 @@ void win_init(win_t *win) {
wm_delete_win = XInternAtom(e->dpy, "WM_DELETE_WINDOW", False);
}
-void win_set_sizehints(win_t *win) {
+void win_set_sizehints(win_t *win)
+{
if (win == NULL || win->xwin == None)
return;
@@ -156,7 +160,8 @@ void win_set_sizehints(win_t *win) {
XSetWMNormalHints(win->env.dpy, win->xwin, &win->sizehints);
}
-void win_open(win_t *win) {
+void win_open(win_t *win)
+{
win_env_t *e;
XClassHint classhint;
XColor col;
@@ -261,7 +266,8 @@ void win_open(win_t *win) {
win_toggle_fullscreen(win);
}
-void win_close(win_t *win) {
+void win_close(win_t *win)
+{
if (win == NULL || win->xwin == None)
return;
@@ -276,7 +282,8 @@ void win_close(win_t *win) {
XCloseDisplay(win->env.dpy);
}
-bool win_configure(win_t *win, XConfigureEvent *c) {
+bool win_configure(win_t *win, XConfigureEvent *c)
+{
bool changed;
if (win == NULL || c == NULL)
@@ -298,7 +305,8 @@ bool win_configure(win_t *win, XConfigureEvent *c) {
return changed;
}
-void win_expose(win_t *win, XExposeEvent *e) {
+void win_expose(win_t *win, XExposeEvent *e)
+{
if (win == NULL || win->xwin == None || win->pm == None || e == NULL)
return;
@@ -306,7 +314,8 @@ void win_expose(win_t *win, XExposeEvent *e) {
e->x, e->y, e->width, e->height, e->x, e->y);
}
-bool win_moveresize(win_t *win, int x, int y, unsigned int w, unsigned int h) {
+bool win_moveresize(win_t *win, int x, int y, unsigned int w, unsigned int h)
+{
if (win == NULL || win->xwin == None)
return false;
@@ -328,10 +337,16 @@ bool win_moveresize(win_t *win, int x, int y, unsigned int w, unsigned int h) {
XMoveResizeWindow(win->env.dpy, win->xwin, x, y, w, h);
+ if (win->pm != None) {
+ XFreePixmap(win->env.dpy, win->pm);
+ win->pm = None;
+ }
+
return true;
}
-void win_toggle_fullscreen(win_t *win) {
+void win_toggle_fullscreen(win_t *win)
+{
XEvent ev;
XClientMessageEvent *cm;
@@ -355,7 +370,8 @@ void win_toggle_fullscreen(win_t *win) {
SubstructureNotifyMask | SubstructureRedirectMask, &ev);
}
-void win_toggle_bar(win_t *win) {
+void win_toggle_bar(win_t *win)
+{
if (win == NULL || win->xwin == None)
return;
@@ -368,7 +384,8 @@ void win_toggle_bar(win_t *win) {
}
}
-void win_clear(win_t *win) {
+void win_clear(win_t *win)
+{
int h;
win_env_t *e;
@@ -385,7 +402,8 @@ void win_clear(win_t *win) {
XFillRectangle(e->dpy, win->pm, gc, 0, 0, win->w, h);
}
-void win_draw_bar(win_t *win) {
+void win_draw_bar(win_t *win)
+{
int len, olen, x, y, w, tw;
char rest[3];
const char *dots = "...";
@@ -440,7 +458,8 @@ void win_draw_bar(win_t *win) {
}
}
-void win_draw(win_t *win) {
+void win_draw(win_t *win)
+{
if (win == NULL || win->xwin == None || win->pm == None)
return;
@@ -469,7 +488,8 @@ void win_draw_rect(win_t *win, Pixmap pm, int x, int y, int w, int h,
XDrawRectangle(win->env.dpy, pm, gc, x, y, w, h);
}
-int win_textwidth(const char *text, unsigned int len, bool with_padding) {
+int win_textwidth(const char *text, unsigned int len, bool with_padding)
+{
XRectangle r;
int padding = with_padding ? 2 * H_TEXT_PAD : 0;
@@ -481,7 +501,8 @@ int win_textwidth(const char *text, unsigned int len, bool with_padding) {
}
}
-void win_set_title(win_t *win, const char *title) {
+void win_set_title(win_t *win, const char *title)
+{
if (win == NULL || win->xwin == None)
return;
@@ -501,14 +522,16 @@ void win_set_title(win_t *win, const char *title) {
PropModeReplace, (unsigned char *) title, strlen(title));
}
-void win_set_bar_info(win_t *win, char *linfo, char *rinfo) {
+void win_set_bar_info(win_t *win, char *linfo, char *rinfo)
+{
if (win != NULL) {
win->bar.l = linfo;
win->bar.r = rinfo;
}
}
-void win_set_cursor(win_t *win, cursor_t cursor) {
+void win_set_cursor(win_t *win, cursor_t cursor)
+{
if (win == NULL || win->xwin == None)
return;
diff --git a/window.h b/window.h
index 60f2864..dfb39aa 100644
--- a/window.h
+++ b/window.h
@@ -1,19 +1,19 @@
-/* sxiv: window.h
- * Copyright (c) 2012 Bert Muennich <be.muennich at googlemail.com>
+/* Copyright 2011 Bert Muennich
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2 of the License, or (at your
- * option) any later version.
+ * This file is part of sxiv.
*
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
+ * sxiv is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published
+ * by the Free Software Foundation; either version 2 of the License,
+ * or (at your option) any later version.
*
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * sxiv is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with sxiv. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef WINDOW_H