summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Makefile4
-rw-r--r--src/collage.c12
-rw-r--r--src/feh.h13
-rw-r--r--src/feh_png.c4
-rw-r--r--src/feh_png.h4
-rw-r--r--src/filelist.c32
-rw-r--r--src/gib_hash.c2
-rw-r--r--src/help.raw3
-rw-r--r--src/imlib.c37
-rw-r--r--src/index.c12
-rw-r--r--src/list.c2
-rw-r--r--src/multiwindow.c20
-rw-r--r--src/options.c28
-rw-r--r--src/options.h4
-rw-r--r--src/slideshow.c78
-rw-r--r--src/thumbnail.c38
-rw-r--r--src/wallpaper.c43
-rw-r--r--src/winwidget.c57
-rw-r--r--src/winwidget.h4
19 files changed, 160 insertions, 237 deletions
diff --git a/src/Makefile b/src/Makefile
index 2f6185a..8a9f97e 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -51,9 +51,9 @@ include deps.mk
fehrc.inc: fehrc.raw
help.inc: help.raw
-
+# CFLAGS might contain include paths needed to resolve includes in headers
deps.mk: ${TARGETS} ${I_DSTS}
- ${CC} ${CPPFLAGS} -MM ${TARGETS} > $@
+ ${CC} ${CFLAGS} -MM ${TARGETS} > $@
clean:
rm -f feh *.o *.inc
diff --git a/src/collage.c b/src/collage.c
index b975136..431d3b6 100644
--- a/src/collage.c
+++ b/src/collage.c
@@ -41,7 +41,6 @@ void init_collage_mode(void)
feh_file *file = NULL;
unsigned char trans_bg = 0;
gib_list *l, *last = NULL;
- char *s;
mode = "collage";
@@ -105,15 +104,9 @@ void init_collage_mode(void)
gib_imlib_image_fill_rectangle(im_main, 0, 0, w, h, 0, 0, 0, 255);
}
- /* Create the title string */
-
- if (!opt.title)
- s = estrdup(PACKAGE " [collage mode]");
- else
- s = estrdup(feh_printf(opt.title, NULL, NULL));
-
if (opt.display) {
- winwid = winwidget_create_from_image(im_main, s, WIN_TYPE_SINGLE);
+ winwid = winwidget_create_from_image(im_main, WIN_TYPE_SINGLE);
+ winwidget_rename(winwid, PACKAGE " [collage mode]");
winwidget_show(winwid);
}
@@ -210,7 +203,6 @@ void init_collage_mode(void)
if (!opt.display)
gib_imlib_free_image_and_decache(im_main);
- free(s);
return;
}
diff --git a/src/feh.h b/src/feh.h
index a4a0a7b..3e0cdda 100644
--- a/src/feh.h
+++ b/src/feh.h
@@ -27,6 +27,14 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#ifndef FEH_H
#define FEH_H
+/*
+ * strverscmp(3) is a GNU extension. In most supporting C libraries it
+ * requires _GNU_SOURCE to be defined.
+ */
+#ifdef HAVE_VERSCMP
+#define _GNU_SOURCE
+#endif
+
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <X11/Xatom.h>
@@ -107,8 +115,6 @@ enum slide_change { SLIDE_NEXT, SLIDE_PREV, SLIDE_RAND, SLIDE_FIRST, SLIDE_LAST,
SLIDE_JUMP_PREV_DIR
};
-enum image_bg { IMAGE_BG_CHECKS = 1, IMAGE_BG_BLACK, IMAGE_BG_WHITE };
-
#define INPLACE_EDIT_FLIP -1
#define INPLACE_EDIT_MIRROR -2
@@ -133,12 +139,11 @@ void init_list_mode(void);
void init_loadables_mode(void);
void init_unloadables_mode(void);
void feh_clean_exit(void);
+int feh_should_ignore_image(Imlib_Image * im);
int feh_load_image(Imlib_Image * im, feh_file * file);
void show_mini_usage(void);
void slideshow_change_image(winwidget winwid, int change, int render);
void slideshow_pause_toggle(winwidget w);
-char *slideshow_create_name(feh_file * file, winwidget winwid);
-char *thumbnail_create_name(feh_file * file, winwidget winwid);
void init_keyevents(void);
void init_buttonbindings(void);
void setup_stdin(void);
diff --git a/src/feh_png.c b/src/feh_png.c
index d27df01..d0c1c8a 100644
--- a/src/feh_png.c
+++ b/src/feh_png.c
@@ -23,13 +23,13 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
-#include "feh_png.h"
-
#include <png.h>
#include <stdio.h>
#include <stdarg.h>
+#include "feh_png.h"
+
#define FEH_PNG_COMPRESSION 3
#define FEH_PNG_NUM_COMMENTS 4
diff --git a/src/feh_png.h b/src/feh_png.h
index ac3375f..035d36a 100644
--- a/src/feh_png.h
+++ b/src/feh_png.h
@@ -26,11 +26,11 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#ifndef FEH_PNG_H
#define FEH_PNG_H
-#include "feh.h"
-
#include <stdio.h>
#include <stdarg.h>
+#include "feh.h"
+
gib_hash *feh_png_read_comments(char *file);
int feh_png_write_png_fd(Imlib_Image image, int fd, ...);
diff --git a/src/filelist.c b/src/filelist.c
index b569b8a..453f795 100644
--- a/src/filelist.c
+++ b/src/filelist.c
@@ -397,14 +397,26 @@ void feh_file_dirname(char *dst, feh_file * f, int maxlen)
dst[n] = '\0';
}
+#ifdef HAVE_VERSCMP
+inline int strcmp_or_strverscmp(const char *s1, const char *s2)
+{
+ if (!opt.version_sort)
+ return(strcmp(s1, s2));
+ else
+ return(strverscmp(s1, s2));
+}
+#else
+#define strcmp_or_strverscmp strcmp
+#endif
+
int feh_cmp_filename(void *file1, void *file2)
{
- return(strcmp(FEH_FILE(file1)->filename, FEH_FILE(file2)->filename));
+ return(strcmp_or_strverscmp(FEH_FILE(file1)->filename, FEH_FILE(file2)->filename));
}
int feh_cmp_name(void *file1, void *file2)
{
- return(strcmp(FEH_FILE(file1)->name, FEH_FILE(file2)->name));
+ return(strcmp_or_strverscmp(FEH_FILE(file1)->name, FEH_FILE(file2)->name));
}
int feh_cmp_dirname(void *file1, void *file2)
@@ -413,7 +425,7 @@ int feh_cmp_dirname(void *file1, void *file2)
int cmp;
feh_file_dirname(dir1, FEH_FILE(file1), PATH_MAX);
feh_file_dirname(dir2, FEH_FILE(file2), PATH_MAX);
- if ((cmp = strcmp(dir1, dir2)) != 0)
+ if ((cmp = strcmp_or_strverscmp(dir1, dir2)) != 0)
return(cmp);
return(feh_cmp_name(file1, file2));
}
@@ -464,9 +476,17 @@ int feh_cmp_format(void *file1, void *file2)
void feh_prepare_filelist(void)
{
- if (opt.list || opt.customlist || (opt.sort > SORT_MTIME)
- || opt.preload || opt.min_width || opt.min_height
- || (opt.max_width != UINT_MAX) || (opt.max_height != UINT_MAX)) {
+ /*
+ * list and customlist mode as well as the somewhat more fancy sort modes
+ * need access to file infos. Preloading them is also useful for
+ * list/customlist as --min-dimension/--max-dimension may filter images
+ * which should not be processed.
+ * Finally, if --min-dimension/--max-dimension (-> opt.filter_by_dimensions)
+ * is set and we're in thumbnail mode, we need to filter images first so
+ * we can create a properly sized thumbnail list.
+ */
+ if (opt.list || opt.preload || opt.customlist || (opt.sort > SORT_MTIME)
+ || (opt.filter_by_dimensions && (opt.index || opt.collage || opt.thumbs || opt.bgmode))) {
/* For these sort options, we have to preload images */
filelist = feh_file_info_preload(filelist);
if (!gib_list_length(filelist))
diff --git a/src/gib_hash.c b/src/gib_hash.c
index 15bbf4a..0d6a226 100644
--- a/src/gib_hash.c
+++ b/src/gib_hash.c
@@ -22,11 +22,11 @@ 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.
*/
+#include <strings.h>
#include "gib_hash.h"
#include "utils.h"
#include "debug.h"
-#include <strings.h>
gib_hash_node *gib_hash_node_new(char *key, void *data)
{
diff --git a/src/help.raw b/src/help.raw
index 37e0e71..86bb617 100644
--- a/src/help.raw
+++ b/src/help.raw
@@ -52,6 +52,7 @@ OPTIONS
name, filename, mtime, width, height, pixels, size,
or format
-n, --reverse Reverse sort order
+ --version-sort Natural sort of (version) numbers within text
-A, --action [;]ACTION Specify action to perform when pressing <return>.
Executed by /bin/sh, may contain FORMAT SPECIFIERS
reloads image with \";\", switches to next otherwise
@@ -84,7 +85,7 @@ OPTIONS
can be used multiple times to add multiple paths.
-M, --menu-font FONT Use FONT for the font in menus.
-B, --image-bg STYLE Set background for transparent images and the like.
- Accepted values: white, black, default
+ Accepted values: default, checks, or a XColor (eg. #428bdd)
-N, --no-menus Don't load or show any menus.
--no-xinerama Disable Xinerama support
--no-screen-clip Do not limit window size to screen size
diff --git a/src/imlib.c b/src/imlib.c
index 73b7039..d9c5cd0 100644
--- a/src/imlib.c
+++ b/src/imlib.c
@@ -139,6 +139,18 @@ void init_x_and_imlib(void)
return;
}
+int feh_should_ignore_image(Imlib_Image * im)
+{
+ if (opt.filter_by_dimensions) {
+ unsigned int w = gib_imlib_image_get_width(im);
+ unsigned int h = gib_imlib_image_get_height(im);
+ if (w < opt.min_width || w > opt.max_width || h < opt.min_height || h > opt.max_height) {
+ return 1;
+ }
+ }
+ return 0;
+}
+
int feh_load_image_char(Imlib_Image * im, char *filename)
{
feh_file *file;
@@ -231,7 +243,7 @@ int feh_load_image(Imlib_Image * im, feh_file * file)
if ((image_source != SRC_IMLIB) && tmpname) {
*im = imlib_load_image_with_error_return(tmpname, &err);
- if (im) {
+ if (!err && im) {
real_filename = file->filename;
file->filename = tmpname;
feh_file_info_load(file, *im);
@@ -240,7 +252,7 @@ int feh_load_image(Imlib_Image * im, feh_file * file)
file->ed = exif_get_data(tmpname);
#endif
}
- if ((image_source == SRC_MAGICK) || !opt.keep_http)
+ if ((image_source != SRC_HTTP) || !opt.keep_http)
unlink(tmpname);
free(tmpname);
@@ -357,30 +369,17 @@ static char *feh_magick_load_image(char *filename)
else {
alarm(opt.magick_timeout);
waitpid(childpid, &status, 0);
- alarm(0);
- if (!WIFEXITED(status) || (WEXITSTATUS(status) != 0)) {
- close(fd);
+ kill(childpid, SIGKILL);
+ if (opt.magick_timeout > 0 && !alarm(0)) {
unlink(sfn);
free(sfn);
sfn = NULL;
if (!opt.quiet) {
- if (WIFSIGNALED(status))
- weprintf("%s - Conversion took too long, skipping",
- filename);
+ weprintf("%s - Conversion took too long, skipping", filename);
}
-
- /*
- * Reap child. The previous waitpid call was interrupted by
- * alarm, but convert doesn't terminate immediately.
- * XXX
- * normally, if (WIFSIGNALED(status)) waitpid(childpid, &status, 0);
- * would suffice. However, as soon as feh has its own window,
- * this doesn't work anymore and the following workaround is
- * required. Hm.
- */
- waitpid(-1, &status, 0);
}
+ close(fd);
childpid = 0;
}
diff --git a/src/index.c b/src/index.c
index fbc25b8..c8c34c5 100644
--- a/src/index.c
+++ b/src/index.c
@@ -59,7 +59,6 @@ void init_index_mode(void)
int lineno;
unsigned char trans_bg = 0;
int index_image_width, index_image_height;
- char *s;
gib_list *line, *lines;
if (opt.montage) {
@@ -164,15 +163,9 @@ void init_index_mode(void)
gib_imlib_image_fill_rectangle(im_main, 0, 0, w, h + title_area_h, 0, 0, 0, 255);
}
- /* Create the window title at this point */
-
- if (!opt.title)
- s = estrdup(PACKAGE " [index mode]");
- else
- s = estrdup(feh_printf(opt.title, NULL, NULL));
-
if (opt.display) {
- winwid = winwidget_create_from_image(im_main, s, WIN_TYPE_SINGLE);
+ winwid = winwidget_create_from_image(im_main, WIN_TYPE_SINGLE);
+ winwidget_rename(winwid, PACKAGE " [index mode]");
winwidget_show(winwid);
}
@@ -348,7 +341,6 @@ void init_index_mode(void)
if (!opt.display)
gib_imlib_free_image_and_decache(im_main);
- free(s);
return;
}
diff --git a/src/list.c b/src/list.c
index 6f317c4..09b23f4 100644
--- a/src/list.c
+++ b/src/list.c
@@ -92,6 +92,7 @@ void real_loadables_mode(int loadable)
if (opt.verbose)
feh_display_status('.');
puts(file->filename);
+ fflush(stdout);
feh_action_run(file, opt.actions[0], NULL);
}
else {
@@ -106,6 +107,7 @@ void real_loadables_mode(int loadable)
if (opt.verbose)
feh_display_status('.');
puts(file->filename);
+ fflush(stdout);
feh_action_run(file, opt.actions[0], NULL);
}
else {
diff --git a/src/multiwindow.c b/src/multiwindow.c
index 13cff90..abbf6c9 100644
--- a/src/multiwindow.c
+++ b/src/multiwindow.c
@@ -34,25 +34,14 @@ void init_multiwindow_mode(void)
{
winwidget w = NULL;
gib_list *l;
- feh_file *file = NULL;
+
+ if (!opt.title)
+ opt.title = PACKAGE " - %f";
mode = "multiwindow";
for (l = filelist; l; l = l->next) {
- char *s = NULL;
- int len = 0;
- file = FEH_FILE(l->data);
- current_file = l;
-
- if (!opt.title) {
- len = strlen(PACKAGE " - ") + strlen(file->filename) + 1;
- s = emalloc(len);
- snprintf(s, len, PACKAGE " - %s", file->filename);
- } else {
- s = estrdup(feh_printf(opt.title, file, w));
- }
-
- if ((w = winwidget_create_from_file(l, s, WIN_TYPE_SINGLE)) != NULL) {
+ if ((w = winwidget_create_from_file(l, WIN_TYPE_SINGLE)) != NULL) {
winwidget_show(w);
if (opt.reload > 0)
feh_add_unique_timer(cb_reload_timer, w, opt.reload);
@@ -62,7 +51,6 @@ void init_multiwindow_mode(void)
D(("EEEK. Couldn't load image in multiwindow mode. "
"I 'm not sure if this is a problem\n"));
}
- free(s);
}
return;
diff --git a/src/options.c b/src/options.c
index c874832..3d11482 100644
--- a/src/options.c
+++ b/src/options.c
@@ -24,10 +24,11 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
+#include <strings.h>
+
#include "feh.h"
#include "filelist.h"
#include "options.h"
-#include <strings.h>
static void check_options(void);
static void feh_getopt_theme(int argc, char **argv);
@@ -213,7 +214,7 @@ static void feh_parse_options_from_string(char *opts)
char *s;
char *t;
char last = 0;
- int inquote = 0;
+ char inquote = 0;
int i = 0;
/* So we don't reinvent the wheel (not again, anyway), we use the
@@ -228,7 +229,7 @@ static void feh_parse_options_from_string(char *opts)
eprintf(PACKAGE " does not support more than 64 words per "
"theme definition.\n Please shorten your lines.");
- if ((*t == ' ') && !(inquote)) {
+ if ((*t == ' ') && !inquote) {
*t = '\0';
num++;
@@ -239,8 +240,10 @@ static void feh_parse_options_from_string(char *opts)
list[num - 1] = feh_string_normalize(s);
break;
- } else if (((*t == '\"') || (*t == '\'')) && last != '\\')
- inquote = !(inquote);
+ } else if ((*t == inquote) && (last != '\\')) {
+ inquote = 0;
+ } else if (((*t == '\"') || (*t == '\'')) && (last != '\\') && !inquote)
+ inquote = *t;
last = *t;
}
@@ -412,6 +415,7 @@ static void feh_parse_option_array(int argc, char **argv, int finalrun)
{"insecure" , 0, 0, 240},
{"no-recursive" , 0, 0, 241},
{"cache-size" , 1, 0, 243},
+ {"version-sort" , 0, 0, 246},
{0, 0, 0, 0}
};
int optch = 0, cmdx = 0;
@@ -430,6 +434,7 @@ static void feh_parse_option_array(int argc, char **argv, int finalrun)
opt.debug = 1;
break;
case '<':
+ opt.filter_by_dimensions = 1;
XParseGeometry(optarg, &discard, &discard, &opt.max_width, &opt.max_height);
if (opt.max_width == 0)
opt.max_width = UINT_MAX;
@@ -437,6 +442,7 @@ static void feh_parse_option_array(int argc, char **argv, int finalrun)
opt.max_height = UINT_MAX;
break;
case '>':
+ opt.filter_by_dimensions = 1;
XParseGeometry(optarg, &discard, &discard, &opt.min_width, &opt.min_height);
break;
case '.':
@@ -449,14 +455,7 @@ static void feh_parse_option_array(int argc, char **argv, int finalrun)
opt.actions[0] = estrdup(optarg);
break;
case 'B':
- if (!strcmp(optarg, "checks"))
- opt.image_bg = IMAGE_BG_CHECKS;
- else if (!strcmp(optarg, "white"))
- opt.image_bg = IMAGE_BG_WHITE;
- else if (!strcmp(optarg, "black"))
- opt.image_bg = IMAGE_BG_BLACK;
- else
- weprintf("Unknown argument to --image-bg: %s", optarg);
+ opt.image_bg = estrdup(optarg);
break;
case 'C':
D(("adding fontpath %s\n", optarg));
@@ -782,6 +781,9 @@ static void feh_parse_option_array(int argc, char **argv, int finalrun)
if (opt.cache_size > 2048)
opt.cache_size = 2048;
break;
+ case 246:
+ opt.version_sort = 1;
+ break;
default:
break;
}
diff --git a/src/options.h b/src/options.h
index c6959c8..c6b4e0e 100644
--- a/src/options.h
+++ b/src/options.h
@@ -71,14 +71,15 @@ struct __fehoptions {
unsigned char cycle_once;
unsigned char hold_actions[10];
unsigned char text_bg;
- unsigned char image_bg;
unsigned char no_fehbg;
unsigned char keep_zoom_vp;
unsigned char insecure_ssl;
+ unsigned char filter_by_dimensions;
char *output_file;
char *output_dir;
char *bg_file;
+ char *image_bg;
char *font;
char *title_font;
char *title;
@@ -103,6 +104,7 @@ struct __fehoptions {
unsigned int thumb_redraw;
double reload;
int sort;
+ int version_sort;
int debug;
int geom_flags;
int geom_x;
diff --git a/src/slideshow.c b/src/slideshow.c
index 4e58596..effdcaf 100644
--- a/src/slideshow.c
+++ b/src/slideshow.c
@@ -35,9 +35,7 @@ void init_slideshow_mode(void)
{
winwidget w = NULL;
int success = 0;
- char *s = NULL;
gib_list *l = filelist, *last = NULL;
- feh_file *file = NULL;
for (; l && opt.start_list_at; l = l->next) {
if (!strcmp(opt.start_list_at, FEH_FILE(l->data)->filename)) {
@@ -50,17 +48,17 @@ void init_slideshow_mode(void)
eprintf("--start-at %s: File not found in filelist",
opt.start_list_at);
+ if (!opt.title)
+ opt.title = PACKAGE " [%u of %l] - %f";
+
mode = "slideshow";
for (; l; l = l->next) {
- file = FEH_FILE(l->data);
if (last) {
filelist = feh_file_remove_from_list(filelist, last);
last = NULL;
}
current_file = l;
- s = slideshow_create_name(file, NULL);
- if ((w = winwidget_create_from_file(l, s, WIN_TYPE_SLIDESHOW)) != NULL) {
- free(s);
+ if ((w = winwidget_create_from_file(l, WIN_TYPE_SLIDESHOW)) != NULL) {
success = 1;
winwidget_show(w);
if (opt.slideshow_delay > 0.0)
@@ -69,7 +67,6 @@ void init_slideshow_mode(void)
feh_add_unique_timer(cb_reload_timer, w, opt.reload);
break;
} else {
- free(s);
last = l;
}
}
@@ -134,13 +131,6 @@ void cb_reload_timer(void *data)
current_file = filelist;
w->file = current_file;
- /* reset window name in case of current file order,
- * filename, or filelist_length has changed.
- */
- current_filename = slideshow_create_name(FEH_FILE(current_file->data), w);
- winwidget_rename(w, current_filename);
- free(current_filename);
-
feh_reload_image(w, 1, 0);
feh_add_unique_timer(cb_reload_timer, w, opt.reload);
return;
@@ -148,7 +138,7 @@ void cb_reload_timer(void *data)
void feh_reload_image(winwidget w, int resize, int force_new)
{
- char *title, *new_title;
+ char *new_title;
int len;
Imlib_Image tmp;
int old_w, old_h;
@@ -177,8 +167,8 @@ void feh_reload_image(winwidget w, int resize, int force_new)
len = strlen(w->name) + sizeof("Reloading: ") + 1;
new_title = emalloc(len);
snprintf(new_title, len, "Reloading: %s", w->name);
- title = estrdup(w->name);
winwidget_rename(w, new_title);
+ free(new_title);
old_w = gib_imlib_image_get_width(w->im);
old_h = gib_imlib_image_get_height(w->im);
@@ -199,9 +189,6 @@ void feh_reload_image(winwidget w, int resize, int force_new)
im_weprintf(w, "Couldn't reload image. Is it still there?");
winwidget_render_image(w, 0, 0);
}
- winwidget_rename(w, title);
- free(title);
- free(new_title);
return;
}
@@ -241,10 +228,6 @@ void feh_reload_image(winwidget w, int resize, int force_new)
winwidget_render_image(w, resize, 0);
}
- winwidget_rename(w, title);
- free(title);
- free(new_title);
-
return;
}
@@ -257,7 +240,6 @@ void slideshow_change_image(winwidget winwid, int change, int render)
* encounter invalid images.
*/
int our_filelist_len = filelist_len;
- char *s;
unsigned char tmode =0;
int tim_x =0;
@@ -382,16 +364,20 @@ void slideshow_change_image(winwidget winwid, int change, int render)
tzoom = winwid->zoom;
}
- if ((winwidget_loadimage(winwid, FEH_FILE(current_file->data)))
- != 0) {
+ 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);
+ if (feh_should_ignore_image(winwid->im)) {
+ last = current_file;
+ continue;
+ }
winwid->mode = MODE_NORMAL;
winwid->file = current_file;
- if ((winwid->im_w != gib_imlib_image_get_width(winwid->im))
- || (winwid->im_h != gib_imlib_image_get_height(winwid->im)))
+ if ((winwid->im_w != w) || (winwid->im_h != h))
winwid->had_resize = 1;
winwidget_reset_image(winwid);
- winwid->im_w = gib_imlib_image_get_width(winwid->im);
- winwid->im_h = gib_imlib_image_get_height(winwid->im);
+ winwid->im_w = w;
+ winwid->im_h = h;
if (opt.keep_zoom_vp) {
/* put back in: */
winwid->mode = tmode;
@@ -406,11 +392,6 @@ void slideshow_change_image(winwidget winwid, int change, int render)
winwidget_render_image(winwid, 1, 0);
}
}
-
- s = slideshow_create_name(FEH_FILE(current_file->data), winwid);
- winwidget_rename(winwid, s);
- free(s);
-
break;
} else
last = current_file;
@@ -437,23 +418,6 @@ void slideshow_pause_toggle(winwidget w)
winwidget_rename(w, NULL);
}
-char *slideshow_create_name(feh_file * file, winwidget winwid)
-{
- char *s = NULL;
- int len = 0;
-
- if (!opt.title) {
- len = strlen(PACKAGE " [slideshow mode] - ") + strlen(file->filename) + 1;
- s = emalloc(len);
- snprintf(s, len, PACKAGE " [%d of %d] - %s",
- gib_list_num(filelist, current_file) + 1, gib_list_length(filelist), file->filename);
- } else {
- s = estrdup(feh_printf(opt.title, file, winwid));
- }
-
- return(s);
-}
-
void feh_action_run(feh_file * file, char *action, winwidget winwid)
{
if (action) {
@@ -490,6 +454,7 @@ char *feh_printf(char *str, feh_file * file, winwidget winwid)
ret[0] = '\0';
filelist_tmppath = NULL;
+ gib_list *f;
for (c = str; *c != '\0'; c++) {
if ((*c == '%') && (*(c+1) != '\0')) {
@@ -574,9 +539,8 @@ char *feh_printf(char *str, feh_file * file, winwidget winwid)
}
break;
case 'u':
- snprintf(buf, sizeof(buf), "%d",
- current_file != NULL ? gib_list_num(filelist, current_file)
- + 1 : 0);
+ f = current_file ? current_file : gib_list_find_by_data(filelist, file);
+ snprintf(buf, sizeof(buf), "%d", f ? gib_list_num(filelist, f) + 1 : 0);
strncat(ret, buf, sizeof(ret) - strlen(ret) - 1);
break;
case 'v':
@@ -630,7 +594,6 @@ char *feh_printf(char *str, feh_file * file, winwidget winwid)
void feh_filelist_image_remove(winwidget winwid, char do_delete)
{
if (winwid->type == WIN_TYPE_SLIDESHOW) {
- char *s;
gib_list *doomed;
doomed = current_file;
@@ -657,9 +620,6 @@ void feh_filelist_image_remove(winwidget winwid, char do_delete)
winwidget_destroy(winwid);
return;
}
- s = slideshow_create_name(FEH_FILE(winwid->file->data), winwid);
- winwidget_rename(winwid, s);
- free(s);
winwidget_render_image(winwid, 1, 0);
} else if ((winwid->type == WIN_TYPE_SINGLE)
|| (winwid->type == WIN_TYPE_THUMBNAIL_VIEWER)) {
diff --git a/src/thumbnail.c b/src/thumbnail.c
index edf0f4f..003c7b4 100644
--- a/src/thumbnail.c
+++ b/src/thumbnail.c
@@ -71,7 +71,6 @@ void init_thumbnail_mode(void)
gib_list *l, *last = NULL;
int lineno;
int index_image_width, index_image_height;
- char *s;
unsigned int thumb_counter = 0;
gib_list *line, *lines;
@@ -92,6 +91,9 @@ void init_thumbnail_mode(void)
td.vertical = 0;
td.max_column_w = 0;
+ if (!opt.thumb_title)
+ opt.thumb_title = "%n";
+
mode = "thumbnail";
if (opt.font)
@@ -168,15 +170,9 @@ void init_thumbnail_mode(void)
td.h + title_area_h, 0, 0, 0, 255);
}
- /* Create title now */
-
- if (!opt.title)
- s = estrdup(PACKAGE " [thumbnail mode]");
- else
- s = estrdup(feh_printf(opt.title, NULL, NULL));
-
if (opt.display) {
- winwid = winwidget_create_from_image(td.im_main, s, WIN_TYPE_THUMBNAIL);
+ winwid = winwidget_create_from_image(td.im_main, WIN_TYPE_THUMBNAIL);
+ winwidget_rename(winwid, PACKAGE " [thumbnail mode]");
winwidget_show(winwid);
}
@@ -415,8 +411,6 @@ void init_thumbnail_mode(void)
}
}
-
- free(s);
return;
}
@@ -772,24 +766,17 @@ int feh_thumbnail_get_generated(Imlib_Image * image, feh_file * file,
void feh_thumbnail_show_fullsize(feh_file *thumbfile)
{
winwidget thumbwin = NULL;
- char *s;
- if (!opt.thumb_title)
- s = thumbfile->name;
- else
- s = feh_printf(opt.thumb_title, thumbfile, NULL);
-
thumbwin = winwidget_get_first_window_of_type(WIN_TYPE_THUMBNAIL_VIEWER);
if (!thumbwin) {
thumbwin = winwidget_create_from_file(
gib_list_add_front(NULL, thumbfile),
- s, WIN_TYPE_THUMBNAIL_VIEWER);
+ 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);
- winwidget_rename(thumbwin, s);
feh_reload_image(thumbwin, 1, 1);
}
}
@@ -925,16 +912,3 @@ int feh_thumbnail_setup_thumbnail_dir(void)
return status;
}
-
-char *thumbnail_create_name(feh_file * file, winwidget winwid)
-{
- char *s = NULL;
-
- if (!opt.thumb_title) {
- s = estrdup(file->filename);
- } else {
- s = estrdup(feh_printf(opt.thumb_title, file, winwid));
- }
-
- return(s);
-}
diff --git a/src/wallpaper.c b/src/wallpaper.c
index c9a3a05..758a81a 100644
--- a/src/wallpaper.c
+++ b/src/wallpaper.c
@@ -24,12 +24,14 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
+#include <limits.h>
+#include <sys/stat.h>
+
#include "feh.h"
#include "filelist.h"
#include "options.h"
#include "wallpaper.h"
-#include <limits.h>
-#include <sys/stat.h>
+
Window ipc_win = None;
Window my_ipc_win = None;
Atom ipc_atom = None;
@@ -89,7 +91,7 @@ static void feh_wm_set_bg_scaled(Pixmap pmap, Imlib_Image im, int use_filelist,
feh_wm_load_next(&im);
gib_imlib_render_image_on_drawable_at_size(pmap, im, x, y, w, h,
- 1, 0, !opt.force_aliasing);
+ 1, 1, !opt.force_aliasing);
if (use_filelist)
gib_imlib_free_image_and_decache(im);
@@ -130,7 +132,7 @@ static void feh_wm_set_bg_centered(Pixmap pmap, Imlib_Image im, int use_filelist
y + ((offset_y > 0) ? offset_y : 0),
w,
h,
- 1, 0, 0);
+ 1, 1, 0);
if (use_filelist)
gib_imlib_free_image_and_decache(im);
@@ -210,7 +212,7 @@ static void feh_wm_set_bg_maxed(Pixmap pmap, Imlib_Image im, int use_filelist,
gib_imlib_render_image_on_drawable_at_size(pmap, im,
render_x, render_y,
render_w, render_h,
- 1, 0, !opt.force_aliasing);
+ 1, 1, !opt.force_aliasing);
if (use_filelist)
gib_imlib_free_image_and_decache(im);
@@ -305,15 +307,19 @@ void feh_wm_set_bg(char *fil, Imlib_Image im, int centered, int scaled,
D(("Falling back to XSetRootWindowPixmap\n"));
+ XColor color;
+ Colormap cmap = DefaultColormap(disp, DefaultScreen(disp));
+ if (opt.image_bg)
+ XAllocNamedColor(disp, cmap, (char*) opt.image_bg, &color, &color);
+ else
+ XAllocNamedColor(disp, cmap, "black", &color, &color);
+
if (scaled) {
pmap_d1 = XCreatePixmap(disp, root, scr->width, scr->height, depth);
#ifdef HAVE_LIBXINERAMA
if (opt.xinerama_index >= 0) {
- if (opt.image_bg == IMAGE_BG_WHITE)
- gcval.foreground = WhitePixel(disp, DefaultScreen(disp));
- else
- gcval.foreground = BlackPixel(disp, DefaultScreen(disp));
+ gcval.foreground = color.pixel;
gc = XCreateGC(disp, root, GCForeground, &gcval);
XFillRectangle(disp, pmap_d1, gc, 0, 0, scr->width, scr->height);
XFreeGC(disp, gc);
@@ -337,10 +343,7 @@ void feh_wm_set_bg(char *fil, Imlib_Image im, int centered, int scaled,
D(("centering\n"));
pmap_d1 = XCreatePixmap(disp, root, scr->width, scr->height, depth);
- if (opt.image_bg == IMAGE_BG_WHITE)
- gcval.foreground = WhitePixel(disp, DefaultScreen(disp));
- else
- gcval.foreground = BlackPixel(disp, DefaultScreen(disp));
+ gcval.foreground = color.pixel;
gc = XCreateGC(disp, root, GCForeground, &gcval);
XFillRectangle(disp, pmap_d1, gc, 0, 0, scr->width, scr->height);
@@ -367,10 +370,7 @@ void feh_wm_set_bg(char *fil, Imlib_Image im, int centered, int scaled,
#ifdef HAVE_LIBXINERAMA
if (opt.xinerama_index >= 0) {
- if (opt.image_bg == IMAGE_BG_WHITE)
- gcval.foreground = WhitePixel(disp, DefaultScreen(disp));
- else
- gcval.foreground = BlackPixel(disp, DefaultScreen(disp));
+ gcval.foreground = color.pixel;
gc = XCreateGC(disp, root, GCForeground, &gcval);
XFillRectangle(disp, pmap_d1, gc, 0, 0, scr->width, scr->height);
XFreeGC(disp, gc);
@@ -393,10 +393,7 @@ void feh_wm_set_bg(char *fil, Imlib_Image im, int centered, int scaled,
} else if (filled == 2) {
pmap_d1 = XCreatePixmap(disp, root, scr->width, scr->height, depth);
- if (opt.image_bg == IMAGE_BG_WHITE)
- gcval.foreground = WhitePixel(disp, DefaultScreen(disp));
- else
- gcval.foreground = BlackPixel(disp, DefaultScreen(disp));
+ gcval.foreground = color.pixel;
gc = XCreateGC(disp, root, GCForeground, &gcval);
XFillRectangle(disp, pmap_d1, gc, 0, 0, scr->width, scr->height);
@@ -423,7 +420,7 @@ void feh_wm_set_bg(char *fil, Imlib_Image im, int centered, int scaled,
w = gib_imlib_image_get_width(im);
h = gib_imlib_image_get_height(im);
pmap_d1 = XCreatePixmap(disp, root, w, h, depth);
- gib_imlib_render_image_on_drawable(pmap_d1, im, 0, 0, 1, 0, 0);
+ gib_imlib_render_image_on_drawable(pmap_d1, im, 0, 0, 1, 1, 0);
}
if (!opt.no_fehbg) {
@@ -472,7 +469,7 @@ void feh_wm_set_bg(char *fil, Imlib_Image im, int centered, int scaled,
free(path);
}
}
-
+
/* create new display, copy pixmap to new display */
disp2 = XOpenDisplay(NULL);
if (!disp2)
diff --git a/src/winwidget.c b/src/winwidget.c
index d636a85..bb6181a 100644
--- a/src/winwidget.c
+++ b/src/winwidget.c
@@ -81,7 +81,7 @@ static winwidget winwidget_allocate(void)
return(ret);
}
-winwidget winwidget_create_from_image(Imlib_Image im, char *name, char type)
+winwidget winwidget_create_from_image(Imlib_Image im, char type)
{
winwidget ret = NULL;
@@ -95,11 +95,6 @@ winwidget winwidget_create_from_image(Imlib_Image im, char *name, char type)
ret->w = ret->im_w = gib_imlib_image_get_width(ret->im);
ret->h = ret->im_h = gib_imlib_image_get_height(ret->im);
- if (name)
- ret->name = estrdup(name);
- else
- ret->name = estrdup(PACKAGE);
-
if (opt.full_screen && (type != WIN_TYPE_THUMBNAIL))
ret->full_screen = True;
winwidget_create_window(ret, ret->w, ret->h);
@@ -108,7 +103,7 @@ winwidget winwidget_create_from_image(Imlib_Image im, char *name, char type)
return(ret);
}
-winwidget winwidget_create_from_file(gib_list * list, char *name, char type)
+winwidget winwidget_create_from_file(gib_list * list, char type)
{
winwidget ret = NULL;
feh_file *file = FEH_FILE(list->data);
@@ -119,12 +114,8 @@ winwidget winwidget_create_from_file(gib_list * list, char *name, char type)
ret = winwidget_allocate();
ret->file = list;
ret->type = type;
- if (name)
- ret->name = estrdup(name);
- else
- ret->name = estrdup(file->filename);
- if (winwidget_loadimage(ret, file) == 0) {
+ if ((winwidget_loadimage(ret, file) == 0) || feh_should_ignore_image(ret->im)) {
winwidget_destroy(ret);
return(NULL);
}
@@ -391,17 +382,18 @@ void winwidget_setup_pixmaps(winwidget winwid)
if (winwid->gc == None) {
XGCValues gcval;
- if (opt.image_bg == IMAGE_BG_WHITE) {
- gcval.foreground = WhitePixel(disp, DefaultScreen(disp));
+ if (!opt.image_bg || !strcmp(opt.image_bg, "default")) {
+ gcval.foreground = BlackPixel(disp, DefaultScreen(disp));
winwid->gc = XCreateGC(disp, winwid->win, GCForeground, &gcval);
- }
- else if (opt.image_bg == IMAGE_BG_CHECKS) {
+ } else if (!strcmp(opt.image_bg, "checks")) {
gcval.tile = feh_create_checks();
gcval.fill_style = FillTiled;
winwid->gc = XCreateGC(disp, winwid->win, GCTile | GCFillStyle, &gcval);
- }
- else {
- gcval.foreground = BlackPixel(disp, DefaultScreen(disp));
+ } else {
+ XColor color;
+ Colormap cmap = DefaultColormap(disp, DefaultScreen(disp));
+ XAllocNamedColor(disp, cmap, (char*) opt.image_bg, &color, &color);
+ gcval.foreground = color.pixel;
winwid->gc = XCreateGC(disp, winwid->win, GCForeground, &gcval);
}
}
@@ -632,16 +624,12 @@ void winwidget_render_image(winwidget winwid, int resize, int force_alias)
feh_draw_info(winwid);
if (winwid->errstr)
feh_draw_errstr(winwid);
- if (opt.title && (winwid->type != WIN_TYPE_THUMBNAIL_VIEWER) &&
- (winwid->file != NULL)) {
- char *s = slideshow_create_name(FEH_FILE(winwid->file->data), winwid);
- winwidget_rename(winwid, s);
- free(s);
- } else if (opt.thumb_title && (winwid->type == WIN_TYPE_THUMBNAIL_VIEWER) &&
- (winwid->file != NULL)) {
- char *s = thumbnail_create_name(FEH_FILE(winwid->file->data), winwid);
- winwidget_rename(winwid, s);
- free(s);
+ if (winwid->file != NULL) {
+ if (opt.title && winwid->type != WIN_TYPE_THUMBNAIL_VIEWER) {
+ winwidget_rename(winwid, feh_printf(opt.title, FEH_FILE(winwid->file->data), winwid));
+ } else if (opt.thumb_title && winwid->type == WIN_TYPE_THUMBNAIL_VIEWER) {
+ winwidget_rename(winwid, feh_printf(opt.thumb_title, FEH_FILE(winwid->file->data), winwid));
+ }
}
} else if ((opt.mode == MODE_ZOOM) && !antialias)
feh_draw_zoom(winwid);
@@ -700,14 +688,15 @@ Pixmap feh_create_checks(void)
if (!checks)
eprintf("Unable to create a teeny weeny imlib image. I detect problems");
- if (opt.image_bg == IMAGE_BG_WHITE)
- gib_imlib_image_fill_rectangle(checks, 0, 0, 16, 16, 255, 255, 255, 255);
- else if (opt.image_bg == IMAGE_BG_BLACK)
- gib_imlib_image_fill_rectangle(checks, 0, 0, 16, 16, 0, 0, 0, 255);
- else {
+ if (!opt.image_bg || !strcmp(opt.image_bg, "default") || !strcmp(opt.image_bg, "checks")) {
gib_imlib_image_fill_rectangle(checks, 0, 0, 16, 16, 144, 144, 144, 255);
gib_imlib_image_fill_rectangle(checks, 0, 0, 8, 8, 100, 100, 100, 255);
gib_imlib_image_fill_rectangle(checks, 8, 8, 8, 8, 100, 100, 100, 255);
+ } else {
+ XColor color;
+ Colormap cmap = DefaultColormap(disp, DefaultScreen(disp));
+ XAllocNamedColor(disp, cmap, (char*) opt.image_bg, &color, &color);
+ gib_imlib_image_fill_rectangle(checks, 0, 0, 16, 16, color.red, color.green, color.blue, 255);
}
checks_pmap = XCreatePixmap(disp, root, 16, 16, depth);
diff --git a/src/winwidget.h b/src/winwidget.h
index 6a794e7..dd8489a 100644
--- a/src/winwidget.h
+++ b/src/winwidget.h
@@ -141,8 +141,8 @@ void winwidget_get_geometry(winwidget winwid, int *rect);
int winwidget_get_width(winwidget winwid);
int winwidget_get_height(winwidget winwid);
winwidget winwidget_get_from_window(Window win);
-winwidget winwidget_create_from_file(gib_list * filename, char *name, char type);
-winwidget winwidget_create_from_image(Imlib_Image im, char *name, char type);
+winwidget winwidget_create_from_file(gib_list * filename, char type);
+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);