On Sun, Jul 24, 2011 at 12:25:03PM -0600, Glenn Golden wrote:
> Thomas Adam writes:
> > 
> > Does the attached patch unconditionally define the behaviour you're after
> > though? 
> > 
> 
> Indeed it does. 
> 
> >
> > If so, I'll embelish it with options, and commit to CVS.
> >
> 
> Way cool dudeski, thanks! 

What about now with the attached patch?

-- Thomas Adam

-- 
"Deep in my heart I wish I was wrong.  But deep in my heart I know I am
not." -- Morrissey ("Girl Least Likely To" -- off of Viva Hate.)
diff --git a/doc/commands/MenuStyle.xml b/doc/commands/MenuStyle.xml
index fda282d..2e56ea1 100644
--- a/doc/commands/MenuStyle.xml
+++ b/doc/commands/MenuStyle.xml
@@ -75,6 +75,7 @@ VerticalItemSpacing,
 VerticalMargins,
 VerticalTitleSpacing,
 AutomaticHotkeys / !AutomaticHotkeys,
+HotKeyActivatesLastSelectedItem / !HotKeyActivatesLastSelectedItem,
 MouseWheel,
 ScrollOffPage / !ScrollOffPage,
 TrianglesUseFore / !TrianglesUseFore.</para>
@@ -124,6 +125,7 @@ TitleWarp, TitleUnderlines1, SeparatorsShort, TrianglesRelief,
 PopupDelayed, PopdownDelayed, PopupDelay 150, PopdownDelay 150,
 PopupAsSubmenu, HoldSubmenus,
 SubmenusRight, BorderWidth 2, !AutomaticHotkeys,
+HotKeyActivatesLastSelectedItem,
 PopupActiveArea 75.</para>
 
 <para><emphasis remap='I'>Mwm</emphasis>
@@ -133,6 +135,7 @@ style is equivalent to !HilightBack, Hilight3DThick,
 !TitleWarp, TitleUnderlines2, SeparatorsLong, TrianglesRelief,
 PopupImmediately, PopdownDelayed, PopdownDelay 150,
 PopupAsSubmenu, HoldSubmenus, SubmenusRight, BorderWidth 2,
+HotKeyActivatesLastSelectedItem,
 !AutomaticHotkeys, PopupActiveArea 75.</para>
 
 <para><emphasis remap='I'>Win</emphasis>
@@ -141,6 +144,7 @@ style is equivalent to HilightBack, Hilight3DOff, ActiveFore,
 TitleUnderlines1, SeparatorsShort, TrianglesSolid,
 PopupImmediately, PopdownDelayed, PopdownDelay 150,
 PopupAsSubmenu, RemoveSubmenus, SubmenusRight, BorderWidth 2,
+HotKeyActivatesLastSelectedItem,
 !AutomaticHotkeys, PopupActiveArea 75.</para>
 
 <para>
@@ -719,6 +723,17 @@ always overridden if an explicit hot-key is assigned in the
 command.</para>
 
 <para>
+<fvwmopt cmd="MenuStyle" opt="HotKeyActivatesLastSelectedItem"/> and
+<emphasis remap='I'>!HotKeyActivatesLastSelectedItem</emphasis> controls how
+button presses on a menu work when hotkeys are enabled.  By default, if a given
+menu entry only has one completeable match for a given hotkey, that action for
+the given menu entry is invoked and the menu is closed.  This is implied by the
+<emphasis remap='I'>HotKeyActivatesLastSelectedItem</emphasis> option.  However,
+the menu can be told to wait for the user to run the selected item instead, when
+there is only one matched item for a given hotkey, by using the
+<emphasis remap='I'>!HotKeyActivatesLastSelectedItem</emphasis> option.</para>
+
+<para>
 <fvwmopt cmd="MenuStyle" opt="MouseWheel"/>
 controls the ability to scroll the menu using a mouse wheel. It takes
 one argument, that can be one of
