--- ./fvwm/menuitem.c.orig	2005-11-25 11:28:52.000000000 +0100
+++ ./fvwm/menuitem.c	2005-11-25 13:40:02.000000000 +0100
@@ -357,7 +357,7 @@
 	{
 		text_y += MI_PICTURE(mi)->height;
 	}
-	for (i = 0; i < MAX_MENU_ITEM_MINI_ICONS; i++)
+	for (i = 0; i < mpip->used_mini_icons; i++)
 	{
 		y = 0;
 		if (MI_MINI_ICON(mi)[i])
@@ -798,7 +798,7 @@
 	 * Draw the mini icons.
 	 */
 
-	for (i = 0; i < MAX_MENU_ITEM_MINI_ICONS; i++)
+	for (i = 0; i < mpip->used_mini_icons; i++)
 	{
 		int k;
 		Bool draw_picture = True;
@@ -806,7 +806,7 @@
 		/* We need to reverse the mini icon order for left submenu
 		 * style. */
 		k = (ST_USE_LEFT_SUBMENUS(ms)) ?
-			MAX_MENU_ITEM_MINI_ICONS - 1 - i : i;
+			mpip->used_mini_icons - 1 - i : i;
 
 		if (MI_MINI_ICON(mi)[i])
 		{
@@ -874,8 +874,9 @@
 						b.x, b.y, b.width, b.height);
 				}
 				PGraphicsRenderPicture(
-					dpy, mpip->w, MI_MINI_ICON(mi)[i], &fra,
-					mpip->w, tmp_gc, Scr.MonoGC, Scr.AlphaGC,
+					dpy, mpip->w, MI_MINI_ICON(mi)[i],
+					&fra, mpip->w, tmp_gc, Scr.MonoGC,
+					Scr.AlphaGC,
 					b.x - MDIM_ICON_X_OFFSET(*dim)[k],
 					b.y - y, b.width, b.height,
 					b.x, b.y, b.width, b.height, False);
--- ./fvwm/menus.c.orig	2005-11-25 11:28:43.000000000 +0100
+++ ./fvwm/menus.c	2005-11-25 13:46:15.000000000 +0100
@@ -1816,14 +1816,6 @@
 					break;
 				}
 				x += gap_left;
-				if (!first)
-				{
-					/* Stop parsing immediately. %s
-					 * must be first or last in the
-					 * format string. */
-					sidepic_is_left = False;
-					done = True;
-				}
 				MR_SIDEPIC_X_OFFSET(msp->menu) = x;
 				if (first)
 				{
@@ -2484,6 +2476,7 @@
 		has_continuation_menu = size_menu_vertically(&msp);
 		/* repeat this step if the menu was split */
 	} while (has_continuation_menu);
+	MR_USED_MINI_ICONS(mr) = msp.used_mini_icons;
 
 	MR_XANIMATION(mr) = 0;
 	memset(&(MR_DYNAMIC_FLAGS(mr)), 0, sizeof(MR_DYNAMIC_FLAGS(mr)));
@@ -3163,6 +3156,7 @@
 	mpip->selected_item = MR_SELECTED_ITEM(mr);
 	mpip->dim = &MR_DIM(mr);
 	mpip->fw = fw;
+	mpip->used_mini_icons = MR_USED_MINI_ICONS(mr);
 	mpip->cb_mr = mr;
 	mpip->cb_reset_bg = paint_menu_gradient_background;
 	mpip->flags.is_first_item = (MR_FIRST_ITEM(mr) == mi);
@@ -3183,7 +3177,6 @@
 {
 	MenuItem *mi;
 	MenuStyle *ms = MR_STYLE(mr);
-	MenuPaintItemParameters mpip;
 	int bw = MST_BORDER_WIDTH(mr);
 	XGCValues gcv;
 	short relief_thickness = ST_RELIEF_THICKNESS(MR_STYLE(mr));
@@ -3261,7 +3254,6 @@
 			 HILIGHT_GC(MST_MENU_INACTIVE_GCS(mr)),
 			 SHADOW_GC(MST_MENU_INACTIVE_GCS(mr)), bw);
 	/* paint the menu items */
-	get_menu_paint_item_parameters(&mpip, mr, NULL, fw, pevent, True);
 	for (mi = MR_FIRST_ITEM(mr); mi != NULL; mi = MI_NEXT_ITEM(mi))
 	{
 		int do_draw = 0;
@@ -3290,6 +3282,10 @@
 		}
 		if (do_draw)
 		{
+			MenuPaintItemParameters mpip;
+
+			get_menu_paint_item_parameters(
+				&mpip, mr, NULL, fw, pevent, True);
 			mpip.flags.is_first_item = (MR_FIRST_ITEM(mr) == mi);
 			menuitem_paint(mi, &mpip);
 		}
