No more needed to use -i to disable icon padding
Now xmenu detects if a menu has an icon, and if it doesn't have, the menu will not have the gaps fgor icons, making the -i flag unecessary to disable the padding. The -i option is still necessary, however, to speed up xmenu loading, since it disables imlib2 initialization routines.
This commit is contained in:
parent
c15958bd96
commit
a2ff706d6f
8
xmenu.c
8
xmenu.c
|
@ -467,6 +467,7 @@ allocmenu(struct Menu *parent, struct Item *list, unsigned level)
|
||||||
menu->y = 0; /* calculated by setupmenu() */
|
menu->y = 0; /* calculated by setupmenu() */
|
||||||
menu->level = level;
|
menu->level = level;
|
||||||
menu->drawn = 0;
|
menu->drawn = 0;
|
||||||
|
menu->hasicon = 0;
|
||||||
|
|
||||||
swa.override_redirect = (wflag) ? False : True;
|
swa.override_redirect = (wflag) ? False : True;
|
||||||
swa.background_pixel = dc.normal[ColorBG].pixel;
|
swa.background_pixel = dc.normal[ColorBG].pixel;
|
||||||
|
@ -541,6 +542,9 @@ buildmenutree(unsigned level, const char *label, const char *output, char *file)
|
||||||
curritem->prev = NULL;
|
curritem->prev = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (curritem->file)
|
||||||
|
prevmenu->hasicon = 1;
|
||||||
|
|
||||||
return rootmenu;
|
return rootmenu;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -718,7 +722,7 @@ setupitems(struct Menu *menu)
|
||||||
* padding appears 3 times: before the label and around the triangle.
|
* padding appears 3 times: before the label and around the triangle.
|
||||||
*/
|
*/
|
||||||
itemwidth = textwidth + config.triangle_width + config.horzpadding * 3;
|
itemwidth = textwidth + config.triangle_width + config.horzpadding * 3;
|
||||||
itemwidth += (iflag) ? 0 : config.iconsize + config.horzpadding;
|
itemwidth += (iflag || !menu->hasicon) ? 0 : config.iconsize + config.horzpadding;
|
||||||
menu->w = MAX(menu->w, itemwidth);
|
menu->w = MAX(menu->w, itemwidth);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -902,7 +906,7 @@ drawitems(struct Menu *menu)
|
||||||
|
|
||||||
/* draw text */
|
/* draw text */
|
||||||
x = config.horzpadding;
|
x = config.horzpadding;
|
||||||
x += (iflag) ? 0 : config.horzpadding + config.iconsize;
|
x += (iflag || !menu->hasicon) ? 0 : config.horzpadding + config.iconsize;
|
||||||
dsel = XftDrawCreate(dpy, item->sel, visual, colormap);
|
dsel = XftDrawCreate(dpy, item->sel, visual, colormap);
|
||||||
dunsel = XftDrawCreate(dpy, item->unsel, visual, colormap);
|
dunsel = XftDrawCreate(dpy, item->unsel, visual, colormap);
|
||||||
XSetForeground(dpy, dc.gc, dc.selected[ColorFG].pixel);
|
XSetForeground(dpy, dc.gc, dc.selected[ColorFG].pixel);
|
||||||
|
|
1
xmenu.h
1
xmenu.h
|
@ -84,6 +84,7 @@ struct Menu {
|
||||||
struct Item *list; /* list of items contained by the menu */
|
struct Item *list; /* list of items contained by the menu */
|
||||||
struct Item *selected; /* item currently selected in the menu */
|
struct Item *selected; /* item currently selected in the menu */
|
||||||
int x, y, w, h; /* menu geometry */
|
int x, y, w, h; /* menu geometry */
|
||||||
|
int hasicon; /* whether the menu has item with icons */
|
||||||
int drawn; /* whether the menu was already drawn */
|
int drawn; /* whether the menu was already drawn */
|
||||||
unsigned level; /* menu level relative to root */
|
unsigned level; /* menu level relative to root */
|
||||||
Window win; /* menu window to map on the screen */
|
Window win; /* menu window to map on the screen */
|
||||||
|
|
Loading…
Reference in New Issue
Block a user