diff --git a/fvwm/menubindings.c b/fvwm/menubindings.c
index 62accf3..a125014 100644
--- a/fvwm/menubindings.c
+++ b/fvwm/menubindings.c
@@ -707,7 +707,12 @@ void menu_shortcuts(
 
 		/* For multiple instances of a single hotkey, just move the
 		 * selection */
-		if (countHotkey > 1)
+		/* TA:  2011-07-24:  But if the user has turned off
+		 * "HotKeyActivatesLastSelectedItem", keep the menu open until
+		 * the user has asked for that entry to be enacted.
+		 */
+		if ((countHotkey > 1) || (countHotkey >=1 &&
+					  !MST_HOTKEY_ACTIVATES_LAST(mr)))
 		{
 			*pmi_current = new_item;
 			pmret->rc = MENU_NEWITEM;
diff --git a/fvwm/menustyle.c b/fvwm/menustyle.c
index e33df5a..5ce75aa 100644
--- a/fvwm/menustyle.c
+++ b/fvwm/menustyle.c
@@ -432,6 +432,7 @@ static int menustyle_get_styleopt_index(char *option)
 		"TitleColorset", "HilightTitleBack",
 		"TitleFont",
 		"VerticalMargins",
+		"HotKeyActivatesLastSelectedItem",
 		NULL
 	};
 
@@ -1007,6 +1008,13 @@ MenuStyle *menustyle_parse_style(F_CMD_ARGS)
 			ST_USE_LEFT_SUBMENUS(tmpms) = 0;
 			ST_IS_ANIMATED(tmpms) = 0;
 			ST_USE_AUTOMATIC_HOTKEYS(tmpms) = 0;
+			/* Pressing a hotkey on an item which only has a
+			 * single entry will activate that action; turning
+			 * thos off will make the menu persist until enter or
+			 * space is pressed; the default behaviour is to
+			 * always close the meny and run the action.
+			 */
+			ST_HOTKEY_ACTIVATES_LAST(tmpms) = 1;
 			menustyle_free_face(&ST_FACE(tmpms));
 			ST_FACE(tmpms).type = SimpleMenu;
 			if (ST_PSTDFONT(tmpms) && !ST_USING_DEFAULT_FONT(tmpms))
@@ -1601,6 +1609,9 @@ MenuStyle *menustyle_parse_style(F_CMD_ARGS)
 				&ST_VERTICAL_MARGIN_BOTTOM(tmpms),
 				0, 0);
 			break;
+		case 63: /* HotKeyActivatesLastSelectedItem */
+			ST_HOTKEY_ACTIVATES_LAST(tmpms) = on;
+			break;
 
 #if 0
 		case 99: /* PositionHints */
@@ -1826,6 +1837,7 @@ void menustyle_copy(MenuStyle *origms, MenuStyle *destms)
 
 	/* AutomaticHotkeys */
 	ST_USE_AUTOMATIC_HOTKEYS(destms) = ST_USE_AUTOMATIC_HOTKEYS(origms);
+	ST_HOTKEY_ACTIVATES_LAST(destms) = ST_HOTKEY_ACTIVATES_LAST(origms);
 	/* Item and Title Spacing */
 	ST_ITEM_GAP_ABOVE(destms) =  ST_ITEM_GAP_ABOVE(origms);
 	ST_ITEM_GAP_BELOW(destms) = ST_ITEM_GAP_BELOW(origms);
diff --git a/fvwm/menustyle.h b/fvwm/menustyle.h
index 19c4cff..9ddaf65 100644
--- a/fvwm/menustyle.h
+++ b/fvwm/menustyle.h
@@ -177,6 +177,8 @@
 #define MST_VERTICAL_MARGIN_TOP(m)	  ((m)->s->ms->look.vertical_margins.top)
 #define ST_VERTICAL_MARGIN_BOTTOM(s)  ((s)->look.vertical_margins.bottom)
 #define MST_VERTICAL_MARGIN_BOTTOM(m)	((m)->s->ms->look.vertical_margins.bottom)
+#define ST_HOTKEY_ACTIVATES_LAST(s)   ((s)->feel.flags.hotkey_activates_last)
+#define MST_HOTKEY_ACTIVATES_LAST(m)  ((m)->s->ms->feel.flags.hotkey_activates_last)
 
 /* ---------------------------- type definitions --------------------------- */
 
@@ -221,6 +223,7 @@ typedef struct MenuFeel
 		unsigned use_automatic_hotkeys : 1;
 		unsigned mouse_wheel : 2;
 		unsigned scroll_off_page : 1;
+		unsigned hotkey_activates_last : 1;
 	} flags;
 	int PopdownDelay10ms;
 	int PopupOffsetPercent;

Reply via email to