summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/feh.h2
-rw-r--r--src/filelist.c4
-rw-r--r--src/gib_imlib.c23
-rw-r--r--src/imlib.c30
-rw-r--r--src/index.c2
-rw-r--r--src/list.c2
-rw-r--r--src/options.c16
-rw-r--r--src/options.h1
-rw-r--r--src/slideshow.c2
-rw-r--r--src/thumbnail.c2
-rw-r--r--src/wallpaper.c104
-rw-r--r--src/winwidget.c4
12 files changed, 118 insertions, 74 deletions
diff --git a/src/feh.h b/src/feh.h
index a4c01f5..a2a586a 100644
--- a/src/feh.h
+++ b/src/feh.h
@@ -162,8 +162,6 @@ void feh_reload_image(winwidget w, int resize, int force_new);
void feh_filelist_image_remove(winwidget winwid, char do_delete);
void feh_imlib_print_load_error(char *file, winwidget w, Imlib_Load_Error err);
void slideshow_save_image(winwidget win);
-void ungib_imlib_save_image_with_error_return(Imlib_Image im, char *file,
- Imlib_Load_Error * error_return);
void feh_edit_inplace(winwidget w, int orientation);
void feh_edit_inplace_lossless(winwidget w, int orientation);
gib_list *feh_wrap_string(char *text, int wrap_width, Imlib_Font fn, gib_style * style);
diff --git a/src/filelist.c b/src/filelist.c
index f31f05b..eaef54b 100644
--- a/src/filelist.c
+++ b/src/filelist.c
@@ -332,8 +332,10 @@ gib_list *feh_file_info_preload(gib_list * list)
feh_display_status(0);
if (remove_list) {
- for (l = remove_list; l; l = l->next)
+ for (l = remove_list; l; l = l->next) {
+ feh_file_free(FEH_FILE(((gib_list *) l->data)->data));
filelist = list = gib_list_remove(list, (gib_list *) l->data);
+ }
gib_list_free(remove_list);
}
diff --git a/src/gib_imlib.c b/src/gib_imlib.c
index b53b1cc..8f401aa 100644
--- a/src/gib_imlib.c
+++ b/src/gib_imlib.c
@@ -527,13 +527,22 @@ void
gib_imlib_save_image_with_error_return(Imlib_Image im, char *file,
Imlib_Load_Error * error_return)
{
- char *tmp;
-
- imlib_context_set_image(im);
- tmp = strrchr(file, '.');
- if (tmp)
- imlib_image_set_format(tmp + 1);
- imlib_save_image_with_error_return(file, error_return);
+ char *tmp;
+
+ imlib_context_set_image(im);
+ tmp = strrchr(file, '.');
+ if (tmp) {
+ char *p, *pp;
+ p = estrdup(tmp + 1);
+ pp = p;
+ while(*pp) {
+ *pp = tolower(*pp);
+ pp++;
+ }
+ imlib_image_set_format(p);
+ free(p);
+ }
+ imlib_save_image_with_error_return(file, error_return);
}
void
diff --git a/src/imlib.c b/src/imlib.c
index 36c8dff..10ab718 100644
--- a/src/imlib.c
+++ b/src/imlib.c
@@ -148,32 +148,6 @@ int feh_load_image_char(Imlib_Image * im, char *filename)
return(i);
}
-/*
- * XXX gib_imlib_save_image_with_error_return breaks with *.END and
- * similar because it tries to set the image format, which only works
- * with .end .
- * So we leave that part out.
- */
-void ungib_imlib_save_image_with_error_return(Imlib_Image im, char *file,
- Imlib_Load_Error * error_return)
-{
- char *tmp;
- imlib_context_set_image(im);
- tmp = strrchr(file, '.');
- if (tmp) {
- char *p, *pp;
- p = estrdup(tmp + 1);
- pp = p;
- while(*pp) {
- *pp = tolower(*pp);
- pp++;
- }
- imlib_image_set_format(p);
- free(p);
- }
- imlib_save_image_with_error_return(file, error_return);
-}
-
void feh_imlib_print_load_error(char *file, winwidget w, Imlib_Load_Error err)
{
if (err == IMLIB_LOAD_ERROR_OUT_OF_FILE_DESCRIPTORS)
@@ -566,6 +540,8 @@ void im_weprintf(winwidget w, char *fmt, ...)
if (fmt[0] != '\0' && fmt[strlen(fmt) - 1] == ':')
fprintf(stderr, " %s", strerror(errno));
fputs("\n", stderr);
+ if (!w)
+ free(errstr);
}
@@ -1053,7 +1029,7 @@ void feh_edit_inplace(winwidget w, int op)
imlib_image_flip_horizontal();
} else
gib_imlib_image_orientate(old, op);
- ungib_imlib_save_image_with_error_return(old,
+ gib_imlib_save_image_with_error_return(old,
FEH_FILE(w->file->data)->filename, &err);
gib_imlib_free_image(old);
if (err)
diff --git a/src/index.c b/src/index.c
index db2c9d2..a71744d 100644
--- a/src/index.c
+++ b/src/index.c
@@ -327,7 +327,7 @@ void init_index_mode(void)
else
strncpy(output_buf, opt.output_file, 1024);
- ungib_imlib_save_image_with_error_return(im_main, output_buf, &err);
+ gib_imlib_save_image_with_error_return(im_main, output_buf, &err);
if (err) {
feh_imlib_print_load_error(output_buf, im_main, err);
}
diff --git a/src/list.c b/src/list.c
index 53fdb36..fcb41ac 100644
--- a/src/list.c
+++ b/src/list.c
@@ -110,7 +110,7 @@ void real_loadables_mode(int loadable)
}
else {
if (opt.verbose)
- feh_display_status('.');
+ feh_display_status('s');
ret = 1;
}
}
diff --git a/src/options.c b/src/options.c
index 8fbdbfb..120541a 100644
--- a/src/options.c
+++ b/src/options.c
@@ -70,6 +70,7 @@ void init_parse_options(int argc, char **argv)
#ifdef HAVE_LIBXINERAMA
/* if we're using xinerama, then enable it by default */
opt.xinerama = 1;
+ opt.xinerama_index = -1;
#endif /* HAVE_LIBXINERAMA */
feh_getopt_theme(argc, argv);
@@ -236,7 +237,7 @@ static void feh_parse_options_from_string(char *opts)
list[num - 1] = feh_string_normalize(s);
break;
- } else if (*t == '\"' && last != '\\')
+ } else if (((*t == '\"') || (*t == '\'')) && last != '\\')
inquote = !(inquote);
last = *t;
}
@@ -265,6 +266,9 @@ char *feh_string_normalize(char *str)
else if ((*s == '\"') && (last == '\\'))
ret[i++] = '\"';
else if ((*s == '\"') && (last == 0));
+ else if ((*s == '\'') && (last == '\\'))
+ ret[i++] = '\'';
+ else if ((*s == '\'') && (last == 0));
else if ((*s == ' ') && (last == '\\'))
ret[i++] = ' ';
else
@@ -272,7 +276,7 @@ char *feh_string_normalize(char *str)
last = *s;
}
- if (i && (ret[i - 1] == '\"'))
+ if (i && ((ret[i - 1] == '\"') || (ret[i - 1] == '\'')))
ret[i - 1] = '\0';
else
ret[i] = '\0';
@@ -401,6 +405,7 @@ static void feh_parse_option_array(int argc, char **argv, int finalrun)
{"no-fehbg" , 0, 0, 236},
{"keep-zoom-vp" , 0, 0, 237},
{"scroll-step" , 1, 0, 238},
+ {"xinerama-index", 1, 0, 239},
{0, 0, 0, 0}
};
@@ -421,6 +426,10 @@ static void feh_parse_option_array(int argc, char **argv, int finalrun)
break;
case '<':
XParseGeometry(optarg, &discard, &discard, &opt.max_width, &opt.max_height);
+ if (opt.max_width == 0)
+ opt.max_width = UINT_MAX;
+ if (opt.max_height == 0)
+ opt.max_height = UINT_MAX;
break;
case '>':
XParseGeometry(optarg, &discard, &discard, &opt.min_width, &opt.min_height);
@@ -737,6 +746,9 @@ static void feh_parse_option_array(int argc, char **argv, int finalrun)
case 238:
opt.scroll_step = atoi(optarg);
break;
+ case 239:
+ opt.xinerama_index = atoi(optarg);
+ break;
default:
break;
}
diff --git a/src/options.h b/src/options.h
index a22cc05..923aa41 100644
--- a/src/options.h
+++ b/src/options.h
@@ -109,6 +109,7 @@ struct __fehoptions {
int default_zoom;
int zoom_mode;
unsigned char adjust_reload;
+ int xinerama_index;
/* signed in case someone wants to invert scrolling real quick */
int scroll_step;
diff --git a/src/slideshow.c b/src/slideshow.c
index 6c5d9c8..7636d31 100644
--- a/src/slideshow.c
+++ b/src/slideshow.c
@@ -669,7 +669,7 @@ void slideshow_save_image(winwidget win)
if (opt.verbose)
fprintf(stderr, "saving image to filename '%s'\n", tmpname);
- ungib_imlib_save_image_with_error_return(win->im, tmpname, &err);
+ gib_imlib_save_image_with_error_return(win->im, tmpname, &err);
if (err)
feh_imlib_print_load_error(tmpname, win, err);
diff --git a/src/thumbnail.c b/src/thumbnail.c
index 1719fdc..c806ce4 100644
--- a/src/thumbnail.c
+++ b/src/thumbnail.c
@@ -382,7 +382,7 @@ void init_thumbnail_mode(void)
snprintf(output_buf, 1024, "%s/%s", opt.output_dir, opt.output_file);
else
strncpy(output_buf, opt.output_file, 1024);
- ungib_imlib_save_image_with_error_return(td.im_main, output_buf, &err);
+ gib_imlib_save_image_with_error_return(td.im_main, output_buf, &err);
if (err) {
feh_imlib_print_load_error(output_buf, td.im_main, err);
}
diff --git a/src/wallpaper.c b/src/wallpaper.c
index 3e19c41..b6f2c0c 100644
--- a/src/wallpaper.c
+++ b/src/wallpaper.c
@@ -298,21 +298,30 @@ void feh_wm_set_bg(char *fil, Imlib_Image im, int centered, int scaled,
/* string for sticking in ~/.fehbg */
char *fehbg = NULL;
+ char fehbg_args[512];
+ fehbg_args[0] = '\0';
char *home;
char filbuf[4096];
- char fehbg_xinerama[] = "--no-xinerama";
char *bgfill = NULL;
bgfill = opt.image_bg == IMAGE_BG_WHITE ? "--image-bg white" : "--image-bg black" ;
+#ifdef HAVE_LIBXINERAMA
+ if (opt.xinerama) {
+ if (opt.xinerama_index >= 0) {
+ snprintf(fehbg_args, sizeof(fehbg_args),
+ "--xinerama-index %d", opt.xinerama_index);
+ }
+ }
+ else
+ snprintf(fehbg_args, sizeof(fehbg_args), "--no-xinerama");
+#endif /* HAVE_LIBXINERAMA */
+
/* local display to set closedownmode on */
Display *disp2;
Window root2;
int depth2;
int in, out, w, h;
- if (opt.xinerama)
- fehbg_xinerama[0] = '\0';
-
D(("Falling back to XSetRootWindowPixmap\n"));
/* Put the filename in filbuf between ' and escape ' in the filename */
@@ -357,16 +366,30 @@ void feh_wm_set_bg(char *fil, Imlib_Image im, int centered, int scaled,
pmap_d1 = XCreatePixmap(disp, root, scr->width, scr->height, depth);
#ifdef HAVE_LIBXINERAMA
- if (opt.xinerama && xinerama_screens)
- for (i = 0; i < num_xinerama_screens; i++)
- feh_wm_set_bg_scaled(pmap_d1, im, use_filelist,
- xinerama_screens[i].x_org, xinerama_screens[i].y_org,
- xinerama_screens[i].width, xinerama_screens[i].height);
+ 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));
+ gc = XCreateGC(disp, root, GCForeground, &gcval);
+ XFillRectangle(disp, pmap_d1, gc, 0, 0, scr->width, scr->height);
+ XFreeGC(disp, gc);
+ }
+
+ if (opt.xinerama && xinerama_screens) {
+ for (i = 0; i < num_xinerama_screens; i++) {
+ if (opt.xinerama_index < 0 || opt.xinerama_index == i) {
+ feh_wm_set_bg_scaled(pmap_d1, im, use_filelist,
+ xinerama_screens[i].x_org, xinerama_screens[i].y_org,
+ xinerama_screens[i].width, xinerama_screens[i].height);
+ }
+ }
+ }
else
#endif /* HAVE_LIBXINERAMA */
feh_wm_set_bg_scaled(pmap_d1, im, use_filelist,
0, 0, scr->width, scr->height);
- fehbg = estrjoin(" ", "feh", fehbg_xinerama, "--bg-scale", filbuf, NULL);
+ fehbg = estrjoin(" ", "feh", fehbg_args, "--bg-scale", filbuf, NULL);
} else if (centered) {
D(("centering\n"));
@@ -380,11 +403,15 @@ void feh_wm_set_bg(char *fil, Imlib_Image im, int centered, int scaled,
XFillRectangle(disp, pmap_d1, gc, 0, 0, scr->width, scr->height);
#ifdef HAVE_LIBXINERAMA
- if (opt.xinerama && xinerama_screens)
- for (i = 0; i < num_xinerama_screens; i++)
- feh_wm_set_bg_centered(pmap_d1, im, use_filelist,
- xinerama_screens[i].x_org, xinerama_screens[i].y_org,
- xinerama_screens[i].width, xinerama_screens[i].height);
+ if (opt.xinerama && xinerama_screens) {
+ for (i = 0; i < num_xinerama_screens; i++) {
+ if (opt.xinerama_index < 0 || opt.xinerama_index == i) {
+ feh_wm_set_bg_centered(pmap_d1, im, use_filelist,
+ xinerama_screens[i].x_org, xinerama_screens[i].y_org,
+ xinerama_screens[i].width, xinerama_screens[i].height);
+ }
+ }
+ }
else
#endif /* HAVE_LIBXINERAMA */
feh_wm_set_bg_centered(pmap_d1, im, use_filelist,
@@ -392,24 +419,38 @@ void feh_wm_set_bg(char *fil, Imlib_Image im, int centered, int scaled,
XFreeGC(disp, gc);
- fehbg = estrjoin(" ", "feh", fehbg_xinerama, bgfill, "--bg-center", filbuf, NULL);
+ fehbg = estrjoin(" ", "feh", fehbg_args, bgfill, "--bg-center", filbuf, NULL);
} else if (filled == 1) {
pmap_d1 = XCreatePixmap(disp, root, scr->width, scr->height, depth);
#ifdef HAVE_LIBXINERAMA
- if (opt.xinerama && xinerama_screens)
- for (i = 0; i < num_xinerama_screens; i++)
- feh_wm_set_bg_filled(pmap_d1, im, use_filelist,
- xinerama_screens[i].x_org, xinerama_screens[i].y_org,
- xinerama_screens[i].width, xinerama_screens[i].height);
+ 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));
+ gc = XCreateGC(disp, root, GCForeground, &gcval);
+ XFillRectangle(disp, pmap_d1, gc, 0, 0, scr->width, scr->height);
+ XFreeGC(disp, gc);
+ }
+
+ if (opt.xinerama && xinerama_screens) {
+ for (i = 0; i < num_xinerama_screens; i++) {
+ if (opt.xinerama_index < 0 || opt.xinerama_index == i) {
+ feh_wm_set_bg_filled(pmap_d1, im, use_filelist,
+ xinerama_screens[i].x_org, xinerama_screens[i].y_org,
+ xinerama_screens[i].width, xinerama_screens[i].height);
+ }
+ }
+ }
else
#endif /* HAVE_LIBXINERAMA */
feh_wm_set_bg_filled(pmap_d1, im, use_filelist
, 0, 0, scr->width, scr->height);
- fehbg = estrjoin(" ", "feh", fehbg_xinerama, "--bg-fill", filbuf, NULL);
+ fehbg = estrjoin(" ", "feh", fehbg_args, "--bg-fill", filbuf, NULL);
} else if (filled == 2) {
@@ -422,11 +463,15 @@ void feh_wm_set_bg(char *fil, Imlib_Image im, int centered, int scaled,
XFillRectangle(disp, pmap_d1, gc, 0, 0, scr->width, scr->height);
#ifdef HAVE_LIBXINERAMA
- if (opt.xinerama && xinerama_screens)
- for (i = 0; i < num_xinerama_screens; i++)
- feh_wm_set_bg_maxed(pmap_d1, im, use_filelist,
- xinerama_screens[i].x_org, xinerama_screens[i].y_org,
- xinerama_screens[i].width, xinerama_screens[i].height);
+ if (opt.xinerama && xinerama_screens) {
+ for (i = 0; i < num_xinerama_screens; i++) {
+ if (opt.xinerama_index < 0 || opt.xinerama_index == i) {
+ feh_wm_set_bg_maxed(pmap_d1, im, use_filelist,
+ xinerama_screens[i].x_org, xinerama_screens[i].y_org,
+ xinerama_screens[i].width, xinerama_screens[i].height);
+ }
+ }
+ }
else
#endif /* HAVE_LIBXINERAMA */
feh_wm_set_bg_maxed(pmap_d1, im, use_filelist,
@@ -434,7 +479,7 @@ void feh_wm_set_bg(char *fil, Imlib_Image im, int centered, int scaled,
XFreeGC(disp, gc);
- fehbg = estrjoin(" ", "feh", fehbg_xinerama, bgfill, "--bg-max", filbuf, NULL);
+ fehbg = estrjoin(" ", "feh", fehbg_args, bgfill, "--bg-max", filbuf, NULL);
} else {
if (use_filelist)
@@ -465,8 +510,9 @@ void feh_wm_set_bg(char *fil, Imlib_Image im, int centered, int scaled,
}
free(path);
}
- free(fehbg);
}
+
+ free(fehbg);
/* create new display, copy pixmap to new display */
disp2 = XOpenDisplay(NULL);
diff --git a/src/winwidget.c b/src/winwidget.c
index a1b78d3..65cefca 100644
--- a/src/winwidget.c
+++ b/src/winwidget.c
@@ -443,8 +443,8 @@ void winwidget_render_image(winwidget winwid, int resize, int force_alias)
feh_calc_needed_zoom(&(winwid->zoom), winwid->im_w, winwid->im_h, winwid->w, winwid->h);
- if (resize && !opt.scale_down && (winwid->full_screen
- || (opt.geom_flags & (WidthValue | HeightValue)))) {
+ if (resize && (winwid->full_screen
+ || (!opt.scale_down && (opt.geom_flags & (WidthValue | HeightValue))))) {
int smaller; /* Is the image smaller than screen? */
int max_w = 0, max_h = 0;