From dfc4fe038c75ad0b4d8387b74cc8556476f76316 Mon Sep 17 00:00:00 2001 From: speedie Date: Sat, 24 Jun 2023 04:53:44 +0200 Subject: [PATCH] Remove fullscreen functionality The fullscreen functionality is kind of cool, but adds a lot of code and as commit history has shown, plenty of bugs and extra required testing. I may reimplement this later in a less bad manner. Note that the fullscreen behavior can be achieved by simply increasing image size to the max. spmenu will let you do that. Fixes issue #9 --- docs/docs.md | 1 - docs/spmenu.conf | 1 - libs/arg.c | 26 ++------------------------ libs/arg.h | 1 - libs/conf/config.h | 1 - libs/draw.c | 13 +++++++------ libs/img.c | 36 ++---------------------------------- libs/keybinds.h | 2 -- spmenu.1 | 19 ++++--------------- spmenu.c | 1 - 10 files changed, 15 insertions(+), 86 deletions(-) diff --git a/docs/docs.md b/docs/docs.md index 9f16786..92e6128 100644 --- a/docs/docs.md +++ b/docs/docs.md @@ -771,7 +771,6 @@ These are the default keybinds. You can generate these yourself from a | 0 | Shift | 1 | setimggaps | -100 | | 0 | Shift | 2 | setimggaps | +100 | | 0 | 0 | t | toggleimg | 0 | -| 0 | 0 | f | togglefullimg | 0 | | 0 | 0 | p | paste | 2 | | 0 | 0 | q | flipimg | 1 | | 0 | 0 | w | flipimg | 0 | diff --git a/docs/spmenu.conf b/docs/spmenu.conf index ebe9174..8450cdc 100644 --- a/docs/spmenu.conf +++ b/docs/spmenu.conf @@ -312,7 +312,6 @@ spmenu = { { mode = 0; modifier = "Shift"; key = "!"; function = "setimggaps"; argument = "-100"; }, // Shift+1: Decrease image gaps by 100 { mode = 0; modifier = "Shift"; key = "@"; function = "setimggaps"; argument = "+100"; }, // Shift+2: Increase image gaps by 100 { mode = 0; modifier = "None"; key = "t"; function = "toggleimg"; argument = "0"; }, // t: Toggle image - { mode = 0; modifier = "None"; key = "f"; function = "togglefullimg"; argument = "0"; }, // f: Toggle image full screen mode { mode = 0; modifier = "None"; key = "q"; function = "flipimg"; argument = "1"; }, // q: Flip image horizontally { mode = 0; modifier = "None"; key = "w"; function = "flipimg"; argument = "0"; }, // w: Flip image vertically { mode = 0; modifier = "None"; key = "k"; function = "moveup"; argument = "0"; }, // k: Move up 1 item diff --git a/libs/arg.c b/libs/arg.c index 2764152..0bac4c6 100644 --- a/libs/arg.c +++ b/libs/arg.c @@ -426,28 +426,6 @@ void toggleimg(Arg *arg) { #endif } -void togglefullimg(Arg *arg) { -#if USEIMAGE - if (hideimage || !image) { - return; - } - - fullscreen = !fullscreen; - - if (fullscreen) { - img.imagewidth = sp.mw; - img.imageheight = sp.mh; - img.imagegaps = 0; - } else { - img.imagewidth = imagewidth; - img.imageheight = imageheight; - img.imagegaps = imagegaps; - } - - drawmenu(); -#endif -} - void defaultimg(Arg *arg) { #if USEIMAGE @@ -462,7 +440,7 @@ void defaultimg(Arg *arg) { } void setlines(Arg *arg) { - if (fullscreen || !overridelines) return; + if (!overridelines) return; lines += arg->i; @@ -480,7 +458,7 @@ void setlines(Arg *arg) { } void setcolumns(Arg *arg) { - if (fullscreen || !overridecolumns) return; + if (!overridecolumns) return; columns += arg->i; diff --git a/libs/arg.h b/libs/arg.h index c54da36..520706d 100644 --- a/libs/arg.h +++ b/libs/arg.h @@ -33,7 +33,6 @@ 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 flipimg(Arg *arg); static void setimgpos(Arg *arg); diff --git a/libs/conf/config.h b/libs/conf/config.h index 4c1e045..62bd6ca 100644 --- a/libs/conf/config.h +++ b/libs/conf/config.h @@ -376,7 +376,6 @@ static FuncList fl[] = { { "setimgsize", setimgsize }, { "setimgsize", setimgsize }, { "toggleimg", toggleimg }, - { "togglefullimg", togglefullimg }, { "defaultimg", defaultimg }, { "flipimg", flipimg }, { "setimgpos", setimgpos }, diff --git a/libs/draw.c b/libs/draw.c index e884960..781127d 100644 --- a/libs/draw.c +++ b/libs/draw.c @@ -582,6 +582,7 @@ void drawmenu_layer(void) { int x = 0, y = 0, w = 0; sp.plw = hidepowerline ? 0 : draw->font->h / 2 + 1; // powerline size + // draw menu first using menu scheme draw_rect(draw, 0, 0, sp.mw, sp.mh, 1, 1, col_menu, col_menu, alpha_menu, alpha_menu); @@ -613,32 +614,32 @@ void drawmenu_layer(void) { y -= sp.bh; } - if (!hideprompt && !fullscreen) { + if (!hideprompt) { w = sp.promptw; x = drawprompt(x, y, w); } - if (!hideinput && !fullscreen) { + if (!hideinput) { w = (lines > 0 || !matches) ? sp.mw - x : sp.inputw; x = drawinput(x, y, w); } - if (!hidemode && !fullscreen) modew = pango_mode ? TEXTWM(tx.modetext) : TEXTW(tx.modetext); + if (!hidemode) modew = pango_mode ? TEXTWM(tx.modetext) : TEXTW(tx.modetext); // draw the items, this function also calls drawrarrow() and drawlarrow() if (!hideitem) drawitem(x, y, w); - if (!hidematchcount && !fullscreen) { + if (!hidematchcount) { w = numberw; drawnumber(sp.mw - numberw - modew - capsw - 2 * sp.sp - 2 * borderwidth - menumarginh, y, w); } - if (!hidemode && !fullscreen) { + if (!hidemode) { w = modew; drawmode(sp.mw - modew - capsw - 2 * sp.sp - 2 * borderwidth - menumarginh, y, w); } - if (!hidecaps && !fullscreen) { + if (!hidecaps) { w = capsw; drawcaps(sp.mw - capsw - 2 * sp.sp - 2 * borderwidth - menumarginh, y, w); } diff --git a/libs/img.c b/libs/img.c index db9b677..c9e680e 100644 --- a/libs/img.c +++ b/libs/img.c @@ -2,7 +2,7 @@ #if USEIMAGE void setimagesize(int width, int height) { - if (!image || fullscreen || hideimage || height < 5 || width < 5 || width > sp.mw) { + if (!image || hideimage || height < 5 || width < 5 || width > sp.mw) { return; } @@ -38,10 +38,6 @@ void drawimage(void) { int width = 0, height = 0; char *limg = NULL; - if (fullscreen && !image) { - togglefullimg(NULL); - } - if (!lines || !columns || hideimage) return; // load image cache @@ -53,13 +49,6 @@ void drawimage(void) { } if (!image) { - if (fullscreen) { - fullscreen = 0; - img.imagewidth = imagewidth; - img.imageheight = imageheight; - img.imagegaps = imagegaps; - } - return; } @@ -83,24 +72,11 @@ void drawimage(void) { wta += menumarginv; if (sp.mh != sp.bh + height + leftmargin * 2 - wtr && imageresize) { // menu height cannot be smaller than image height - resizetoimageheight(imlib_image_get_height() - (fullscreen ? 2 * menumarginv : 0)); + resizetoimageheight(imlib_image_get_height()); } draw_set_img(draw, imlib_image_get_data(), width, height); - if (fullscreen) { - xta = wta = leftmargin = 0; - draw_img(draw, (img.imagewidth - width) / 2, 0); - - if (sel) { - limg = sel->image; - } else { - limg = NULL; - } - - return; - } - // render image on X11 if (!imageposition) { // top mode = 0 if (height > width) @@ -365,10 +341,6 @@ void resizetoimageheight_x11(int imageheight) { if (lines * sp.bh < imageheight + imagegaps * 2) { lines = (imageheight + imagegaps * 2) / sp.bh; - - if (fullscreen) { - lines = imageheight / sp.bh - 1; - } } get_mh(); @@ -464,10 +436,6 @@ void resizetoimageheight_wl(int imageheight) { if (lines * sp.bh < imageheight + imagegaps * 2) { lines = (imageheight + imagegaps * 2) / sp.bh; - - if (fullscreen) { - lines = imageheight / sp.bh - 1; - } } get_mh(); diff --git a/libs/keybinds.h b/libs/keybinds.h index 3fcaa35..667c576 100644 --- a/libs/keybinds.h +++ b/libs/keybinds.h @@ -49,7 +49,6 @@ 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_q, flipimg, {.i = 1 } }, { 0, 0, XK_w, flipimg, {.i = 0 } }, @@ -125,7 +124,6 @@ static WlKey wl_keys[] = { { 0, WL_Shift, XKB_KEY_1, setimggaps, {.i = -100 } }, { 0, WL_Shift, XKB_KEY_2, setimggaps, {.i = +100 } }, { 0, WL_None, XKB_KEY_t, toggleimg, {0} }, - { 0, WL_None, XKB_KEY_f, togglefullimg, {0} }, { 0, WL_None, XKB_KEY_p, paste, {.i = 2 } }, { 0, WL_None, XKB_KEY_q, flipimg, {.i = 1 } }, { 0, WL_None, XKB_KEY_w, flipimg, {.i = 0 } }, diff --git a/spmenu.1 b/spmenu.1 index 95cf0c8..90ae202 100644 --- a/spmenu.1 +++ b/spmenu.1 @@ -1220,17 +1220,6 @@ T{ T}@T{ 0 T}@T{ -f -T}@T{ -togglefullimg -T}@T{ -0 -T} -T{ -0 -T}@T{ -0 -T}@T{ p T}@T{ paste @@ -1240,9 +1229,9 @@ T} T{ 0 T}@T{ -Shift +0 T}@T{ -h +q T}@T{ flipimg T}@T{ @@ -1251,9 +1240,9 @@ T} T{ 0 T}@T{ -Shift +0 T}@T{ -v +w T}@T{ flipimg T}@T{ diff --git a/spmenu.c b/spmenu.c index e45fee8..289f30f 100644 --- a/spmenu.c +++ b/spmenu.c @@ -203,7 +203,6 @@ static int *sel_index = NULL; static unsigned int sel_size = 0; static int protocol_override = 0; static int itemn = 0; -static int fullscreen = 0; #if USERTL static int isrtl = 1;