Changeset 3c54869 in mainline for uspace/app/taskbar


Ignore:
Timestamp:
2023-01-04T20:24:44Z (3 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
master, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
5d86797
Parents:
cdd6fc9
Message:

Highlight active window in task bar

Location:
uspace/app/taskbar
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • uspace/app/taskbar/test/wndlist.c

    rcdd6fc9 r3c54869  
    11/*
    2  * Copyright (c) 2022 Jiri Svoboda
     2 * Copyright (c) 2023 Jiri Svoboda
    33 * All rights reserved.
    44 *
     
    208208        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
    209209
    210         rc = wndlist_append(wndlist, 123, "Foo", true);
     210        rc = wndlist_append(wndlist, 123, "Foo", true, true);
    211211        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
    212212
     
    214214        PCUT_ASSERT_INT_EQUALS(123, entry->wnd_id);
    215215        PCUT_ASSERT_NOT_NULL(entry->button);
     216        PCUT_ASSERT_TRUE(ui_pbutton_get_light(entry->button));
    216217
    217218        wndlist_destroy(wndlist);
     
    248249        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
    249250
    250         rc = wndlist_append(wndlist, 1, "Foo", true);
    251         PCUT_ASSERT_ERRNO_VAL(EOK, rc);
    252 
    253         rc = wndlist_append(wndlist, 2, "Bar", true);
     251        rc = wndlist_append(wndlist, 1, "Foo", true, true);
     252        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
     253
     254        rc = wndlist_append(wndlist, 2, "Bar", false, true);
    254255        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
    255256
     
    269270}
    270271
     272/** Test updating entry */
     273PCUT_TEST(update)
     274{
     275        errno_t rc;
     276        ui_t *ui = NULL;
     277        ui_wnd_params_t params;
     278        ui_window_t *window = NULL;
     279        ui_fixed_t *fixed = NULL;
     280        wndlist_t *wndlist;
     281        wndlist_entry_t *entry;
     282
     283        rc = ui_create_disp(NULL, &ui);
     284        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
     285
     286        ui_wnd_params_init(&params);
     287        params.caption = "Hello";
     288
     289        rc = ui_window_create(ui, &params, &window);
     290        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
     291        PCUT_ASSERT_NOT_NULL(window);
     292
     293        rc = ui_fixed_create(&fixed);
     294        ui_window_add(window, ui_fixed_ctl(fixed));
     295
     296        rc = wndlist_create(window, fixed, &wndlist);
     297        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
     298
     299        rc = wndlist_append(wndlist, 1, "Foo", true, true);
     300        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
     301
     302        entry = wndlist_first(wndlist);
     303        PCUT_ASSERT_INT_EQUALS(1, entry->wnd_id);
     304        PCUT_ASSERT_NOT_NULL(entry->button);
     305        PCUT_ASSERT_TRUE(ui_pbutton_get_light(entry->button));
     306
     307        rc = wndlist_update(wndlist, entry, "Bar", false);
     308        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
     309
     310        PCUT_ASSERT_INT_EQUALS(1, entry->wnd_id);
     311        PCUT_ASSERT_NOT_NULL(entry->button);
     312        PCUT_ASSERT_FALSE(ui_pbutton_get_light(entry->button));
     313
     314        wndlist_destroy(wndlist);
     315
     316        ui_window_destroy(window);
     317        ui_destroy(ui);
     318}
     319
    271320/** Test setting entry rectangle */
    272321PCUT_TEST(set_entry_rect)
     
    296345        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
    297346
    298         rc = wndlist_append(wndlist, 123, "Foo", true);
     347        rc = wndlist_append(wndlist, 123, "Foo", true, true);
    299348        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
    300349
     
    337386        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
    338387
    339         rc = wndlist_append(wndlist, 1, "Foo", true);
    340         PCUT_ASSERT_ERRNO_VAL(EOK, rc);
    341 
    342         rc = wndlist_append(wndlist, 2, "Bar", true);
     388        rc = wndlist_append(wndlist, 1, "Foo", true, true);
     389        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
     390
     391        rc = wndlist_append(wndlist, 2, "Bar", false, true);
    343392        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
    344393
     
    384433        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
    385434
    386         rc = wndlist_append(wndlist, 1, "Foo", true);
    387         PCUT_ASSERT_ERRNO_VAL(EOK, rc);
    388 
    389         rc = wndlist_append(wndlist, 2, "Bar", true);
     435        rc = wndlist_append(wndlist, 1, "Foo", true, true);
     436        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
     437
     438        rc = wndlist_append(wndlist, 2, "Bar", false, true);
    390439        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
    391440
     
    434483        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
    435484
    436         rc = wndlist_append(wndlist, 1, "Foo", true);
    437         PCUT_ASSERT_ERRNO_VAL(EOK, rc);
    438 
    439         rc = wndlist_append(wndlist, 2, "Bar", true);
     485        rc = wndlist_append(wndlist, 1, "Foo", true, true);
     486        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
     487
     488        rc = wndlist_append(wndlist, 2, "Bar", false, true);
    440489        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
    441490
     
    480529        PCUT_ASSERT_INT_EQUALS(0, count);
    481530
    482         rc = wndlist_append(wndlist, 1, "Foo", true);
     531        rc = wndlist_append(wndlist, 1, "Foo", true, true);
    483532        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
    484533
     
    486535        PCUT_ASSERT_INT_EQUALS(1, count);
    487536
    488         rc = wndlist_append(wndlist, 2, "Bar", true);
     537        rc = wndlist_append(wndlist, 2, "Bar", false, true);
    489538        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
    490539
     
    524573        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
    525574
    526         rc = wndlist_append(wndlist, 1, "Foo", true);
    527         PCUT_ASSERT_ERRNO_VAL(EOK, rc);
    528 
    529         rc = wndlist_append(wndlist, 2, "Bar", true);
     575        rc = wndlist_append(wndlist, 1, "Foo", true, true);
     576        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
     577
     578        rc = wndlist_append(wndlist, 2, "Bar", false, true);
    530579        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
    531580
  • uspace/app/taskbar/wndlist.c

    rcdd6fc9 r3c54869  
    11/*
    2  * Copyright (c) 2022 Jiri Svoboda
     2 * Copyright (c) 2023 Jiri Svoboda
    33 * All rights reserved.
    44 *
     
    157157                if ((winfo->flags & (wndf_popup | wndf_system)) == 0) {
    158158                        rc = wndlist_append(wndlist, wlist->windows[i],
    159                             winfo->caption, false);
     159                            winfo->caption, winfo->nfocus != 0, false);
    160160                        if (rc != EOK) {
    161161                                wndmgt_free_window_info(winfo);
     
    202202 * @param wnd_id Window ID
    203203 * @param caption Entry caption
     204 * @param active @c true iff window is active
    204205 * @param paint @c true to paint immediately
    205206 * @return @c EOK on success or an error code
    206207 */
    207208errno_t wndlist_append(wndlist_t *wndlist, sysarg_t wnd_id,
    208     const char *caption, bool paint)
     209    const char *caption, bool active, bool paint)
    209210{
    210211        wndlist_entry_t *entry = NULL;
     
    230231
    231232        entry->visible = false;
     233
     234        ui_pbutton_set_light(entry->button, active);
    232235
    233236        /* Set button callbacks */
     
    382385 * @param wndlist Window list
    383386 * @param entry Window list entry
     387 * @param active @c true iff the window is active
    384388 * @return @c EOK on success or an error code
    385389 */
    386390errno_t wndlist_update(wndlist_t *wndlist, wndlist_entry_t *entry,
    387     const char *caption)
     391    const char *caption, bool active)
    388392{
    389393        errno_t rc;
     
    393397        if (rc != EOK)
    394398                return rc;
     399
     400        ui_pbutton_set_light(entry->button, active);
    395401
    396402        rc = ui_pbutton_paint(entry->button);
     
    507513
    508514        if ((winfo->flags & (wndf_popup | wndf_system)) == 0) {
    509                 rc = wndlist_append(wndlist, wnd_id, winfo->caption, true);
     515                rc = wndlist_append(wndlist, wnd_id, winfo->caption,
     516                    winfo->nfocus != 0, true);
    510517                if (rc != EOK) {
    511518                        wndmgt_free_window_info(winfo);
     
    558565                return;
    559566
    560         (void) wndlist_update(wndlist, entry, winfo->caption);
     567        (void) wndlist_update(wndlist, entry, winfo->caption,
     568            winfo->nfocus != 0);
    561569        wndmgt_free_window_info(winfo);
    562570}
  • uspace/app/taskbar/wndlist.h

    rcdd6fc9 r3c54869  
    11/*
    2  * Copyright (c) 2022 Jiri Svoboda
     2 * Copyright (c) 2023 Jiri Svoboda
    33 * All rights reserved.
    44 *
     
    5050extern errno_t wndlist_open_wm(wndlist_t *, const char *);
    5151extern void wndlist_destroy(wndlist_t *);
    52 extern errno_t wndlist_append(wndlist_t *, sysarg_t, const char *, bool);
     52extern errno_t wndlist_append(wndlist_t *, sysarg_t, const char *, bool,
     53    bool);
    5354extern errno_t wndlist_remove(wndlist_t *, wndlist_entry_t *, bool);
    5455extern bool wndlist_update_pitch(wndlist_t *);
    55 extern errno_t wndlist_update(wndlist_t *, wndlist_entry_t *, const char *);
     56extern errno_t wndlist_update(wndlist_t *, wndlist_entry_t *, const char *,
     57    bool);
    5658extern void wndlist_set_entry_rect(wndlist_t *, wndlist_entry_t *);
    5759extern wndlist_entry_t *wndlist_entry_by_id(wndlist_t *, sysarg_t);
Note: See TracChangeset for help on using the changeset viewer.