diff --git a/docs/spmenu.conf b/docs/spmenu.conf index 63b7799..85dfada 100644 --- a/docs/spmenu.conf +++ b/docs/spmenu.conf @@ -500,6 +500,13 @@ spmenu = { function = "toggleimg"; argument = "0"; }, + // f: Toggle image full screen mode + { mode = 0; + modifier = "None"; + key = "f"; + function = "togglefullimg"; + argument = "0"; + }, // h: Flip image horizontally { mode = 0; modifier = "None"; diff --git a/keybinds.h b/keybinds.h index 36aac53..69ec829 100644 --- a/keybinds.h +++ b/keybinds.h @@ -41,6 +41,7 @@ static Key keys[] = { { 0, Shift, XK_1, setimggaps, {.i = -100 } }, { 0, Shift, XK_2, setimggaps, {.i = +100 } }, { 0, 0, XK_t, toggleimg, {0} }, + { 0, 0, XK_f, togglefullimg, {0} }, { 0, 0, XK_p, paste, {.i = 2 } }, { 0, 0, XK_h, flipimg, {.i = 1 } }, { 0, 0, XK_v, flipimg, {.i = 0 } }, diff --git a/libs/arg.c b/libs/arg.c index 332d28a..1aab7ce 100644 --- a/libs/arg.c +++ b/libs/arg.c @@ -403,6 +403,25 @@ void toggleimg(Arg *arg) { #endif } +void togglefullimg(Arg *arg) { +#if USEIMAGE + fullscreen = image ? !fullscreen : 0; + + if (fullscreen) { + ow = imagewidth; + oh = imageheight; + + imagewidth = mw; + imageheight = mh; + } else { + imagewidth = ow; + imageheight = oh; + } + + drawmenu(); +#endif +} + void defaultimg(Arg *arg) { #if USEIMAGE @@ -419,6 +438,7 @@ void defaultimg(Arg *arg) { } void setlines(Arg *arg) { + if (fullscreen) return; lines += arg->i; if (lines < 0) lines = 0; @@ -428,6 +448,7 @@ void setlines(Arg *arg) { } void setcolumns(Arg *arg) { + if (fullscreen) return; columns += arg->i; if (columns < 1) columns = 1; diff --git a/libs/arg.h b/libs/arg.h index 679ffe0..0a5d435 100644 --- a/libs/arg.h +++ b/libs/arg.h @@ -30,6 +30,7 @@ static void quit(Arg *arg); static void complete(Arg *arg); static void setimgsize(Arg *arg); static void toggleimg(Arg *arg); +static void togglefullimg(Arg *arg); static void defaultimg(Arg *arg); static void rotateimg(Arg *arg); static void flipimg(Arg *arg); diff --git a/libs/conf/config.h b/libs/conf/config.h index 71c9321..8e3a3d0 100644 --- a/libs/conf/config.h +++ b/libs/conf/config.h @@ -356,6 +356,7 @@ static FuncList fl[] = { { "setimgsize", setimgsize }, { "setimgsize", setimgsize }, { "toggleimg", toggleimg }, + { "togglefullimg", togglefullimg }, { "defaultimg", defaultimg }, { "rotateimg", rotateimg }, { "flipimg", flipimg }, diff --git a/libs/draw.c b/libs/draw.c index 43decca..9717d59 100644 --- a/libs/draw.c +++ b/libs/draw.c @@ -488,31 +488,32 @@ void drawmenu(void) { } #endif - if (!hideprompt) { + if (!hideprompt && !fullscreen) { w = promptw; x = drawprompt(x, y, w); } - if (!hideinput) { + + if (!hideinput && !fullscreen) { w = (lines > 0 || !matches) ? mw - x : inputw; x = drawinput(x, y, w); } - if (!hidemode) modeWidth = pango_mode ? TEXTWM(modetext) : TEXTW(modetext); + if (!hidemode && !fullscreen) modeWidth = pango_mode ? TEXTWM(modetext) : TEXTW(modetext); // draw the items, this function also calls drawrarrow() and drawlarrow() if (!hideitem) drawitem(x, y, w); - if (!hidematchcount) { + if (!hidematchcount && !fullscreen) { w = numberWidth; drawnumber(mw - numberWidth - modeWidth - capsWidth - 2 * sp - 2 * borderwidth - menumarginh, y, w); } - if (!hidemode) { + if (!hidemode && !fullscreen) { w = modeWidth; drawmode(mw - modeWidth - capsWidth - 2 * sp - 2 * borderwidth - menumarginh, y, w); } - if (!hidecaps) { + if (!hidecaps && !fullscreen) { w = capsWidth; drawcaps(mw - capsWidth - 2 * sp - 2 * borderwidth - menumarginh, y, w); } diff --git a/libs/img.c b/libs/img.c index e7e4b3a..45ec702 100644 --- a/libs/img.c +++ b/libs/img.c @@ -4,7 +4,7 @@ void setimagesize(int width, int height) { int oiw = 0; // this makes sure we cannot scale the image up or down too much - if ((!image && height < imageheight) || (!image && width < imagewidth) || (width < 0) || width > mw || hideimage) return; + if ((!image && height < imageheight) || (!image && width < imagewidth) || (width < 0) || width > mw || hideimage || fullscreen) return; // original width/height oih = imageheight; @@ -94,24 +94,31 @@ void drawimage(void) { xta += menumarginh; wta += menumarginv; - if (mh != bh + height + imagegaps * 2 - wtr) { // menu height cannot be smaller than image height + if (mh != bh + height + leftmargin * 2 - wtr && !fullscreen) { // menu height cannot be smaller than image height resizetoimageheight(height); + } else if (mh != bh + height + leftmargin * 2 - wtr && fullscreen) { + resizetoimageheight(height-bh); + } + + // we're covering all the area + if (fullscreen) { + xta = wta = wtr = leftmargin = 0; } // render image if (!imageposition && image) { // top mode = 0 if (height > width) width = height; - imlib_render_image_on_drawable(leftmargin+(imagewidth-width)/2+xta, wta+imagegaps); + imlib_render_image_on_drawable(leftmargin+(imagewidth-width)/2+xta, wta+leftmargin); } else if (imageposition == 1 && image) { // bottom mode = 1 if (height > width) width = height; - imlib_render_image_on_drawable(leftmargin+(imagewidth-width)/2+xta, mh-height-imagegaps); + imlib_render_image_on_drawable(leftmargin+(imagewidth-width)/2+xta, mh-height-leftmargin); } else if (imageposition == 2 && image) { // center mode = 2 imlib_render_image_on_drawable(leftmargin+(imagewidth-width)/2+xta, (mh-wta-height)/2+wta); } else if (image) { // top center - int minh = MIN(height, mh-bh-imagegaps*2); - imlib_render_image_on_drawable(leftmargin+(imagewidth-width)/2+xta, (minh-height)/2+wta+imagegaps); + int minh = MIN(height, mh-bh-leftmargin*2); + imlib_render_image_on_drawable(leftmargin+(imagewidth-width)/2+xta, (minh-height)/2+wta+leftmargin); } } diff --git a/spmenu.c b/spmenu.c index d763c8f..4c5fc54 100644 --- a/spmenu.c +++ b/spmenu.c @@ -183,7 +183,10 @@ static int longestedge = 0; static int imagew = 0; static int imageh = 0; static int imageg = 0; +static int ow = 0; +static int oh = 0; #endif +static int fullscreen = 0; // config file #if USECONFIG