From 933c642019fd1c2bbb0dc4159b8cfc75a67ebaf4 Mon Sep 17 00:00:00 2001 From: Richard Wilson Date: Mon, 26 Mar 2007 20:33:50 +0000 Subject: [PATCH] Call close function for submenu windows. svn path=/trunk/netsurf/; revision=3226 --- riscos/menus.c | 7 +++---- riscos/wimp_event.c | 19 +++++++++++++++++++ riscos/wimp_event.h | 3 +++ 3 files changed, 25 insertions(+), 4 deletions(-) diff --git a/riscos/menus.c b/riscos/menus.c index 8b14be40f..25d0df3b3 100644 --- a/riscos/menus.c +++ b/riscos/menus.c @@ -574,10 +574,7 @@ void ro_gui_menu_closed(bool cleanup) { current_menu = NULL; if (cleanup) { - /* end any search operation that was started so that - the text doesn't remain highlighted */ - if (ro_gui_menu_search_window_menu) - ro_gui_search_end(dialog_search); + ro_gui_wimp_event_menus_closed(); if (tree) ro_gui_tree_menu_closed(tree); @@ -726,6 +723,7 @@ void ro_gui_menu_warning(wimp_message_menu_warning *warning) { entries[warning->selection.items[i]]; if (IS_MENU(menu_entry->sub_menu)) { + ro_gui_wimp_event_register_submenu((wimp_w)0); sub_menu = menu_entry->sub_menu; i = 0; do { @@ -736,6 +734,7 @@ void ro_gui_menu_warning(wimp_message_menu_warning *warning) { action, false); } while (!(sub_menu->entries[i++].menu_flags & wimp_MENU_LAST)); } else { + ro_gui_wimp_event_register_submenu((wimp_w)menu_entry->sub_menu); action = ro_gui_menu_find_action(current_menu, menu_entry); if (action != NO_ACTION) ro_gui_menu_prepare_action(current_menu_window, diff --git a/riscos/wimp_event.c b/riscos/wimp_event.c index b8690f5c0..87ed789ff 100644 --- a/riscos/wimp_event.c +++ b/riscos/wimp_event.c @@ -100,6 +100,7 @@ static struct event_window *ro_gui_wimp_event_remove_window(wimp_w w); static struct event_window *ro_gui_wimp_event_windows[WIN_HASH_SIZE]; +static wimp_w ro_gui_wimp_event_submenu; /** * Memorises the current state of any registered components in a window. @@ -856,6 +857,8 @@ bool ro_gui_wimp_event_close_window(wimp_w w) { struct event_window *window; LOG(("Close event received for window 0x%x", (unsigned int)w)); + if (w == ro_gui_wimp_event_submenu) + ro_gui_wimp_event_submenu = 0; window = ro_gui_wimp_event_find_window(w); if ((window) && (window->close_window)) { window->close_window(w); @@ -1216,3 +1219,19 @@ struct icon_event *ro_gui_wimp_event_get_event(wimp_w w, wimp_i i, event_type ty return event; } + +/** + * Handle menus being closed + */ +void ro_gui_wimp_event_menus_closed(void) { + ro_gui_wimp_event_register_submenu(0); +} + +/** + * Register a submenu as being opened + */ +void ro_gui_wimp_event_register_submenu(wimp_w w) { + if (ro_gui_wimp_event_submenu) + ro_gui_wimp_event_close_window(ro_gui_wimp_event_submenu); + ro_gui_wimp_event_submenu = w; +} diff --git a/riscos/wimp_event.h b/riscos/wimp_event.h index 48c25a416..7fc2d89c8 100644 --- a/riscos/wimp_event.h +++ b/riscos/wimp_event.h @@ -68,4 +68,7 @@ bool ro_gui_wimp_event_register_redraw_window(wimp_w w, bool ro_gui_wimp_event_register_menu_selection(wimp_w w, void (*callback)(wimp_w w, wimp_i i)); +void ro_gui_wimp_event_menus_closed(void); +void ro_gui_wimp_event_register_submenu(wimp_w w); + #endif