don't allow the image to be scaled up beyond menu width

This commit is contained in:
speedie 2023-03-08 18:20:15 +01:00
parent 6a83ac707e
commit d3ec1b609b
2 changed files with 7 additions and 49 deletions

View file

@ -8,8 +8,8 @@ setimagesize(int width, int height)
int oih = 0; int oih = 0;
int oiw = 0; int oiw = 0;
/* this makes sure we cannot scale down the image too much */ /* this makes sure we cannot scale the image up or down too much */
if ((!image && height < imageheight) || (!image && width < imagewidth) || hideimage) return; if ((!image && height < imageheight) || (!image && width < imagewidth) || width > mw || hideimage) return;
cleanupimage(); cleanupimage();

View file

@ -191,7 +191,6 @@ static size_t nextrune(int inc);
static void drawmenu(void); static void drawmenu(void);
static void calcoffsets(void); static void calcoffsets(void);
static void run(void);
static void readstdin(void); static void readstdin(void);
static void recalculatenumbers(void); static void recalculatenumbers(void);
static void usage(void); static void usage(void);
@ -200,6 +199,8 @@ static void movewordedge(int dir);
static void insert(const char *str, ssize_t n); static void insert(const char *str, ssize_t n);
static void cleanup(void); static void cleanup(void);
static void navigatehistfile(int dir); static void navigatehistfile(int dir);
static void grabfocus(void);
static void pastesel(void);
static int max_textw(void); static int max_textw(void);
/* user configuration */ /* user configuration */
@ -223,6 +224,8 @@ static int longestedge = 0; /* longest edge */
#include "libs/rtl.h" #include "libs/rtl.h"
#include "libs/rtl.c" #include "libs/rtl.c"
#endif #endif
#include "libs/event.h"
#include "libs/event.c"
#include "libs/key.c" #include "libs/key.c"
#include "libs/mouse.c" #include "libs/mouse.c"
#include "libs/draw.c" #include "libs/draw.c"
@ -804,51 +807,6 @@ readstdin(void)
lines = MIN(lines, i); lines = MIN(lines, i);
} }
void
run(void)
{
XEvent ev;
while (!XNextEvent(dpy, &ev)) {
if (XFilterEvent(&ev, win))
continue;
switch(ev.type) {
case DestroyNotify:
if (ev.xdestroywindow.window != win)
break;
cleanup();
exit(1);
case ButtonPress:
buttonpress(&ev);
break;
case Expose:
if (ev.xexpose.count == 0)
drw_map(drw, win, 0, 0, mw, mh);
break;
case FocusIn:
/* regrab focus from parent window */
if (ev.xfocus.window != win)
grabfocus();
break;
case KeyPress:
keypress(&ev);
break;
case SelectionNotify:
if (ev.xselection.property == utf8)
pastesel();
break;
case VisibilityNotify:
if (ev.xvisibility.state != VisibilityUnobscured)
XRaiseWindow(dpy, win);
break;
}
#if USEIMAGE
drawimage();
#endif
}
}
void void
setup(void) setup(void)
{ {
@ -1068,7 +1026,7 @@ main(int argc, char *argv[])
} }
setup(); setup();
run(); eventloop();
return 1; /* unreachable */ return 1; /* unreachable */
} }