From 4eb72706ebd0635d23e96bdde7b6f9612d18d4c5 Mon Sep 17 00:00:00 2001 From: ulteq Date: Wed, 22 Aug 2018 10:56:17 +0200 Subject: Add an option to disable inplace edit --- src/imlib.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'src/imlib.c') diff --git a/src/imlib.c b/src/imlib.c index f41cdcd..91b635e 100644 --- a/src/imlib.c +++ b/src/imlib.c @@ -1192,6 +1192,22 @@ void feh_edit_inplace(winwidget w, int op) if (!w->file || !w->file->data || !FEH_FILE(w->file->data)->filename) return; + if (opt.no_inplace_edit) { + imlib_context_set_image(w->im); + if (op == INPLACE_EDIT_FLIP) + imlib_image_flip_vertical(); + else if (op == INPLACE_EDIT_MIRROR) + imlib_image_flip_horizontal(); + else { + imlib_image_orientate(op); + tmp = w->im_w; + FEH_FILE(w->file->data)->info->width = w->im_w = w->im_h; + FEH_FILE(w->file->data)->info->height = w->im_h = tmp; + } + winwidget_render_image(w, 1, 0); + return; + } + if (!strcmp(gib_imlib_image_format(w->im), "jpeg") && !path_is_url(FEH_FILE(w->file->data)->filename)) { feh_edit_inplace_lossless(w, op); -- cgit v1.2.3 From 0dd07456d361736b8f100c45b3edada6ef4f1e42 Mon Sep 17 00:00:00 2001 From: Olof-Joachim Frahm Date: Thu, 4 Oct 2018 02:18:42 +0200 Subject: Add missing EXIF rotations. --- src/gib_imlib.c | 12 ++++++++++++ src/gib_imlib.h | 2 ++ src/imlib.c | 14 +++++++++++++- 3 files changed, 27 insertions(+), 1 deletion(-) (limited to 'src/imlib.c') diff --git a/src/gib_imlib.c b/src/gib_imlib.c index 8f401aa..7858cb7 100644 --- a/src/gib_imlib.c +++ b/src/gib_imlib.c @@ -717,3 +717,15 @@ void gib_imlib_image_orientate(Imlib_Image im, int orientation) imlib_context_set_image(im); imlib_image_orientate(orientation); } + +void gib_imlib_image_flip_horizontal(Imlib_Image im) +{ + imlib_context_set_image(im); + imlib_image_flip_horizontal(); +} + +void gib_imlib_image_flip_vertical(Imlib_Image im) +{ + imlib_context_set_image(im); + imlib_image_flip_vertical(); +} diff --git a/src/gib_imlib.h b/src/gib_imlib.h index 6a16a0c..07daabe 100644 --- a/src/gib_imlib.h +++ b/src/gib_imlib.h @@ -181,6 +181,8 @@ void gib_imlib_parse_color(char *col, int *r, int *g, int *b, int *a); void gib_imlib_parse_fontpath(char *path); Imlib_Font gib_imlib_load_font(char *name); void gib_imlib_image_orientate(Imlib_Image im, int orientation); +void gib_imlib_image_flip_horizontal(Imlib_Image im); +void gib_imlib_image_flip_vertical(Imlib_Image im); #ifdef __cplusplus } diff --git a/src/imlib.c b/src/imlib.c index f41cdcd..18547a9 100644 --- a/src/imlib.c +++ b/src/imlib.c @@ -294,10 +294,22 @@ int feh_load_image(Imlib_Image * im, feh_file * file) } file->ed = exifData; - if (orientation == 3) + if (orientation == 2) + gib_imlib_image_flip_horizontal(*im); + else if (orientation == 3) gib_imlib_image_orientate(*im, 2); + else if (orientation == 4) + gib_imlib_image_flip_vertical(*im); + else if (orientation == 5) { + gib_imlib_image_orientate(*im, 3); + gib_imlib_image_flip_vertical(*im); + } else if (orientation == 6) gib_imlib_image_orientate(*im, 1); + else if (orientation == 7) { + gib_imlib_image_orientate(*im, 3); + gib_imlib_image_flip_horizontal(*im); + } else if (orientation == 8) gib_imlib_image_orientate(*im, 3); #endif -- cgit v1.2.3 From 1c36c74c8ff5ad9768c854a2d88fa66fa9fe148f Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Sun, 4 Nov 2018 22:07:22 +0100 Subject: Disable in-place editing by default --- src/imlib.c | 2 +- src/options.c | 8 ++++---- src/options.h | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) (limited to 'src/imlib.c') diff --git a/src/imlib.c b/src/imlib.c index 2c04128..a48d654 100644 --- a/src/imlib.c +++ b/src/imlib.c @@ -1204,7 +1204,7 @@ void feh_edit_inplace(winwidget w, int op) if (!w->file || !w->file->data || !FEH_FILE(w->file->data)->filename) return; - if (opt.no_inplace_edit) { + if (!opt.edit) { imlib_context_set_image(w->im); if (op == INPLACE_EDIT_FLIP) imlib_image_flip_vertical(); diff --git a/src/options.c b/src/options.c index dc6a9ff..19e47f6 100644 --- a/src/options.c +++ b/src/options.c @@ -398,6 +398,7 @@ static void feh_parse_option_array(int argc, char **argv, int finalrun) {"bg-fill" , 0, 0, 218}, {"bg-max" , 0, 0, 219}, {"no-jump-on-resort", 0, 0, 220}, + {"edit" , 0, 0, 221}, #ifdef HAVE_LIBEXIF {"draw-exif" , 0, 0, 223}, {"auto-rotate" , 0, 0, 242}, @@ -418,7 +419,6 @@ static void feh_parse_option_array(int argc, char **argv, int finalrun) {"conversion-timeout" , 1, 0, 245}, {"version-sort" , 0, 0, 246}, {"offset" , 1, 0, 247}, - {"no-inplace-edit", 0, 0, 248}, {0, 0, 0, 0} }; int optch = 0, cmdx = 0; @@ -731,6 +731,9 @@ static void feh_parse_option_array(int argc, char **argv, int finalrun) case 220: opt.jump_on_resort = 0; break; + case 221: + opt.edit = 1; + break; #ifdef HAVE_LIBEXIF case 223: opt.draw_exif = 1; @@ -806,9 +809,6 @@ static void feh_parse_option_array(int argc, char **argv, int finalrun) opt.offset_flags = XParseGeometry(optarg, &opt.offset_x, &opt.offset_y, (unsigned int *)&discard, (unsigned int *)&discard); break; - case 248: - opt.no_inplace_edit = 1; - break; default: break; } diff --git a/src/options.h b/src/options.h index 5734b54..1c68fa0 100644 --- a/src/options.h +++ b/src/options.h @@ -80,6 +80,7 @@ struct __fehoptions { unsigned char keep_zoom_vp; unsigned char insecure_ssl; unsigned char filter_by_dimensions; + unsigned char edit; char *output_file; char *output_dir; @@ -110,7 +111,6 @@ struct __fehoptions { double reload; int sort; int version_sort; - int no_inplace_edit; int debug; int geom_enabled; int geom_flags; -- cgit v1.2.3 From de185357e745f78e2133da826972502bd1980d1f Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Sun, 4 Nov 2018 22:12:39 +0100 Subject: Fix segfault when editing an image without info struct --- src/imlib.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'src/imlib.c') diff --git a/src/imlib.c b/src/imlib.c index a48d654..4270c4a 100644 --- a/src/imlib.c +++ b/src/imlib.c @@ -1213,8 +1213,12 @@ void feh_edit_inplace(winwidget w, int op) else { imlib_image_orientate(op); tmp = w->im_w; - FEH_FILE(w->file->data)->info->width = w->im_w = w->im_h; - FEH_FILE(w->file->data)->info->height = w->im_h = tmp; + w->im_w = w->im_h; + w->im_h = tmp; + if (FEH_FILE(w->file->data)->info) { + FEH_FILE(w->file->data)->info->width = w->im_w; + FEH_FILE(w->file->data)->info->height = w->im_h; + } } winwidget_render_image(w, 1, 0); return; @@ -1257,8 +1261,12 @@ void feh_edit_inplace(winwidget w, int op) else { imlib_image_orientate(op); tmp = w->im_w; - FEH_FILE(w->file->data)->info->width = w->im_w = w->im_h; - FEH_FILE(w->file->data)->info->height = w->im_h = tmp; + w->im_w = w->im_h; + w->im_h = tmp; + if (FEH_FILE(w->file->data)->info) { + FEH_FILE(w->file->data)->info->width = w->im_w; + FEH_FILE(w->file->data)->info->height = w->im_h; + } } im_weprintf(w, "unable to edit in place. Changes have not been saved."); winwidget_render_image(w, 1, 0); -- cgit v1.2.3 From a6ac404853d107308b0ad11dbf0885c50ab11b73 Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Fri, 23 Nov 2018 16:38:22 +0100 Subject: Decrease libcurl timeout from indefinite to 30 minutes --- src/imlib.c | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src/imlib.c') diff --git a/src/imlib.c b/src/imlib.c index 4270c4a..2f3459e 100644 --- a/src/imlib.c +++ b/src/imlib.c @@ -583,6 +583,13 @@ static char *feh_http_load_image(char *url) #ifdef DEBUG curl_easy_setopt(curl, CURLOPT_VERBOSE, 1); #endif + /* + * Do not allow requests to take longer than 30 minutes. + * This should be sufficiently high to accomodate use cases with + * unusually high latencies, while at the sime time avoiding + * feh hanging indefinitely in unattended slideshows. + */ + curl_easy_setopt(curl, CURLOPT_TIMEOUT, 1800); curl_easy_setopt(curl, CURLOPT_URL, url); curl_easy_setopt(curl, CURLOPT_WRITEDATA, sfp); ebuff = emalloc(CURL_ERROR_SIZE); -- cgit v1.2.3 From 3fc148aecf9a5334a26752acf6b6d71819cbc2f4 Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Thu, 29 Nov 2018 18:36:46 +0100 Subject: Handle SIGINT while doing libcurl transfers See also #435 --- src/imlib.c | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) (limited to 'src/imlib.c') diff --git a/src/imlib.c b/src/imlib.c index 2f3459e..3bc0126 100644 --- a/src/imlib.c +++ b/src/imlib.c @@ -37,6 +37,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #ifdef HAVE_LIBCURL #include +extern int sig_exit; #endif #ifdef HAVE_LIBEXIF @@ -541,6 +542,24 @@ static char *feh_magick_load_image(char *filename) #ifdef HAVE_LIBCURL +static int curl_quit_function(void *clientp, curl_off_t dltotal, curl_off_t dlnow, curl_off_t ultotal, curl_off_t ulnow) +{ + // ignore "unused parameter" warnings + (void)clientp; + (void)dltotal; + (void)dlnow; + (void)ultotal; + (void)ulnow; + if (sig_exit) { + /* + * The user wants to quit feh. Tell libcurl to abort the transfer and + * return control to the main loop, where we can quit gracefully. + */ + return 1; + } + return 0; +} + static char *feh_http_load_image(char *url) { CURL *curl; @@ -596,6 +615,8 @@ static char *feh_http_load_image(char *url) curl_easy_setopt(curl, CURLOPT_ERRORBUFFER, ebuff); curl_easy_setopt(curl, CURLOPT_FAILONERROR, 1L); curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1); + curl_easy_setopt(curl, CURLOPT_XFERINFOFUNCTION, curl_quit_function); + curl_easy_setopt(curl, CURLOPT_NOPROGRESS, 0); if (opt.insecure_ssl) { curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0); curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, 0); @@ -608,7 +629,9 @@ static char *feh_http_load_image(char *url) res = curl_easy_perform(curl); curl_easy_cleanup(curl); if (res != CURLE_OK) { - weprintf("open url: %s", ebuff); + if (res != CURLE_ABORTED_BY_CALLBACK) { + weprintf("open url: %s", ebuff); + } unlink(sfn); close(fd); free(sfn); -- cgit v1.2.3 From bafc47fd575bb7878214deda3730efcb6c755770 Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Tue, 4 Dec 2018 21:34:14 +0100 Subject: Declare sig_exit as volatile sig_exit may be changed by a signal handler, so its value should always be read from RAM. --- src/filelist.c | 2 +- src/imlib.c | 2 +- src/signals.c | 2 +- src/signals.h | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) (limited to 'src/imlib.c') diff --git a/src/filelist.c b/src/filelist.c index 3f3c96d..6f4f6df 100644 --- a/src/filelist.c +++ b/src/filelist.c @@ -30,6 +30,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include "feh.h" #include "filelist.h" +#include "signals.h" #include "options.h" gib_list *filelist = NULL; @@ -37,7 +38,6 @@ gib_list *original_file_items = NULL; /* original file items from argv */ int filelist_len = 0; gib_list *current_file = NULL; extern int errno; -extern int sig_exit; /* exit flag from signal handler */ static gib_list *rm_filelist = NULL; diff --git a/src/imlib.c b/src/imlib.c index 3bc0126..4d2f2fa 100644 --- a/src/imlib.c +++ b/src/imlib.c @@ -26,6 +26,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include "feh.h" #include "filelist.h" +#include "signals.h" #include "winwidget.h" #include "options.h" @@ -37,7 +38,6 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #ifdef HAVE_LIBCURL #include -extern int sig_exit; #endif #ifdef HAVE_LIBEXIF diff --git a/src/signals.c b/src/signals.c index aeaf889..d65f49b 100644 --- a/src/signals.c +++ b/src/signals.c @@ -28,7 +28,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include "options.h" void feh_handle_signal(int); -int sig_exit = 0; +volatile int sig_exit = 0; void setup_signal_handlers() { diff --git a/src/signals.h b/src/signals.h index 090ab0b..38fc0d2 100644 --- a/src/signals.h +++ b/src/signals.h @@ -27,5 +27,5 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #define SIGNALS_H void setup_signal_handlers(); -extern int sig_exit; +volatile extern int sig_exit; #endif -- cgit v1.2.3