Changeset 4034954c in mainline


Ignore:
Timestamp:
2023-09-27T20:01:51Z (7 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.

Location:
uspace/lib/ui
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/ui/private/menubar.h

    r5afc1aa r4034954c  
    6767
    6868extern void ui_menu_bar_select(ui_menu_bar_t *, ui_menu_dd_t *, bool, sysarg_t);
    69 extern void ui_menu_bar_select_sysmenu(ui_menu_bar_t *, sysarg_t);
     69extern void ui_menu_bar_select_sysmenu(ui_menu_bar_t *, bool, sysarg_t);
    7070extern void ui_menu_bar_left(ui_menu_bar_t *, sysarg_t);
    7171extern void ui_menu_bar_right(ui_menu_bar_t *, sysarg_t);
  • 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
  • uspace/lib/ui/src/window.c

    r5afc1aa r4034954c  
    10611061
    10621062        if (window->mbar != NULL) {
     1063                ui_wdecor_sysmenu_hdl_set_active(window->wdecor, false);
     1064                ui_menu_close(window->sysmenu);
    10631065                ui_menu_bar_select_last(window->mbar, false, idev_id);
    1064                 ui_wdecor_sysmenu_hdl_set_active(window->wdecor, false);
    10651066        }
    10661067}
     
    10771078
    10781079        if (window->mbar != NULL) {
     1080                ui_wdecor_sysmenu_hdl_set_active(window->wdecor, false);
     1081                ui_menu_close(window->sysmenu);
    10791082                ui_menu_bar_select_first(window->mbar, false, idev_id);
    1080                 ui_wdecor_sysmenu_hdl_set_active(window->wdecor, false);
    10811083        }
    10821084}
     
    10951097
    10961098        if (window->mbar != NULL) {
     1099                ui_wdecor_sysmenu_hdl_set_active(window->wdecor, false);
     1100                ui_menu_close(window->sysmenu);
    10971101                ui_menu_bar_press_accel(window->mbar, c, idev_id);
    1098                 ui_wdecor_sysmenu_hdl_set_active(window->wdecor, false);
    10991102        }
    11001103}
     
    15501553        ui_window_t *window = (ui_window_t *)arg;
    15511554
    1552         (void)sysmenu;
    1553 
    1554         if (window->mbar != NULL)
     1555        if (window->mbar != NULL) {
     1556                ui_wdecor_sysmenu_hdl_set_active(window->wdecor, false);
     1557                ui_menu_close(sysmenu);
    15551558                ui_menu_bar_select_last(window->mbar, true, idev_id);
     1559        }
    15561560}
    15571561
     
    15661570        ui_window_t *window = (ui_window_t *)arg;
    15671571
    1568         (void)sysmenu;
    1569 
    1570         if (window->mbar != NULL)
     1572        if (window->mbar != NULL) {
     1573                ui_wdecor_sysmenu_hdl_set_active(window->wdecor, false);
     1574                ui_menu_close(sysmenu);
    15711575                ui_menu_bar_select_first(window->mbar, true, idev_id);
     1576        }
    15721577}
    15731578
  • uspace/lib/ui/test/menubar.c

    r5afc1aa r4034954c  
    453453        PCUT_ASSERT_NOT_NULL(mdd2);
    454454
    455         ui_menu_bar_select_sysmenu(mbar, 0);
     455        ui_menu_bar_select_sysmenu(mbar, false, 0);
    456456        PCUT_ASSERT_TRUE(window->wdecor->sysmenu_hdl_active);
    457457
Note: See TracChangeset for help on using the changeset viewer.