From 03a245720e4ebf50c10def696fdd476d1744dae6 Mon Sep 17 00:00:00 2001 From: speedie Date: Wed, 8 Mar 2023 19:10:48 +0100 Subject: [PATCH] turns out one of those calls were necessary to prevent image from being scaled down too far, this commit fixes the last commit while preserving the speed improvement by preventing a call to drawimage() through an X11 event after image size has been changed. --- libs/img.c | 10 ++++++++++ spmenu.c | 1 + 2 files changed, 11 insertions(+) diff --git a/libs/img.c b/libs/img.c index 9e922e8..ced71e1 100644 --- a/libs/img.c +++ b/libs/img.c @@ -17,6 +17,10 @@ setimagesize(int width, int height) imageheight = height; imagewidth = width; + drawimage(); + + needredraw = 0; + if (!image) { imageheight = oih; imagewidth = oiw; @@ -69,6 +73,12 @@ drawimage(void) if (!lines || hideimage) return; + /* to prevent the image from being drawn multiple times */ + if (!needredraw) { + needredraw = 1; + return; + } + if (sel && sel->image && strcmp(sel->image, limg ? limg : "")) { if (longestedge) loadimagecache(sel->image, &width, &height); diff --git a/spmenu.c b/spmenu.c index 899fc9e..95edfff 100644 --- a/spmenu.c +++ b/spmenu.c @@ -159,6 +159,7 @@ static int rotation = 0; static int imagew = 0; static int imageh = 0; static int imageg = 0; +static int needredraw = 1; /* set an integer if to 1 if we have right to left language support enabled * doing it this way, because we can reduce the amount of #if and #else lines used.