diff options
author | Steve Fryatt <stevef@netsurf-browser.org> | 2014-01-29 16:54:34 +0000 |
---|---|---|
committer | Steve Fryatt <stevef@netsurf-browser.org> | 2014-01-29 16:54:34 +0000 |
commit | 0114cc825d8a23ff99ce3a667aebc0ed21b0339f (patch) | |
tree | 5d6e0a143cb02d5a655bfe13f187a726221981f4 /riscos/menus.c | |
parent | 829b4fd4546670512f8543c8bc8ed80372566f08 (diff) | |
download | netsurf-0114cc825d8a23ff99ce3a667aebc0ed21b0339f.tar.gz netsurf-0114cc825d8a23ff99ce3a667aebc0ed21b0339f.tar.bz2 |
Provide a dedicated interface for destroying open menus.
Add ro_gui_menu_destroy(), so that this specific task does not share the same code as the more general task of tidying up after menus have been closed by other means.
The original ro_gui_menu_closed() now simply cleans up from a known (or assumed) closure, without forcing a closure itself.
Diffstat (limited to 'riscos/menus.c')
-rw-r--r-- | riscos/menus.c | 55 |
1 files changed, 31 insertions, 24 deletions
diff --git a/riscos/menus.c b/riscos/menus.c index 91232a160..d8e2f2c16 100644 --- a/riscos/menus.c +++ b/riscos/menus.c @@ -77,7 +77,7 @@ struct menu_definition { struct menu_definition *next; /**< next menu */ }; - +static void ro_gui_menu_closed(void); static void ro_gui_menu_define_menu_add(struct menu_definition *definition, const struct ns_menu *menu, int depth, wimp_menu_entry *parent_entry, @@ -213,6 +213,7 @@ void ro_gui_menu_init(void) * \param y The y position. * \param w The window that the menu belongs to. */ + void ro_gui_menu_create(wimp_menu *menu, int x, int y, wimp_w w) { os_error *error; @@ -252,6 +253,7 @@ void ro_gui_menu_create(wimp_menu *menu, int x, int y, wimp_w w) * \param w window handle * \param i icon handle */ + void ro_gui_popup_menu(wimp_menu *menu, wimp_w w, wimp_i i) { wimp_window_state state; @@ -286,29 +288,24 @@ void ro_gui_popup_menu(wimp_menu *menu, wimp_w w, wimp_i i) /** - * Clean up after a menu has been closed, or forcible close an open menu. - */ -void ro_gui_menu_closed(void) + * Forcibly close any menu or transient dialogue box that is currently open. + */ + +void ro_gui_menu_destroy(void) { os_error *error; - if (current_menu) { - error = xwimp_create_menu(wimp_CLOSE_MENU, 0, 0); - if (error) { - LOG(("xwimp_create_menu: 0x%x: %s", - error->errnum, error->errmess)); - warn_user("MenuError", error->errmess); - } - - ro_gui_wimp_event_menus_closed(current_menu_window, - current_menu_icon, current_menu); + if (current_menu == NULL) + return; - current_menu = NULL; + error = xwimp_create_menu(wimp_CLOSE_MENU, 0, 0); + if (error) { + LOG(("xwimp_create_menu: 0x%x: %s", + error->errnum, error->errmess)); + warn_user("MenuError", error->errmess); } - current_menu_window = NULL; - current_menu_icon = 0; - current_menu_open = false; + ro_gui_menu_closed(); } @@ -450,15 +447,25 @@ void ro_gui_menu_warning(wimp_message_menu_warning *warning) void ro_gui_menu_message_deleted(wimp_message_menus_deleted *deleted) { - if (deleted != NULL && deleted->menu == current_menu) { + if (deleted != NULL && deleted->menu == current_menu) + ro_gui_menu_closed(); +} + + +/** + * Clean up after a menu has been closed, or forcibly close an open menu. + */ + +static void ro_gui_menu_closed(void) +{ + if (current_menu != NULL) ro_gui_wimp_event_menus_closed(current_menu_window, current_menu_icon, current_menu); - current_menu = NULL; - current_menu_window = NULL; - current_menu_icon = 0; - current_menu_open = false; - } + current_menu = NULL; + current_menu_window = NULL; + current_menu_icon = 0; + current_menu_open = false; } |