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)
{
if (!rotation) return;
if (rotation == 1) {
imlib_image_orientate(1);
} else if (rotation == 2) {
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;
}
if (rotation > 4) rotation = 1;
imlib_image_orientate(rotation);
}
void
@ -47,24 +33,6 @@ cleanupimage(void)
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
drawimage(void)
{
@ -86,7 +54,6 @@ drawimage(void)
image = NULL;
} if (image && longestedge) {
prepareimage();
rotateimage();
flipimage();

View file

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

View file

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