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 ++++++++++++++++ src/options.c | 4 ++++ src/options.h | 1 + 3 files changed, 21 insertions(+) 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); diff --git a/src/options.c b/src/options.c index af0f07d..d3066ef 100644 --- a/src/options.c +++ b/src/options.c @@ -418,6 +418,7 @@ 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; @@ -795,6 +796,9 @@ 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 936b4bd..bd2dfad 100644 --- a/src/options.h +++ b/src/options.h @@ -105,6 +105,7 @@ 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 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(-) 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(-) 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