don't allow the image to be scaled up beyond menu width
This commit is contained in:
parent
6a83ac707e
commit
d3ec1b609b
|
@ -8,8 +8,8 @@ setimagesize(int width, int height)
|
|||
int oih = 0;
|
||||
int oiw = 0;
|
||||
|
||||
/* this makes sure we cannot scale down the image too much */
|
||||
if ((!image && height < imageheight) || (!image && width < imagewidth) || hideimage) return;
|
||||
/* this makes sure we cannot scale the image up or down too much */
|
||||
if ((!image && height < imageheight) || (!image && width < imagewidth) || width > mw || hideimage) return;
|
||||
|
||||
cleanupimage();
|
||||
|
||||
|
|
52
spmenu.c
52
spmenu.c
|
@ -191,7 +191,6 @@ static size_t nextrune(int inc);
|
|||
|
||||
static void drawmenu(void);
|
||||
static void calcoffsets(void);
|
||||
static void run(void);
|
||||
static void readstdin(void);
|
||||
static void recalculatenumbers(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 cleanup(void);
|
||||
static void navigatehistfile(int dir);
|
||||
static void grabfocus(void);
|
||||
static void pastesel(void);
|
||||
static int max_textw(void);
|
||||
|
||||
/* user configuration */
|
||||
|
@ -223,6 +224,8 @@ static int longestedge = 0; /* longest edge */
|
|||
#include "libs/rtl.h"
|
||||
#include "libs/rtl.c"
|
||||
#endif
|
||||
#include "libs/event.h"
|
||||
#include "libs/event.c"
|
||||
#include "libs/key.c"
|
||||
#include "libs/mouse.c"
|
||||
#include "libs/draw.c"
|
||||
|
@ -804,51 +807,6 @@ readstdin(void)
|
|||
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
|
||||
setup(void)
|
||||
{
|
||||
|
@ -1068,7 +1026,7 @@ main(int argc, char *argv[])
|
|||
}
|
||||
|
||||
setup();
|
||||
run();
|
||||
eventloop();
|
||||
|
||||
return 1; /* unreachable */
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue