Allow infinite delay for submenu show/hide by using a negative value.

This commit is contained in:
Dana Jansens 2010-01-04 15:26:10 -05:00
parent b88cf22bc0
commit e8588737c9
2 changed files with 15 additions and 11 deletions

View file

@ -633,11 +633,15 @@
<middle>no</middle> <middle>no</middle>
<!-- center submenus vertically about the parent entry --> <!-- center submenus vertically about the parent entry -->
<submenuShowDelay>200</submenuShowDelay> <submenuShowDelay>200</submenuShowDelay>
<!-- this one is easy, time to delay before showing a submenu after hovering <!-- time to delay before showing a submenu after hovering over the parent
over the parent entry --> entry.
if this is a negative value, then the delay is infinite and the
submenu will not be shown until it is clicked on -->
<submenuHideDelay>400</submenuHideDelay> <submenuHideDelay>400</submenuHideDelay>
<!-- time to delay before hiding a submenu when selecting another <!-- time to delay before hiding a submenu when selecting another
entry in parent menu --> entry in parent menu -->
if this is a negative value, then the delay is infinite and the
submenu will not be hidden until a different submenu is opened -->
<applicationIcons>yes</applicationIcons> <applicationIcons>yes</applicationIcons>
<!-- controls if icons appear in the client-list-(combined-)menu --> <!-- controls if icons appear in the client-list-(combined-)menu -->
<manageDesktops>yes</manageDesktops> <manageDesktops>yes</manageDesktops>

View file

@ -1160,7 +1160,9 @@ void menu_frame_select(ObMenuFrame *self, ObMenuEntryFrame *entry,
if (entry && entry->entry->type == OB_MENU_ENTRY_TYPE_SEPARATOR) if (entry && entry->entry->type == OB_MENU_ENTRY_TYPE_SEPARATOR)
entry = old; entry = old;
if (old == entry) return; if (old == entry && (old->entry->type != OB_MENU_ENTRY_TYPE_SUBMENU ||
old == oldchild_entry))
return;
/* if the user left this menu but we have a submenu open, move the /* if the user left this menu but we have a submenu open, move the
selection back to that submenu */ selection back to that submenu */
@ -1187,16 +1189,15 @@ void menu_frame_select(ObMenuFrame *self, ObMenuEntryFrame *entry,
else if (oldchild_entry == old) { else if (oldchild_entry == old) {
/* The open submenu was selected and is no longer, so hide the /* The open submenu was selected and is no longer, so hide the
submenu */ submenu */
if (!immediate && config_submenu_hide_delay) { if (immediate || config_submenu_hide_delay == 0)
menu_frame_hide(oldchild);
else if (config_submenu_hide_delay > 0)
ob_main_loop_timeout_add(ob_main_loop, ob_main_loop_timeout_add(ob_main_loop,
config_submenu_hide_delay * 1000, config_submenu_hide_delay * 1000,
submenu_hide_timeout, submenu_hide_timeout,
oldchild, g_direct_equal, oldchild, g_direct_equal,
NULL); NULL);
} }
else
menu_frame_hide(oldchild);
}
} }
if (self->selected) { if (self->selected) {
@ -1206,15 +1207,14 @@ void menu_frame_select(ObMenuFrame *self, ObMenuEntryFrame *entry,
if (oldchild_entry != self->selected && if (oldchild_entry != self->selected &&
self->selected->entry->type == OB_MENU_ENTRY_TYPE_SUBMENU) self->selected->entry->type == OB_MENU_ENTRY_TYPE_SUBMENU)
{ {
if (config_submenu_show_delay && !immediate) { if (immediate || config_submenu_hide_delay == 0)
/* initiate a new submenu open request */ menu_entry_frame_show_submenu(self->selected);
else if (config_submenu_hide_delay > 0)
ob_main_loop_timeout_add(ob_main_loop, ob_main_loop_timeout_add(ob_main_loop,
config_submenu_show_delay * 1000, config_submenu_show_delay * 1000,
submenu_show_timeout, submenu_show_timeout,
self->selected, g_direct_equal, self->selected, g_direct_equal,
NULL); NULL);
} else
menu_entry_frame_show_submenu(self->selected);
} }
} }
} }