Fixing #7
Redrawing an icon every time the cursor moves between items costs a lot of time. So now each icon is drawn once, and s copied when needed.
This commit is contained in:
parent
ced6b0f73e
commit
675a2008a6
32
xmenu.c
32
xmenu.c
|
@ -546,8 +546,29 @@ setupitems(struct Menu *menu)
|
|||
menu->w = MAX(menu->w, itemwidth);
|
||||
|
||||
/* create icon */
|
||||
if (item->file != NULL && !iflag)
|
||||
if (item->file != NULL && !iflag) {
|
||||
item->icon = loadicon(item->file);
|
||||
|
||||
item->sel = XCreatePixmap(dpy, menu->win,
|
||||
config.iconsize, config.iconsize,
|
||||
DefaultDepth(dpy, screen));
|
||||
XSetForeground(dpy, dc.gc, dc.selected[ColorBG].pixel);
|
||||
XFillRectangle(dpy, item->sel, dc.gc, 0, 0,
|
||||
config.iconsize, config.iconsize);
|
||||
imlib_context_set_drawable(item->sel);
|
||||
imlib_context_set_image(item->icon);
|
||||
imlib_render_image_on_drawable(0, 0);
|
||||
|
||||
item->unsel = XCreatePixmap(dpy, menu->win,
|
||||
config.iconsize, config.iconsize,
|
||||
DefaultDepth(dpy, screen));
|
||||
XSetForeground(dpy, dc.gc, dc.normal[ColorBG].pixel);
|
||||
XFillRectangle(dpy, item->unsel, dc.gc, 0, 0,
|
||||
config.iconsize, config.iconsize);
|
||||
imlib_context_set_drawable(item->unsel);
|
||||
imlib_context_set_image(item->icon);
|
||||
imlib_render_image_on_drawable(0, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -778,9 +799,12 @@ drawitem(struct Menu *menu, struct Item *item, XftColor *color)
|
|||
if (item->icon != NULL) {
|
||||
x = config.horzpadding;
|
||||
y = item->y + config.iconpadding;
|
||||
imlib_context_set_drawable(menu->pixmap);
|
||||
imlib_context_set_image(item->icon);
|
||||
imlib_render_image_on_drawable(x, y);
|
||||
if (color == dc.selected)
|
||||
XCopyArea(dpy, item->sel, menu->pixmap, dc.gc, 0, 0,
|
||||
menu->w, menu->h, x, y);
|
||||
else
|
||||
XCopyArea(dpy, item->unsel, menu->pixmap, dc.gc, 0, 0,
|
||||
menu->w, menu->h, x, y);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user