diff --git a/src/options.c b/src/options.c index af0f07dd..1173a856 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}, + {"center-window-on-resize", 0, 0, 249}, {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 249: + opt.center_window_on_resize = 1; + break; default: break; } diff --git a/src/options.h b/src/options.h index 936b4bd1..2fe46c4c 100644 --- a/src/options.h +++ b/src/options.h @@ -105,6 +105,7 @@ struct __fehoptions { double reload; int sort; int version_sort; + int center_window_on_resize; int debug; int geom_enabled; int geom_flags; diff --git a/src/winwidget.c b/src/winwidget.c index fe0b505b..219fb208 100644 --- a/src/winwidget.c +++ b/src/winwidget.c @@ -817,6 +817,10 @@ void winwidget_resize(winwidget winwid, int w, int h, int force_resize) winwid->x = tc_x; winwid->y = tc_y; XMoveResizeWindow(disp, winwid->win, tc_x, tc_y, winwid->w, winwid->h); + } else if (opt.center_window_on_resize) { + winwid->x = (scr_width - winwid->w) / 2; + winwid->y = (scr_height - winwid->h) / 2; + XMoveResizeWindow(disp, winwid->win, winwid->x, winwid->y, winwid->w, winwid->h); } else XResizeWindow(disp, winwid->win, winwid->w, winwid->h);