Changeset f1f433d in mainline for uspace/app/taskbar/wndlist.c


Ignore:
Timestamp:
2022-11-04T20:54:04Z (3 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
master, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
3a6d44b7
Parents:
fc00f0d
Message:

Update window button when window caption changes

File:
1 edited

Legend:

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

    rfc00f0d rf1f433d  
    4848static void wndlist_wm_window_added(void *, sysarg_t);
    4949static void wndlist_wm_window_removed(void *, sysarg_t);
     50static void wndlist_wm_window_changed(void *, sysarg_t);
    5051
    5152static wndmgt_cb_t wndlist_wndmgt_cb = {
    5253        .window_added = wndlist_wm_window_added,
    53         .window_removed = wndlist_wm_window_removed
     54        .window_removed = wndlist_wm_window_removed,
     55        .window_changed = wndlist_wm_window_changed
    5456};
    5557
     
    233235        if (!paint)
    234236                return EOK;
     237
     238        return wndlist_repaint(wndlist);
     239}
     240
     241/** Update window list entry.
     242 *
     243 * @param wndlist Window list
     244 * @param entry Window list entry
     245 * @return @c EOK on success or an error code
     246 */
     247errno_t wndlist_update(wndlist_t *wndlist, wndlist_entry_t *entry,
     248    const char *caption)
     249{
     250        errno_t rc;
     251        assert(entry->wndlist == wndlist);
     252
     253        rc = ui_pbutton_set_caption(entry->button, caption);
     254        if (rc != EOK)
     255                return rc;
     256
     257        rc = ui_pbutton_paint(entry->button);
     258        if (rc != EOK)
     259                return rc;
    235260
    236261        return wndlist_repaint(wndlist);
     
    325350}
    326351
     352/** Handle WM window changed event.
     353 *
     354 * @param arg Argument (wndlist_t *)
     355 * @param wnd_id Window ID
     356 */
     357static void wndlist_wm_window_changed(void *arg, sysarg_t wnd_id)
     358{
     359        wndlist_t *wndlist = (wndlist_t *)arg;
     360        wndmgt_window_info_t *winfo = NULL;
     361        wndlist_entry_t *entry;
     362        errno_t rc;
     363
     364        printf("wm_window_changed: wndlist=%p wnd_id=%zu\n",
     365            (void *)wndlist, wnd_id);
     366
     367        entry = wndlist_entry_by_id(wndlist, wnd_id);
     368        if (entry == NULL)
     369                return;
     370
     371        rc = wndmgt_get_window_info(wndlist->wndmgt, wnd_id, &winfo);
     372        if (rc != EOK)
     373                return;
     374
     375        (void) wndlist_update(wndlist, entry, winfo->caption);
     376        wndmgt_free_window_info(winfo);
     377}
     378
    327379/** Find window list entry by ID.
    328380 *
Note: See TracChangeset for help on using the changeset viewer.