Changeset 4034954c in mainline for uspace/lib/ui/src/menubar.c


Ignore:
Timestamp:
2023-09-27T20:01:51Z (15 months ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
master, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
e54de59
Parents:
5afc1aa
Message:

Do not forget to close system menu. Close first, open second!

When moving out of system menu to menu bar we would forget to
close it. This was only causing noticeable problems in text mode.
Also we first close the current menu, then open the other one,
as juggling multiple popup windows in text mode could cause problems.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/ui/src/menubar.c

    r5afc1aa r4034954c  
    294294}
    295295
     296/** Select first drop-down.
     297 *
     298 * @param mbar Menu bar
     299 * @param openup @c true to open drop-down if it was not open
     300 * @param idev_id Input device ID
     301 */
    296302void ui_menu_bar_select_first(ui_menu_bar_t *mbar, bool openup,
    297303    sysarg_t idev_id)
     
    303309}
    304310
     311/** Select last drop-down.
     312 *
     313 * @param mbar Menu bar
     314 * @param openup @c true to open drop-down if it was not open
     315 * @param idev_id Input device ID
     316 */
    305317void ui_menu_bar_select_last(ui_menu_bar_t *mbar, bool openup,
    306318    sysarg_t idev_id)
     
    312324}
    313325
    314 void ui_menu_bar_select_sysmenu(ui_menu_bar_t *mbar, sysarg_t idev_id)
    315 {
    316         bool was_open;
    317 
     326/** Select system menu.
     327 *
     328 * @param mbar Menu bar
     329 * @param openup @c true to open drop-down if it was not open
     330 * @param idev_id Input device ID
     331 */
     332void ui_menu_bar_select_sysmenu(ui_menu_bar_t *mbar, bool openup,
     333    sysarg_t idev_id)
     334{
    318335        ui_wdecor_sysmenu_hdl_set_active(mbar->window->wdecor, true);
    319         was_open = mbar->selected != NULL &&
    320             ui_menu_dd_is_open(mbar->selected);
    321 
    322         if (was_open)
     336
     337        if (openup)
    323338                ui_window_send_sysmenu(mbar->window, idev_id);
    324339}
     
    335350{
    336351        ui_menu_dd_t *nmdd;
     352        bool sel_sysmenu = false;
     353        bool was_open;
    337354
    338355        if (mbar->selected == NULL)
     
    342359        if (nmdd == NULL) {
    343360                if ((mbar->window->wdecor->style & ui_wds_sysmenu_hdl) != 0) {
    344                         ui_menu_bar_select_sysmenu(mbar, idev_id);
     361                        sel_sysmenu = true;
    345362                } else {
    346363                        nmdd = ui_menu_dd_last(mbar);
     
    348365        }
    349366
     367        was_open = mbar->selected != NULL &&
     368            ui_menu_dd_is_open(mbar->selected);
     369
    350370        if (nmdd != mbar->selected)
    351371                ui_menu_bar_select(mbar, nmdd, false, idev_id);
     372
     373        /*
     374         * Only open sysmenu *after* closing the previous menu, avoid
     375         * having multiple popup windows at the same time.
     376         */
     377        if (sel_sysmenu)
     378                ui_menu_bar_select_sysmenu(mbar, was_open, idev_id);
    352379}
    353380
     
    363390{
    364391        ui_menu_dd_t *nmdd;
     392        bool sel_sysmenu = false;
     393        bool was_open;
    365394
    366395        if (mbar->selected == NULL)
     
    370399        if (nmdd == NULL) {
    371400                if ((mbar->window->wdecor->style & ui_wds_sysmenu_hdl) != 0) {
    372                         ui_menu_bar_select_sysmenu(mbar, idev_id);
     401                        sel_sysmenu = true;
    373402                } else {
    374403                        nmdd = ui_menu_dd_first(mbar);
     
    376405        }
    377406
     407        was_open = mbar->selected != NULL &&
     408            ui_menu_dd_is_open(mbar->selected);
     409
    378410        if (nmdd != mbar->selected)
    379411                ui_menu_bar_select(mbar, nmdd, false, idev_id);
     412
     413        /*
     414         * Only open sysmenu *after* closing the previous menu, avoid
     415         * having multiple popup windows at the same time.
     416         */
     417        if (sel_sysmenu)
     418                ui_menu_bar_select_sysmenu(mbar, was_open, idev_id);
    380419}
    381420
Note: See TracChangeset for help on using the changeset viewer.