- /* set menu width */
- labelwidth = ext.xOff + item->h * 2;
- menu->w = MAX(menu->w, labelwidth);
+ /*
+ * set menu width
+ *
+ * the item width depends on the size of its label (ext.xOff),
+ * and it is only used to calculate the width of the menu (which
+ * is equal to the width of the largest item).
+ *
+ * the horizontal padding appears 4 times through the width of a
+ * item: before and after its icon, and before and after its triangle
+ * if the iflag is set (icons are disabled) then the horizontal
+ * padding appears before the label and around the triangle.
+ */
+ itemwidth = ext.xOff + config.triangle_width + config.horzpadding * 3;
+ itemwidth += (iflag) ? 0 : config.iconsize + config.horzpadding;
+ menu->w = MAX(menu->w, itemwidth);