simplify full screen

This commit is contained in:
speedie 2023-06-24 04:43:05 +02:00
parent c0cd874348
commit 748db7eed1
3 changed files with 28 additions and 13 deletions

View file

@ -428,17 +428,20 @@ void toggleimg(Arg *arg) {
void togglefullimg(Arg *arg) { void togglefullimg(Arg *arg) {
#if USEIMAGE #if USEIMAGE
fullscreen = image ? !fullscreen : 0; if (hideimage || !image) {
return;
}
fullscreen = !fullscreen;
if (fullscreen) { if (fullscreen) {
img.ow = img.imagewidth;
img.oh = img.imageheight;
img.imagewidth = sp.mw; img.imagewidth = sp.mw;
img.imageheight = sp.mh; img.imageheight = sp.mh;
img.imagegaps = 0;
} else { } else {
img.imagewidth = img.ow; img.imagewidth = imagewidth;
img.imageheight = img.oh; img.imageheight = imageheight;
img.imagegaps = imagegaps;
} }
drawmenu(); drawmenu();

View file

@ -50,7 +50,21 @@ void drawimage(void) {
loadimagecache(sel->image, &width, &height); loadimagecache(sel->image, &width, &height);
} else if ((!sel || !sel->image) && image) { // free image } else if ((!sel || !sel->image) && image) { // free image
cleanupimage(); cleanupimage();
} if (image && img.longestedge && width && height) { // render the image }
if (!image) {
if (fullscreen) {
fullscreen = 0;
img.imagewidth = imagewidth;
img.imageheight = imageheight;
img.imagegaps = imagegaps;
}
return;
}
// render the image
if (img.longestedge && width && height) {
flipimage(); flipimage();
int leftmargin = imagegaps; // gaps between image and menu int leftmargin = imagegaps; // gaps between image and menu
@ -88,19 +102,19 @@ void drawimage(void) {
} }
// render image on X11 // render image on X11
if (!imageposition && image) { // top mode = 0 if (!imageposition) { // top mode = 0
if (height > width) if (height > width)
width = height; width = height;
draw_img(draw, leftmargin + (img.imagewidth - width) / 2 + xta, wta + leftmargin); draw_img(draw, leftmargin + (img.imagewidth - width) / 2 + xta, wta + leftmargin);
} else if (imageposition == 1 && image) { // bottom mode = 1 } else if (imageposition == 1) { // bottom mode = 1
if (height > width) if (height > width)
width = height; width = height;
draw_img(draw, leftmargin + (img.imagewidth - width) / 2 + xta, sp.mh - height - leftmargin); draw_img(draw, leftmargin + (img.imagewidth - width) / 2 + xta, sp.mh - height - leftmargin);
} else if (imageposition == 2 && image) { // center mode = 2 } else if (imageposition == 2) { // center mode = 2
draw_img(draw, leftmargin + (img.imagewidth - width) / 2 + xta, (sp.mh - wta - height) / 2 + wta); draw_img(draw, leftmargin + (img.imagewidth - width) / 2 + xta, (sp.mh - wta - height) / 2 + wta);
} else if (image) { // top center } else { // top center
int minh = MIN(height, sp.mh - sp.bh - leftmargin * 2); int minh = MIN(height, sp.mh - sp.bh - leftmargin * 2);
draw_img(draw, leftmargin + (img.imagewidth - width) / 2 + xta, (minh - height) / 2 + wta + leftmargin); draw_img(draw, leftmargin + (img.imagewidth - width) / 2 + xta, (minh - height) / 2 + wta + leftmargin);
} }

View file

@ -146,8 +146,6 @@ struct img {
int imagewidth; // current image width int imagewidth; // current image width
int imageheight; // current image height int imageheight; // current image height
int imagegaps; // current image gaps int imagegaps; // current image gaps
int ow; // original sp.mw
int oh; // original sp.mh
}; };
#endif #endif