diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/events.c | 20 | ||||
-rw-r--r-- | src/feh.h | 3 | ||||
-rw-r--r-- | src/feh_png.c | 4 | ||||
-rw-r--r-- | src/filelist.c | 33 | ||||
-rw-r--r-- | src/filelist.h | 1 | ||||
-rw-r--r-- | src/help.raw | 2 | ||||
-rw-r--r-- | src/imlib.c | 38 | ||||
-rw-r--r-- | src/keyevents.c | 36 | ||||
-rw-r--r-- | src/menu.c | 10 | ||||
-rw-r--r-- | src/multiwindow.c | 4 | ||||
-rw-r--r-- | src/options.c | 26 | ||||
-rw-r--r-- | src/options.h | 2 | ||||
-rw-r--r-- | src/signals.c | 5 | ||||
-rw-r--r-- | src/slideshow.c | 41 | ||||
-rw-r--r-- | src/support.c | 173 | ||||
-rw-r--r-- | src/thumbnail.c | 4 | ||||
-rw-r--r-- | src/winwidget.c | 31 | ||||
-rw-r--r-- | src/winwidget.h | 5 |
18 files changed, 258 insertions, 180 deletions
diff --git a/src/events.c b/src/events.c index f2a1b3e..a850137 100644 --- a/src/events.c +++ b/src/events.c @@ -183,7 +183,7 @@ static void feh_event_handle_ButtonRelease(XEvent * ev) opt.mode = MODE_NORMAL; winwid->mode = MODE_NORMAL; winwidget_sanitise_offsets(winwid); - winwidget_render_image(winwid, 0, 1); + winwidget_render_image(winwid, 0, 0); } } else if (opt.mode == MODE_NEXT) { opt.mode = MODE_NORMAL; @@ -248,7 +248,7 @@ static void feh_event_handle_ButtonRelease(XEvent * ev) } else winwidget_sanitise_offsets(winwid); - winwidget_render_image(winwid, 0, 1); + winwidget_render_image(winwid, 0, 0); } } else if ((ev->xbutton.button == opt.blur_button) && ((opt.no_blur_ctrl_mask) @@ -281,7 +281,7 @@ static void feh_event_handle_ConfigureNotify(XEvent * ev) opt.geom_w = w->w; opt.geom_h = w->h; } - winwidget_render_image(w, 0, 1); + winwidget_render_image(w, 0, 0); } } } @@ -404,7 +404,7 @@ static void feh_event_handle_MotionNotify(XEvent * ev) winwid->im_y = winwid->click_offset_y - (winwid->im_click_offset_y * winwid->zoom); - winwidget_render_image(winwid, 0, 0); + winwidget_render_image(winwid, 0, 1); } } else if ((opt.mode == MODE_PAN) || (opt.mode == MODE_NEXT)) { int orig_x, orig_y; @@ -463,7 +463,7 @@ static void feh_event_handle_MotionNotify(XEvent * ev) if ((winwid->im_x != orig_x) || (winwid->im_y != orig_y)) - winwidget_render_image(winwid, 0, 0); + winwidget_render_image(winwid, 0, 1); } } else if (opt.mode == MODE_ROTATE) { while (XCheckTypedWindowEvent(disp, ev->xmotion.window, MotionNotify, ev)); @@ -483,7 +483,7 @@ static void feh_event_handle_MotionNotify(XEvent * ev) } winwid->im_angle = (ev->xmotion.x - winwid->w / 2) / ((double) winwid->w / 2) * 3.1415926535; D(("angle: %f\n", winwid->im_angle)); - winwidget_render_image(winwid, 0, 0); + winwidget_render_image(winwid, 0, 1); } } else if (opt.mode == MODE_BLUR) { while (XCheckTypedWindowEvent(disp, ev->xmotion.window, MotionNotify, ev)); @@ -503,7 +503,7 @@ static void feh_event_handle_MotionNotify(XEvent * ev) gib_imlib_image_blur(temp, 0 - blur_radius); ptr = winwid->im; winwid->im = temp; - winwidget_render_image(winwid, 0, 0); + winwidget_render_image(winwid, 0, 1); gib_imlib_free_image_and_decache(winwid->im); winwid->im = ptr; } @@ -522,7 +522,7 @@ static void feh_event_handle_MotionNotify(XEvent * ev) imlib_context_set_image(winwid->im); imlib_apply_filter("bump_map_point(x=[],y=[],map=" PREFIX "/share/feh/images/about.png);", &x, &y); - winwidget_render_image(winwid, 0, 1); + winwidget_render_image(winwid, 0, 0); gib_imlib_free_image_and_decache(winwid->im); winwid->im = orig_im; } else if (winwid->type == WIN_TYPE_THUMBNAIL) { @@ -553,11 +553,11 @@ static void feh_event_handle_MotionNotify(XEvent * ev) thumbnail->x + 2, thumbnail->y + 2, thumbnail->w - 4, thumbnail->h - 4, 255, 255, 255, 255); - winwidget_render_image(winwid, 0, 1); + winwidget_render_image(winwid, 0, 0); gib_imlib_free_image_and_decache(winwid->im); winwid->im = origwin; } else - winwidget_render_image(winwid, 0, 1); + winwidget_render_image(winwid, 0, 0); } last_thumb = thumbnail; } @@ -139,12 +139,11 @@ void feh_display_status(char stat); void real_loadables_mode(int loadable); void feh_reload_image(winwidget w, int resize, int force_new); void feh_filelist_image_remove(winwidget winwid, char do_delete); -char *feh_strip_hostname(char *url); void slideshow_save_image(winwidget win); void feh_edit_inplace_orient(winwidget w, int orientation); void feh_edit_inplace_lossless_rotate(winwidget w, int orientation); gib_list *feh_wrap_string(char *text, int wrap_width, Imlib_Font fn, gib_style * style); -char *build_caption_filename(feh_file * file); +char *build_caption_filename(feh_file * file, short create_dir); gib_list *feh_list_jump(gib_list * root, gib_list * l, int direction, int num); /* Imlib stuff */ diff --git a/src/feh_png.c b/src/feh_png.c index cefd4c8..f02aecb 100644 --- a/src/feh_png.c +++ b/src/feh_png.c @@ -66,7 +66,7 @@ gib_hash *feh_png_read_comments(char *file) return hash; } - if (setjmp(png_ptr->jmpbuf)) { + if (setjmp(png_jmpbuf(png_ptr))) { png_destroy_read_struct(&png_ptr, &info_ptr, NULL); fclose(fp); return hash; @@ -124,7 +124,7 @@ int feh_png_write_png(Imlib_Image image, char *file, ...) return 0; } - if (setjmp(png_ptr->jmpbuf)) { + if (setjmp(png_jmpbuf(png_ptr))) { fclose(fp); png_destroy_write_struct(&png_ptr, &info_ptr); png_destroy_info_struct(png_ptr, &info_ptr); diff --git a/src/filelist.c b/src/filelist.c index b4b481a..fa1735d 100644 --- a/src/filelist.c +++ b/src/filelist.c @@ -112,6 +112,11 @@ gib_list *feh_file_remove_from_list(gib_list * list, gib_list * l) return(gib_list_remove(list, l)); } +int file_selector_all(const struct dirent *unused __attribute__((unused))) +{ + return 1; +} + /* Recursive */ void add_file_to_filelist_recursively(char *origpath, unsigned char level) { @@ -176,8 +181,9 @@ void add_file_to_filelist_recursively(char *origpath, unsigned char level) } if ((S_ISDIR(st.st_mode)) && (level != FILELIST_LAST)) { - struct dirent *de; + struct dirent **de; DIR *dir; + int cnt, n; D(("It is a directory\n")); @@ -187,13 +193,25 @@ void add_file_to_filelist_recursively(char *origpath, unsigned char level) free(path); return; } - de = readdir(dir); - while (de != NULL) { - if (strcmp(de->d_name, ".") - && strcmp(de->d_name, "..")) { + n = scandir(path, &de, file_selector_all, alphasort); + if (n < 0) { + switch (errno) { + case ENOMEM: + if (!opt.quiet) + weprintf("Insufficient memory to scan directory %s:", path); + break; + default: + if (!opt.quiet) + weprintf("Failed to scan directory %s:", path); + } + } + + for (cnt = 0; cnt < n; cnt++) { + if (strcmp(de[cnt]->d_name, ".") + && strcmp(de[cnt]->d_name, "..")) { char *newfile; - newfile = estrjoin("", path, "/", de->d_name, NULL); + newfile = estrjoin("", path, "/", de[cnt]->d_name, NULL); /* This ensures we go down one level even if not fully recursive - this way "feh some_dir" expands to some_dir's contents */ @@ -203,9 +221,10 @@ void add_file_to_filelist_recursively(char *origpath, unsigned char level) add_file_to_filelist_recursively(newfile, FILELIST_LAST); free(newfile); + free(de[cnt]); } - de = readdir(dir); } + free(de); closedir(dir); } else if (S_ISREG(st.st_mode)) { D(("Adding regular file %s to filelist\n", path)); diff --git a/src/filelist.h b/src/filelist.h index 842e3af..617236f 100644 --- a/src/filelist.h +++ b/src/filelist.h @@ -60,6 +60,7 @@ void feh_file_free(feh_file * file); feh_file_info *feh_file_info_new(void); void feh_file_info_free(feh_file_info * info); gib_list *feh_file_rm_and_free(gib_list * list, gib_list * file); +int file_selector_all(const struct dirent *unused); void add_file_to_filelist_recursively(char *origpath, unsigned char level); void add_file_to_rm_filelist(char *file); void delete_rm_files(void); diff --git a/src/help.raw b/src/help.raw index eb57248..bbe5e37 100644 --- a/src/help.raw +++ b/src/help.raw @@ -49,6 +49,7 @@ OPTIONS Executed by /bin/sh, may contain FORMAT SPECIFIERS --action[1-9] Extra actions triggered by pressing keys <1>to <9> -G, --draw-actions Show the defined actions in the image window + --force-aliasing Disable antialiasing -m, --montage Enable montage mode -c, --collage Montage mode with randomly distributed thumbnails -i, --index Create an index print of all images @@ -76,7 +77,6 @@ OPTIONS -C, --fontpath PATH Specify an extra directory to look in for fonts, can be used multiple times to add multiple paths. -M, --menu-font FONT Use FONT for the font in menus. - -), --menu-bg BG Use BG for the background image in menus. -B, --image-bg STYLE Set background for transparent images and the like. Accepted values: white, black, default -N, --no-menus Don't load or show any menus. diff --git a/src/imlib.c b/src/imlib.c index 2460924..3f73a24 100644 --- a/src/imlib.c +++ b/src/imlib.c @@ -316,31 +316,6 @@ char *feh_http_load_image(char *url) #endif /* HAVE_LIBCURL */ -char *feh_strip_hostname(char *url) -{ - char *ret; - char *start; - char *finish; - int len; - - start = strchr(url, '/'); - if (!start) - return(NULL); - - start += 2; - - finish = strchr(start, '/'); - if (!finish) - return(NULL); - - len = finish - start; - - ret = emalloc(len + 1); - strncpy(ret, start, len); - ret[len] = '\0'; - return(ret); -} - void feh_draw_zoom(winwidget w) { static Imlib_Font fn = NULL; @@ -530,7 +505,7 @@ void feh_draw_info(winwidget w) return; } -char *build_caption_filename(feh_file * file) +char *build_caption_filename(feh_file * file, short create_dir) { char *caption_filename; char *s, *dir, *caption_dir; @@ -549,6 +524,8 @@ char *build_caption_filename(feh_file * file) D(("dir %s, cp %s, cdir %s\n", dir, opt.caption_path, caption_dir)) if (stat(caption_dir, &cdir_stat) == -1) { + if (!create_dir) + return NULL; if (mkdir(caption_dir, 0755) == -1) eprintf("Failed to create caption directory %s:", caption_dir); } else if (!S_ISDIR(cdir_stat.st_mode)) @@ -584,9 +561,12 @@ void feh_draw_caption(winwidget w) if (!file->caption) { char *caption_filename; - caption_filename = build_caption_filename(file); - /* read caption from file */ - file->caption = ereadfile(caption_filename); + caption_filename = build_caption_filename(file, 0); + if (caption_filename) + /* read caption from file */ + file->caption = ereadfile(caption_filename); + else + file->caption = estrdup(""); free(caption_filename); } diff --git a/src/keyevents.c b/src/keyevents.c index 8e2b181..e43ae33 100644 --- a/src/keyevents.c +++ b/src/keyevents.c @@ -125,6 +125,7 @@ void init_keyevents(void) { feh_set_kb(&keys.size_to_image, 0, XK_w , 0, 0 , 0, 0); feh_set_kb(&keys.render , 0, XK_KP_Begin , 0, 0 , 0, 0); feh_set_kb(&keys.toggle_actions, 0, XK_a, 0, 0, 0, 0); + feh_set_kb(&keys.toggle_aliasing, 0, XK_A, 0, 0, 0, 0); feh_set_kb(&keys.toggle_filenames, 0, XK_d, 0, 0, 0, 0); feh_set_kb(&keys.toggle_pointer, 0, XK_o, 0, 0, 0, 0); feh_set_kb(&keys.toggle_caption, 0, XK_c, 0, 0, 0, 0); @@ -245,6 +246,8 @@ void init_keyevents(void) { cur_kb = &keys.render; else if (!strcmp(action, "toggle_actions")) cur_kb = &keys.toggle_actions; + else if (!strcmp(action, "toggle_aliasing")) + cur_kb = &keys.toggle_aliasing; else if (!strcmp(action, "toggle_filenames")) cur_kb = &keys.toggle_filenames; else if (!strcmp(action, "toggle_pointer")) @@ -374,14 +377,15 @@ void feh_event_handle_keypress(XEvent * ev) /* finish caption entry, write to captions file */ FILE *fp; char *caption_filename; - caption_filename = build_caption_filename(FEH_FILE(winwid->file->data)); + caption_filename = + build_caption_filename(FEH_FILE(winwid->file->data), 1); winwid->caption_entry = 0; winwidget_render_image_cached(winwid); XFreePixmap(disp, winwid->bg_pmap_cache); winwid->bg_pmap_cache = 0; fp = fopen(caption_filename, "w"); if (!fp) { - weprintf("couldn't write to captions file %s:", caption_filename); + eprintf("couldn't write to captions file %s:", caption_filename); return; } fprintf(fp, "%s", FEH_FILE(winwid->file->data)->caption); @@ -424,19 +428,19 @@ void feh_event_handle_keypress(XEvent * ev) } else if (feh_is_kp(&keys.scroll_right, keysym, state)) { winwid->im_x -= 20; - winwidget_render_image(winwid, 0, 0); + winwidget_render_image(winwid, 0, 1); } else if (feh_is_kp(&keys.scroll_left, keysym, state)) { winwid->im_x += 20; - winwidget_render_image(winwid, 0, 0); + winwidget_render_image(winwid, 0, 1); } else if (feh_is_kp(&keys.scroll_down, keysym, state)) { winwid->im_y -= 20; - winwidget_render_image(winwid, 0, 0); + winwidget_render_image(winwid, 0, 1); } else if (feh_is_kp(&keys.scroll_up, keysym, state)) { winwid->im_y += 20; - winwidget_render_image(winwid, 0, 0); + winwidget_render_image(winwid, 0, 1); } else if (feh_is_kp(&keys.jump_back, keysym, state)) { if (opt.slideshow) @@ -505,7 +509,7 @@ void feh_event_handle_keypress(XEvent * ev) winwid->im_y = (winwid->h / 2) - (((winwid->h / 2) - winwid->im_y) / winwid->old_zoom * winwid->zoom); winwidget_sanitise_offsets(winwid); - winwidget_render_image(winwid, 0, 1); + winwidget_render_image(winwid, 0, 0); } else if (feh_is_kp(&keys.zoom_out, keysym, state)) { winwid->old_zoom = winwid->zoom; @@ -515,7 +519,7 @@ void feh_event_handle_keypress(XEvent * ev) winwid->im_y = (winwid->h / 2) - (((winwid->h / 2) - winwid->im_y) / winwid->old_zoom * winwid->zoom); winwidget_sanitise_offsets(winwid); - winwidget_render_image(winwid, 0, 1); + winwidget_render_image(winwid, 0, 0); } else if (feh_is_kp(&keys.zoom_default, keysym, state)) { winwid->zoom = 1; @@ -526,18 +530,22 @@ void feh_event_handle_keypress(XEvent * ev) else if (feh_is_kp(&keys.zoom_fit, keysym, state)) { feh_calc_needed_zoom(&winwid->zoom, winwid->im_w, winwid->im_h, winwid->w, winwid->h); winwidget_center_image(winwid); - winwidget_render_image(winwid, 0, 1); + winwidget_render_image(winwid, 0, 0); } else if (feh_is_kp(&keys.render, keysym, state)) { - winwidget_render_image(winwid, 0, 1); + winwidget_render_image(winwid, 0, 0); } else if (feh_is_kp(&keys.toggle_actions, keysym, state)) { opt.draw_actions = !opt.draw_actions; - winwidget_rerender_all(0, 1); + winwidget_rerender_all(0); + } + else if (feh_is_kp(&keys.toggle_aliasing, keysym, state)) { + opt.force_aliasing = !opt.force_aliasing; + winwidget_rerender_all(0); } else if (feh_is_kp(&keys.toggle_filenames, keysym, state)) { opt.draw_filename = !opt.draw_filename; - winwidget_rerender_all(0, 1); + winwidget_rerender_all(0); } else if (feh_is_kp(&keys.toggle_pointer, keysym, state)) { winwidget_set_pointer(winwid, opt.hide_pointer); @@ -549,7 +557,7 @@ void feh_event_handle_keypress(XEvent * ev) else if (feh_is_kp(&keys.toggle_caption, keysym, state)) { if (opt.caption_path) winwid->caption_entry = 1; - winwidget_render_image(winwid, 0, 1); + winwidget_render_image(winwid, 0, 0); } else if (feh_is_kp(&keys.reload_image, keysym, state)) { feh_reload_image(winwid, 0, 0); @@ -614,7 +622,7 @@ void feh_event_handle_keypress(XEvent * ev) winwid->full_screen = !winwid->full_screen; winwidget_destroy_xwin(winwid); winwidget_create_window(winwid, winwid->im_w, winwid->im_h); - winwidget_render_image(winwid, 1, 1); + winwidget_render_image(winwid, 1, 0); winwidget_show(winwid); #ifdef HAVE_LIBXINERAMA /* if we have xinerama and we're using it, then full screen the window @@ -1268,7 +1268,7 @@ void feh_menu_cb_opt_fullscreen(feh_menu * m, feh_menu_item * i) winwidget_destroy_xwin(m->fehwin); winwidget_create_window(m->fehwin, m->fehwin->im_w, m->fehwin->im_h); - winwidget_render_image(m->fehwin, 1, 1); + winwidget_render_image(m->fehwin, 1, 0); winwidget_show(m->fehwin); #ifdef HAVE_LIBXINERAMA @@ -1343,7 +1343,7 @@ void feh_menu_cb(feh_menu * m, feh_menu_item * i, int action, void *data) winwidget_resize(m->fehwin, m->fehwin->im_w, m->fehwin->im_h); } winwidget_reset_image(m->fehwin); - winwidget_render_image(m->fehwin, 1, 1); + winwidget_render_image(m->fehwin, 1, 0); break; case CB_RELOAD: feh_reload_image(m->fehwin, 0, 0); @@ -1404,7 +1404,7 @@ void feh_menu_cb(feh_menu * m, feh_menu_item * i, int action, void *data) opt.draw_filename = TRUE; else opt.draw_filename = FALSE; - winwidget_rerender_all(0, 1); + winwidget_rerender_all(0); break; case CB_OPT_DRAW_ACTIONS: MENU_ITEM_TOGGLE(i); @@ -1412,7 +1412,7 @@ void feh_menu_cb(feh_menu * m, feh_menu_item * i, int action, void *data) opt.draw_actions = TRUE; else opt.draw_actions = FALSE; - winwidget_rerender_all(0, 1); + winwidget_rerender_all(0); break; case CB_OPT_KEEP_HTTP: MENU_ITEM_TOGGLE(i); @@ -1440,7 +1440,7 @@ void feh_menu_cb(feh_menu * m, feh_menu_item * i, int action, void *data) opt.zoom_mode = ZOOM_MODE_FILL; else opt.zoom_mode = 0; - winwidget_rerender_all(1, 1); + winwidget_rerender_all(1); break; } return; diff --git a/src/multiwindow.c b/src/multiwindow.c index c46e453..1bd8a8a 100644 --- a/src/multiwindow.c +++ b/src/multiwindow.c @@ -28,6 +28,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include "timers.h" #include "filelist.h" #include "options.h" +#include "signals.h" void init_multiwindow_mode(void) { @@ -63,5 +64,8 @@ void init_multiwindow_mode(void) } free(s); } + + setup_signal_handlers(); + return; } diff --git a/src/options.c b/src/options.c index 3ba0512..de72429 100644 --- a/src/options.c +++ b/src/options.c @@ -30,8 +30,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. static void check_options(void); static void feh_getopt_theme(int argc, char **argv); -static void feh_parse_option_array(int argc, char **argv); -static void feh_parse_environment_options(void); +static void feh_parse_option_array(int argc, char **argv, int finalrun); static void feh_check_theme_options(int arg, char **argv); static void feh_parse_options_from_string(char *opts); static void feh_load_options_for_theme(char *theme); @@ -95,7 +94,7 @@ void init_parse_options(int argc, char **argv) D(("About to parse commandline options\n")); /* Parse the cmdline args */ - feh_parse_option_array(argc, argv); + feh_parse_option_array(argc, argv, 1); /* If we have a filelist to read, do it now */ if (opt.filelistfile) { @@ -167,8 +166,10 @@ static void feh_load_options_for_theme(char *theme) free(rcpath); if (!fp && ((fp = fopen(oldrcpath, "r")) != NULL)) - weprintf("the config is now read from .config/feh/themes, " - "please update your path!"); + weprintf("The theme config file was moved from ~/.fehrc to " + "~/.config/feh/themes. Run\n" + " mkdir -p ~/.config/feh; mv ~/.fehrc ~/.config/feh/themes\n" + "to fix this."); free(oldrcpath); @@ -257,7 +258,7 @@ static void feh_parse_options_from_string(char *opts) last = *t; } - feh_parse_option_array(num, list); + feh_parse_option_array(num, list, 0); for (i = 0; i < num; i++) if (list[i]) @@ -319,7 +320,7 @@ static void feh_getopt_theme(int argc, char **argv) optind = 0; } -static void feh_parse_option_array(int argc, char **argv) +static void feh_parse_option_array(int argc, char **argv, int finalrun) { static char stropts[] = "a:A:b:B:cC:dD:e:E:f:Fg:GhH:iIj:J:kK:lL:mM:nNo:O:pPqrR:sS:tT:uUvVwW:xXy:YzZ" @@ -422,6 +423,7 @@ static void feh_parse_option_array(int argc, char **argv) {"index-dim" , 1, 0, 232}, {"thumb-redraw" , 1, 0, 'J'}, {"info" , 1, 0, 234}, + {"force-aliasing", 0, 0, 235}, {0, 0, 0, 0} }; @@ -518,7 +520,7 @@ static void feh_parse_option_array(int argc, char **argv) opt.full_screen = 1; break; case 'Z': - opt.zoom_mode = ZOOM_MODE_FILL; + opt.zoom_mode = ZOOM_MODE_MAX; break; case 'U': opt.loadables = 1; @@ -605,6 +607,7 @@ static void feh_parse_option_array(int argc, char **argv) case ')': free(opt.menu_bg); opt.menu_bg = estrdup(optarg); + weprintf("The --menu-bg option is deprecated and will be removed by 2012"); break; case 'B': free(opt.image_bg); @@ -686,7 +689,7 @@ static void feh_parse_option_array(int argc, char **argv) case 204: free(opt.menu_style); opt.menu_style = estrdup(optarg); - weprintf("--menu-style is deprecated and will be removed soon"); + weprintf("The --menu-style option is deprecated and will be removed by 2012"); break; case 205: if (!strcmp("fill", optarg)) @@ -771,6 +774,9 @@ static void feh_parse_option_array(int argc, char **argv) case 234: opt.info_cmd = estrdup(optarg); break; + case 235: + opt.force_aliasing = 1; + break; default: break; } @@ -784,6 +790,8 @@ static void feh_parse_option_array(int argc, char **argv) add_file_to_filelist_recursively(argv[optind++], FILELIST_FIRST); } } + else if (finalrun && !opt.filelistfile && !opt.bgmode) + add_file_to_filelist_recursively(".", FILELIST_FIRST); /* So that we can safely be called again */ optind = 1; diff --git a/src/options.h b/src/options.h index 38b1526..431fdfc 100644 --- a/src/options.h +++ b/src/options.h @@ -107,6 +107,7 @@ struct __fehoptions { unsigned char no_blur_ctrl_mask; unsigned char no_pan_ctrl_mask; + int force_aliasing; int thumb_w; int thumb_h; int limit_w; @@ -175,6 +176,7 @@ struct __fehkb { struct __fehkey toggle_actions; struct __fehkey toggle_filenames; struct __fehkey toggle_pointer; + struct __fehkey toggle_aliasing; struct __fehkey jump_random; struct __fehkey toggle_caption; struct __fehkey toggle_pause; diff --git a/src/signals.c b/src/signals.c index b3e118a..956c861 100644 --- a/src/signals.c +++ b/src/signals.c @@ -25,6 +25,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include "feh.h" #include "winwidget.h" +#include "options.h" void feh_handle_signal(int); @@ -60,12 +61,16 @@ void feh_handle_signal(int signo) { winwidget winwid = winwidget_get_first_window_of_type(WIN_TYPE_SLIDESHOW); + int i; if (winwid) { if (signo == SIGUSR1) slideshow_change_image(winwid, SLIDE_NEXT); else if (signo == SIGUSR2) slideshow_change_image(winwid, SLIDE_PREV); + } else if (opt.multiwindow) { + for (i = window_num - 1; i >= 0; i--) + feh_reload_image(windows[i], 0, 0); } return; diff --git a/src/slideshow.c b/src/slideshow.c index 5ceee39..79b931f 100644 --- a/src/slideshow.c +++ b/src/slideshow.c @@ -101,12 +101,15 @@ void feh_reload_image(winwidget w, int resize, int force_new) char *title, *new_title; int len; Imlib_Image tmp; + int old_w, old_h; if (!w->file) { weprintf("couldn't reload, this image has no file associated with it."); return; } + D(("resize %d, force_new %d\n", resize, force_new)); + free(FEH_FILE(w->file->data)->caption); FEH_FILE(w->file->data)->caption = NULL; @@ -116,10 +119,11 @@ void feh_reload_image(winwidget w, int resize, int force_new) title = estrdup(w->name); winwidget_rename(w, new_title); + old_w = gib_imlib_image_get_width(w->im); + old_h = gib_imlib_image_get_height(w->im); + /* force imlib2 not to cache */ - if (force_new) { - winwidget_free_image(w); - } + winwidget_free_image(w); /* if the image has changed in dimensions - we gotta resize */ if ((feh_load_image(&tmp, FEH_FILE(w->file->data))) == 0) { @@ -134,19 +138,13 @@ void feh_reload_image(winwidget w, int resize, int force_new) filelist = feh_file_remove_from_list(filelist, w->file); return; } - if (force_new) { - w->im = tmp; + + if (!resize && ((old_w != gib_imlib_image_get_width(tmp)) || + (old_h != gib_imlib_image_get_height(tmp)))) resize = 1; - winwidget_reset_image(w); - } else { - if ((gib_imlib_image_get_width(w->im) != gib_imlib_image_get_width(tmp)) - || (gib_imlib_image_get_height(w->im) != gib_imlib_image_get_height(tmp))) { - resize = 1; - winwidget_reset_image(w); - } - winwidget_free_image(w); - w->im = tmp; - } + + w->im = tmp; + winwidget_reset_image(w); w->mode = MODE_NORMAL; if ((w->im_w != gib_imlib_image_get_width(w->im)) @@ -163,7 +161,7 @@ void feh_reload_image(winwidget w, int resize, int force_new) w->im_w = gib_imlib_image_get_width(w->im); w->im_h = gib_imlib_image_get_height(w->im); } - winwidget_render_image(w, resize, 1); + winwidget_render_image(w, resize, 0); winwidget_rename(w, title); free(title); @@ -252,10 +250,6 @@ void slideshow_change_image(winwidget winwid, int change) filelist = feh_file_remove_from_list(filelist, last); last = NULL; } - s = slideshow_create_name(FEH_FILE(current_file->data)); - - winwidget_rename(winwid, s); - free(s); if ((winwidget_loadimage(winwid, FEH_FILE(current_file->data))) != 0) { @@ -268,7 +262,12 @@ void slideshow_change_image(winwidget winwid, int change) winwidget_reset_image(winwid); winwid->im_w = gib_imlib_image_get_width(winwid->im); winwid->im_h = gib_imlib_image_get_height(winwid->im); - winwidget_render_image(winwid, 1, 1); + winwidget_render_image(winwid, 1, 0); + + s = slideshow_create_name(FEH_FILE(current_file->data)); + winwidget_rename(winwid, s); + free(s); + break; } else last = current_file; diff --git a/src/support.c b/src/support.c index d404047..e257271 100644 --- a/src/support.c +++ b/src/support.c @@ -131,7 +131,7 @@ void feh_wm_set_bg(char *fil, Imlib_Image im, int centered, int scaled, enl_ipc_sync(); } else { Atom prop_root, prop_esetroot, type; - int format; + int format, i; unsigned long length, after; unsigned char *data_root, *data_esetroot; Pixmap pmap_d1, pmap_d2; @@ -139,6 +139,10 @@ void feh_wm_set_bg(char *fil, Imlib_Image im, int centered, int scaled, char *fehbg = NULL; char *home; char filbuf[PATH_MAX]; + char fehbg_xinerama[] = "--no-xinerama"; + + if (opt.xinerama) + fehbg_xinerama[0] = '\0'; /* local display to set closedownmode on */ Display *disp2; @@ -163,21 +167,20 @@ void feh_wm_set_bg(char *fil, Imlib_Image im, int centered, int scaled, filbuf[out++] = 0; if (scaled) { - w = scr->width; - h = scr->height; - -/* disable xinerama check for setting background */ -#if 0 -/* #ifdef HAVE_LIBXINERAMA */ - if (opt.xinerama && xinerama_screens) { - w = xinerama_screens[xinerama_screen].width; - h = xinerama_screens[xinerama_screen].height; - } -#endif /* HAVE_LIBXINERAMA */ - - pmap_d1 = XCreatePixmap(disp, root, w, h, depth); - gib_imlib_render_image_on_drawable_at_size(pmap_d1, im, 0, 0, w, h, 1, 0, 1); - fehbg = estrjoin(" ", "feh --bg-scale", filbuf, NULL); + 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++) + gib_imlib_render_image_on_drawable_at_size(pmap_d1, im, + xinerama_screens[i].x_org, xinerama_screens[i].y_org, + xinerama_screens[i].width, xinerama_screens[i].height, + 1, 0, !opt.force_aliasing); + else +#endif /* HAVE_LIBXINERAMA */ + gib_imlib_render_image_on_drawable_at_size(pmap_d1, im, 0, 0, + scr->width, scr->height, 1, 0, !opt.force_aliasing); + fehbg = estrjoin(" ", "feh", fehbg_xinerama, "--bg-scale", filbuf, NULL); } else if (centered) { XGCValues gcval; GC gc; @@ -186,25 +189,33 @@ void feh_wm_set_bg(char *fil, Imlib_Image im, int centered, int scaled, D(("centering\n")); w = scr->width; h = scr->height; - -/* disable xinerama check for setting background */ -#if 0 -/* #ifdef HAVE_LIBXINERAMA */ - if (opt.xinerama && xinerama_screens) { - w = xinerama_screens[xinerama_screen].width; - h = xinerama_screens[xinerama_screen].height; - } -#endif /* HAVE_LIBXINERAMA */ + x = (w - gib_imlib_image_get_width(im)) >> 1; + y = (h - gib_imlib_image_get_height(im)) >> 1; pmap_d1 = XCreatePixmap(disp, root, w, h, depth); gcval.foreground = BlackPixel(disp, DefaultScreen(disp)); gc = XCreateGC(disp, root, GCForeground, &gcval); XFillRectangle(disp, pmap_d1, gc, 0, 0, w, h); - x = (w - gib_imlib_image_get_width(im)) >> 1; - y = (h - gib_imlib_image_get_height(im)) >> 1; - gib_imlib_render_image_on_drawable(pmap_d1, im, x, y, 1, 0, 0); + +#ifdef HAVE_LIBXINERAMA + if (opt.xinerama && xinerama_screens) + for (i = 0; i < num_xinerama_screens; i++) { + w = xinerama_screens[i].width; + h = xinerama_screens[i].height; + x = (w - gib_imlib_image_get_width(im)) >> 1; + y = (h - gib_imlib_image_get_height(im)) >> 1; + gib_imlib_render_image_part_on_drawable_at_size( + pmap_d1, im, + ((x < 0) ? -x : 0) , ((y < 0) ? -y : 0), w, h, + xinerama_screens[i].x_org + ((x > 0) ? x : 0), + xinerama_screens[i].y_org + ((y > 0) ? y : 0), + w, h, 1, 0, 0); + } + else +#endif /* HAVE_LIBXINERAMA */ + gib_imlib_render_image_on_drawable(pmap_d1, im, x, y, 1, 0, 0); XFreeGC(disp, gc); - fehbg = estrjoin(" ", "feh --bg-center", filbuf, NULL); + fehbg = estrjoin(" ", "feh", fehbg_xinerama, "--bg-center", filbuf, NULL); } else if (filled == 1) { int scr_w = scr->width; int scr_h = scr->height; @@ -212,20 +223,44 @@ void feh_wm_set_bg(char *fil, Imlib_Image im, int centered, int scaled, int img_h = gib_imlib_image_get_height(im); int render_x = 0; int render_y = 0; + int cut_x = (((img_w * scr_h) > (img_h * scr_w)) ? 1 : 0); + w = (cut_x ? ((scr_h * img_w) / img_h) : scr_w); + h = (cut_x ? scr_h : ((scr_w * img_h) / img_w)); + + if (cut_x) + render_x = (scr_w - w) >> 1; + else + render_y = (scr_h - h) >> 1; - if ((img_w * scr_h) > (scr_w * img_h)) { - h = scr_h; - w = (scr_h * img_w) / img_h; - render_x = (scr_w - w) / 2; - } else { - h = (scr_w * img_h) / img_w; - w = scr_w; - render_y = (scr_h - h) / 2; - } pmap_d1 = XCreatePixmap(disp, root, w, h, depth); - gib_imlib_render_image_on_drawable_at_size(pmap_d1, im, - render_x, render_y, w, h, 1, 0, 1); - fehbg = estrjoin(" ", "feh --bg-fill", filbuf, NULL); + +#ifdef HAVE_LIBXINERAMA + if (opt.xinerama && xinerama_screens) + for (i = 0; i < num_xinerama_screens; i++) { + scr_w = xinerama_screens[i].width; + scr_h = xinerama_screens[i].height; + cut_x = (((img_w * scr_h) > (img_h * scr_w)) ? 1 : 0); + w = (cut_x ? ((img_h * scr_w) / scr_h) : img_w); + h = (cut_x ? img_h : ((img_w * scr_h) / scr_w)); + render_x = (cut_x ? ((img_w - w) >> 1) : 0); + render_y = (cut_x ? 0 : ((img_h - h) >> 1)); + + D(("cut_x %d w %5d h %5d x %5d y %5d\n", + cut_x, w, h, render_x, render_y)); + + gib_imlib_render_image_part_on_drawable_at_size( + pmap_d1, im, + render_x, render_y, + w, h, + xinerama_screens[i].x_org, + xinerama_screens[i].y_org, + scr_w, scr_h, 1, 0, !opt.force_aliasing); + } + else +#endif /* HAVE_LIBXINERAMA */ + gib_imlib_render_image_on_drawable_at_size(pmap_d1, im, + render_x, render_y, w, h, 1, 0, !opt.force_aliasing); + fehbg = estrjoin(" ", "feh", fehbg_xinerama, "--bg-fill", filbuf, NULL); } else if (filled == 2) { int scr_w = scr->width; int scr_h = scr->height; @@ -233,38 +268,48 @@ void feh_wm_set_bg(char *fil, Imlib_Image im, int centered, int scaled, int img_h = gib_imlib_image_get_height(im); int render_x = 0; int render_y = 0; + int border_x = (((img_w * scr_h) > (img_h * scr_w)) ? 0 : 1); + w = (border_x ? ((scr_h * img_w) / img_h) : scr_w); + h = (border_x ? scr_h : ((scr_w * img_h) / img_w)); XGCValues gcval; - if (img_w > img_h) { - w = scr_w; - h = (((scr_w * 100) / img_w) * img_h) / 100; - render_y = (scr_h - h) / 2; - if (h > scr_h) { - w = (((scr_h * 100) / h) * w) / 100; - h = scr_h; - render_x = (scr_w - w) / 2; - render_y = 0; - } - } else { - h = scr_h; - w = (((scr_h * 100) / img_h) * img_w) / 100; - render_x = (scr_w - w) / 2; - if (w > scr_w) { - h = (((scr_w * 100) / w) * h) / 100; - w = scr_w; - render_x = 0; - render_y = (scr_h - h) / 2; - } - } + if (border_x) + render_x = (scr_w - w) >> 1; + else + render_y = (scr_h - h) >> 1; pmap_d1 = XCreatePixmap(disp, root, scr_w, scr_h, depth); gcval.foreground = BlackPixel(disp, DefaultScreen(disp)); gc = XCreateGC(disp, root, GCForeground, &gcval); XFillRectangle(disp, pmap_d1, gc, 0, 0, scr_w, scr_h); + +#ifdef HAVE_LIBXINERAMA + if (opt.xinerama && xinerama_screens) + for (i = 0; i < num_xinerama_screens; i++) { + scr_w = xinerama_screens[i].width; + scr_h = xinerama_screens[i].height; + border_x = (((img_w * scr_h) > (img_h * scr_w)) ? 0 : 1); + w = (border_x ? ((scr_h * img_w) / img_h) : scr_w); + h = (border_x ? scr_h : ((scr_w * img_h) / img_w)); + render_x = (border_x ? ((scr_w - w) >> 1) : 0); + render_y = (border_x ? 0 : ((scr_h - h) >> 1)); + + D(("border_x %d w %5d h %5d x %5d y %5d\n", + border_x, w, h, render_x, render_y)); + + gib_imlib_render_image_on_drawable_at_size( + pmap_d1, im, + xinerama_screens[i].x_org + render_x, + xinerama_screens[i].y_org + render_y, + w, h, + 1, 0, !opt.force_aliasing); + } + else +#endif /* HAVE_LIBXINERAMA */ gib_imlib_render_image_on_drawable_at_size(pmap_d1, im, - render_x, render_y, w, h, 1, 0, 1); + render_x, render_y, w, h, 1, 0, !opt.force_aliasing); XFreeGC(disp, gc); - fehbg = estrjoin(" ", "feh --bg-max", filbuf, NULL); + fehbg = estrjoin(" ", "feh", fehbg_xinerama, "--bg-max", filbuf, NULL); } else { w = gib_imlib_image_get_width(im); h = gib_imlib_image_get_height(im); diff --git a/src/thumbnail.c b/src/thumbnail.c index 17605a9..ca5c387 100644 --- a/src/thumbnail.c +++ b/src/thumbnail.c @@ -364,7 +364,7 @@ void init_thumbnail_mode(void) if (opt.display) { /* thumb_counter is unsigned, so no need to catch overflows */ if (++thumb_counter == opt.thumb_redraw) { - winwidget_render_image(winwid, 0, 0); + winwidget_render_image(winwid, 0, 1); thumb_counter = 0; } if (!feh_main_iteration(0)) @@ -373,7 +373,7 @@ void init_thumbnail_mode(void) } if (thumb_counter != 0) - winwidget_render_image(winwid, 0, 0); + winwidget_render_image(winwid, 0, 1); if (opt.verbose) fprintf(stdout, "\n"); diff --git a/src/winwidget.c b/src/winwidget.c index e918cd3..a39e8ef 100644 --- a/src/winwidget.c +++ b/src/winwidget.c @@ -58,6 +58,7 @@ static winwidget winwidget_allocate(void) ret->type = WIN_TYPE_UNSET; ret->visible = 0; ret->caption_entry = 0; + ret->force_aliasing = opt.force_aliasing; /* Zoom stuff */ ret->mode = MODE_NORMAL; @@ -99,7 +100,7 @@ winwidget winwidget_create_from_image(Imlib_Image im, char *name, char type) if (opt.full_screen && (type != WIN_TYPE_THUMBNAIL)) ret->full_screen = True; winwidget_create_window(ret, ret->w, ret->h); - winwidget_render_image(ret, 1, 1); + winwidget_render_image(ret, 1, 0); return(ret); } @@ -132,7 +133,7 @@ winwidget winwidget_create_from_file(gib_list * list, char *name, char type) if (opt.full_screen) ret->full_screen = True; winwidget_create_window(ret, ret->w, ret->h); - winwidget_render_image(ret, 1, 1); + winwidget_render_image(ret, 1, 0); } return(ret); @@ -362,10 +363,11 @@ void winwidget_setup_pixmaps(winwidget winwid) return; } -void winwidget_render_image(winwidget winwid, int resize, int alias) +void winwidget_render_image(winwidget winwid, int resize, int force_alias) { int sx, sy, sw, sh, dx, dy, dw, dh; int calc_w, calc_h; + int antialias = 0; if (!winwid->full_screen && resize) { winwidget_resize(winwid, winwid->im_w, winwid->im_h); @@ -378,8 +380,8 @@ void winwidget_render_image(winwidget winwid, int resize, int alias) if (winwid->im_y > winwid->h) winwid->im_y = winwid->h; - D(("winwidget_render_image resize %d alias %d im %dx%d\n", - resize, alias, winwid->im_w, winwid->im_h)); + D(("winwidget_render_image resize %d force_alias %d im %dx%d\n", + resize, force_alias, winwid->im_w, winwid->im_h)); winwidget_setup_pixmaps(winwid); @@ -524,17 +526,22 @@ void winwidget_render_image(winwidget winwid, int resize, int alias) D(("sx: %d sy: %d sw: %d sh: %d dx: %d dy: %d dw: %d dh: %d zoom: %f\n", sx, sy, sw, sh, dx, dy, dw, dh, winwid->zoom)); + if ((winwid->zoom != 1.0) && !force_alias && !winwid->force_aliasing) + antialias = 1; + D(("winwidget_render(): winwid->im_angle = %f\n", winwid->im_angle)); if (winwid->has_rotated) gib_imlib_render_image_part_on_drawable_at_size_with_rotation - (winwid->bg_pmap, winwid->im, sx, sy, sw, sh, dx, dy, dw, dh, winwid->im_angle, 1, 1, alias); + (winwid->bg_pmap, winwid->im, sx, sy, sw, sh, dx, dy, dw, dh, + winwid->im_angle, 1, 1, antialias); else gib_imlib_render_image_part_on_drawable_at_size(winwid->bg_pmap, winwid->im, sx, sy, sw, sh, dx, dy, dw, dh, 1, - gib_imlib_image_has_alpha(winwid->im), alias); + gib_imlib_image_has_alpha(winwid->im), + antialias); if (opt.mode == MODE_NORMAL) { if (opt.caption_path) @@ -545,7 +552,7 @@ void winwidget_render_image(winwidget winwid, int resize, int alias) feh_draw_actions(winwid); if (opt.info_cmd) feh_draw_info(winwid); - } else if ((opt.mode == MODE_ZOOM) && !alias) + } else if ((opt.mode == MODE_ZOOM) && !antialias) feh_draw_zoom(winwid); XSetWindowBackgroundPixmap(disp, winwid->win, winwid->bg_pmap); @@ -580,7 +587,7 @@ double feh_calc_needed_zoom(double *zoom, int orig_w, int orig_h, int dest_w, in ratio = ((double) orig_w / orig_h) / ((double) dest_w / dest_h); - if (opt.zoom_mode == ZOOM_MODE_MAX) + if (opt.zoom_mode == ZOOM_MODE_FILL) ratio = 1.0 / ratio; if (ratio > 1.0) @@ -691,13 +698,13 @@ void winwidget_destroy_all(void) return; } -void winwidget_rerender_all(int resize, int alias) +void winwidget_rerender_all(int resize) { int i; /* Have to DESCEND the list here, 'cos of the way _unregister works */ for (i = window_num - 1; i >= 0; i--) - winwidget_render_image(windows[i], resize, alias); + winwidget_render_image(windows[i], resize, 0); return; } @@ -988,7 +995,7 @@ void winwidget_size_to_image(winwidget winwid) { winwidget_resize(winwid, winwid->im_w * winwid->zoom, winwid->im_h * winwid->zoom); winwid->im_x = winwid->im_y = 0; - winwidget_render_image(winwid, 0, 1); + winwidget_render_image(winwid, 0, 0); return; } diff --git a/src/winwidget.h b/src/winwidget.h index 8b4579c..922ecf5 100644 --- a/src/winwidget.h +++ b/src/winwidget.h @@ -82,6 +82,7 @@ struct __winwidget { int h; int im_w; int im_h; + int force_aliasing; double im_angle; enum win_type type; unsigned char had_resize, full_screen; @@ -123,14 +124,14 @@ void winwidget_hide(winwidget winwid); void winwidget_destroy_all(void); void winwidget_free_image(winwidget w); void winwidget_center_image(winwidget w); -void winwidget_render_image(winwidget winwid, int resize, int alias); +void winwidget_render_image(winwidget winwid, int resize, int force_alias); void winwidget_rotate_image(winwidget winid, double angle); void winwidget_move(winwidget winwid, int x, int y); void winwidget_resize(winwidget winwid, int w, int h); void winwidget_setup_pixmaps(winwidget winwid); void winwidget_update_title(winwidget ret); void winwidget_update_caption(winwidget winwid); -void winwidget_rerender_all(int resize, int alias); +void winwidget_rerender_all(int resize); void winwidget_destroy_xwin(winwidget winwid); void winwidget_set_pointer(winwidget winwid, int visible); |