@@ -3304,8 +3300,6 @@
 static void select_menu_item(
 	MenuRoot *mr, MenuItem *mi, Bool select, FvwmWindow *fw)
 {
-	MenuPaintItemParameters mpip;
-
 	if (select == True && MR_SELECTED_ITEM(mr) != NULL &&
 	    MR_SELECTED_ITEM(mr) != mi)
 	{
@@ -3475,8 +3469,13 @@
 		fw = NULL;
 	}
 	MR_SELECTED_ITEM(mr) = (select) ? mi : NULL;
-	get_menu_paint_item_parameters(&mpip, mr, mi, fw, NULL, False);
-	menuitem_paint(mi, &mpip);
+	if (MR_IS_PAINTED(mr))
+	{
+		MenuPaintItemParameters mpip;
+
+		get_menu_paint_item_parameters(&mpip, mr, mi, fw, NULL, False);
+		menuitem_paint(mi, &mpip);
+	}
 
 	return;
 }
@@ -4646,6 +4645,7 @@
 	mloop_evh_input_t *in, mloop_evh_data_t *med, mloop_static_info_t *msi)
 {
 	MenuRoot *tmrMi;
+	Bool rc;
 
 	pmret->rc = MENU_NOP;
 	switch ((*pmp->pexc)->x.elast->type)
@@ -4933,10 +4933,13 @@
 	case Expose:
 		/* grab our expose events, let the rest go through */
 		XFlush(dpy);
-		menu_expose((*pmp->pexc)->x.elast, (*pmp->pexc)->w.fw);
-		/* we want to dispatch this too so that icons and maybe tear off
-		 * get redrawn after being obscured by menus. */
-		dispatch_event((*pmp->pexc)->x.elast);
+		rc = menu_expose((*pmp->pexc)->x.elast, (*pmp->pexc)->w.fw);
+		/* we want to dispatch this too so that icons and maybe tear
+		 * off get redrawn after being obscured by menus. */
+		if (rc == False)
+		{
+			dispatch_event((*pmp->pexc)->x.elast);
+		}
 		return MENU_MLOOP_RET_LOOP;
 
 	case ClientMessage:
@@ -6591,7 +6594,7 @@
 	return;
 }
 
-void menu_expose(XEvent *event, FvwmWindow *fw)
+Bool menu_expose(XEvent *event, FvwmWindow *fw)
 {
 	MenuRoot *mr = NULL;
 
@@ -6601,9 +6604,13 @@
 	{
 		flush_accumulate_expose(event->xany.window, event);
 		paint_menu(mr, event, fw);
-	}
 
-	return;
+		return True;
+	}
+	else
+	{
+		return False;
+	}
 }
 
 /*
@@ -6624,7 +6631,6 @@
 {
 	MenuItem *mi;
 	MenuRoot *mr;
-	MenuPaintItemParameters mpip;
 	MenuStyle *ms;
 	int h = 0;
 	int s_h = 0;
@@ -6686,14 +6692,17 @@
 	}
 
 	/* now redraw the items */
-	get_menu_paint_item_parameters(&mpip, mr, NULL, prtm->fw, NULL, True);
 	for (mi = MR_FIRST_ITEM(mr); mi != NULL; mi = MI_NEXT_ITEM(mi))
 	{
+		MenuPaintItemParameters mpip;
+
 		if (mi == MR_SELECTED_ITEM(mr) && MST_DO_HILIGHT_BACK(mr) &&
 		    !CSET_IS_TRANSPARENT_PR_TINT(ST_CSET_MENU(ms)))
 		{
 			continue;
 		}
+		get_menu_paint_item_parameters(
+			&mpip, mr, NULL, prtm->fw, NULL, True);
 		mpip.flags.is_first_item = (MR_FIRST_ITEM(mr) == mi);
 		menuitem_paint(mi, &mpip);
 	}
--- ./fvwm/fvwm.1.in.orig	2005-11-25 13:47:16.000000000 +0100
+++ ./fvwm/fvwm.1.in	2005-11-25 13:47:48.000000000 +0100
@@ -3276,8 +3276,7 @@
 menu. This directive may be used only once and only as the first
 or last in the format string. If the
 .B %s
-is not at the beginning of the string, all characters to the right
-of it are silently ignored.
+is not at the beginning of the string, menus are not drawn properly.
 .in -.3i
 .BR Space ", " Tab ", " %Space " and " %Tab
 .in +.3i
--- ./ChangeLog.orig	2005-11-25 12:47:12.000000000 +0100
+++ ./ChangeLog	2005-11-25 13:47:08.000000000 +0100
@@ -1,3 +1,28 @@
+2005-11-25  Dominik Vogt  <dominik.vogt@gmx.de>
+
+	* fvwm/menuitem.c (menuitem_paint):
+	* fvwm/menus.c (get_menu_paint_item_parameters)
+	(get_menu_paint_item_parameters):
+	(make_menu):
+	fixed text offset of menu items with icons but with an item format that
+	disables icons
+	(size_menu_horizontally):
+	allow sidepic to be placed in the middle of menu items; this is better
+	than ignoring the item format completely but does not draw the items
+	properly either
+
+	* fvwm/menus.c (__mloop_handle_event):
+	(menu_expose):
+	fixed delayed menu drawing issue
+	(select_menu_item):
+	do not draw the selected menu item before the menu is drawn for the
+	first time
+	(repaint_transparent_menu):
+	(select_menu_item):
+	(paint_menu):
+	don't call get_menu_paint_item_parameters when the result is not used
+	(get_menu_paint_item_parameters):
+
 2005-07-18  Dominik Vogt  <dominik.vogt@gmx.de>
 
 	* fvwm/ewmh_events.c (ewmh_WMIconGeometry):
