simplify pointless function, which also fixes defaultimg function

This commit is contained in:
speedie 2023-03-04 15:21:43 +01:00
parent cc231b8df8
commit 7803e08417
3 changed files with 16 additions and 40 deletions

View file

@ -17,23 +17,9 @@ void
rotateimage(void) rotateimage(void)
{ {
if (!rotation) return; if (!rotation) return;
if (rotation == 1) { if (rotation > 4) rotation = 1;
imlib_image_orientate(1);
} else if (rotation == 2) { imlib_image_orientate(rotation);
imlib_image_orientate(1);
imlib_image_orientate(1);
} else if (rotation == 3) {
imlib_image_orientate(1);
imlib_image_orientate(1);
imlib_image_orientate(1);
} else if (rotation == 4) {
imlib_image_orientate(1);
imlib_image_orientate(1);
imlib_image_orientate(1);
imlib_image_orientate(1);
} else {
rotation = 1;
}
} }
void void
@ -47,24 +33,6 @@ cleanupimage(void)
return; return;
} }
void
prepareimage(void)
{
/* values which can be restored later */
if (!imagew || !imageh || !imageg) {
imagew = imagewidth;
imageh = imageheight;
imageg = imagegaps;
}
/* restore values if necessary */
if (!imageheight || !imagewidth || !longestedge) {
imageheight = imageh;
imagewidth = imagew;
imagegaps = imageg;
}
}
void void
drawimage(void) drawimage(void)
{ {
@ -86,7 +54,6 @@ drawimage(void)
image = NULL; image = NULL;
} if (image && longestedge) { } if (image && longestedge) {
prepareimage();
rotateimage(); rotateimage();
flipimage(); flipimage();

View file

@ -6,7 +6,6 @@
static void setimageopts(void); static void setimageopts(void);
static void cleanupimage(void); static void cleanupimage(void);
static void drawimage(void); static void drawimage(void);
static void prepareimage(void);
static void rotateimage(void); static void rotateimage(void);
static void flipimage(void); static void flipimage(void);
static void loadimagecache(const char *file, int *width, int *height); static void loadimagecache(const char *file, int *width, int *height);

View file

@ -327,9 +327,11 @@ defaultimg(const Arg *arg)
if (hideimage || !image) return; if (hideimage || !image) return;
/* this will cause values to be reset */ if (imagew) {
imagewidth = 0; imagewidth = imagew;
prepareimage(); imageheight = imageh;
imagegaps = imageg;
}
drawmenu(); drawmenu();
drawimage(); drawimage();
@ -1628,6 +1630,14 @@ main(int argc, char *argv[])
readstdin(); readstdin();
grabkeyboard(); grabkeyboard();
} }
/* set values which we can restore later */
if (!imagew || !imageh || !imageg) {
imagew = imagewidth;
imageh = imageheight;
imagegaps = imagegaps;
}
setup(); setup();
run(); run();