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
This commit is contained in:
speedie 2023-06-24 04:53:44 +02:00
parent 748db7eed1
commit dfc4fe038c
10 changed files with 15 additions and 86 deletions

View file

@ -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 |

View file

@ -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

View file

@ -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;

View file

@ -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);

View file

@ -376,7 +376,6 @@ static FuncList fl[] = {
{ "setimgsize", setimgsize },
{ "setimgsize", setimgsize },
{ "toggleimg", toggleimg },
{ "togglefullimg", togglefullimg },
{ "defaultimg", defaultimg },
{ "flipimg", flipimg },
{ "setimgpos", setimgpos },

View file

@ -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);
}

View file

@ -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();

View file

@ -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 } },

View file

@ -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{

View file

@ -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;