Changeset 7a05d924 in mainline for uspace/app/taskbar


Ignore:
Timestamp:
2022-10-20T08:05:06Z (3 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
master, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
7cc30e9
Parents:
1766326
git-author:
Jiri Svoboda <jiri@…> (2022-10-19 18:04:42)
git-committer:
Jiri Svoboda <jiri@…> (2022-10-20 08:05:06)
Message:

Return correct number of windows from display server

But not the caption since the display server does not have it

Location:
uspace/app/taskbar
Files:
4 edited

Legend:

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

    r1766326 r7a05d924  
    174174        }
    175175
    176         rc = wndlist_append(taskbar->wndlist, "Text Editor");
    177         if (rc != EOK) {
    178                 printf("Error adding window list entry.\n");
     176        rc = wndlist_attach_wm(taskbar->wndlist, taskbar->wndmgt);
     177        if (rc != EOK) {
     178                printf("Error attaching window management service.\n");
    179179                goto error;
    180180        }
  • uspace/app/taskbar/types/wndlist.h

    r1766326 r7a05d924  
    4242#include <ui/fixed.h>
    4343#include <ui/resource.h>
     44#include <wndmgt.h>
    4445
    4546/** Taskbar window list entry */
     
    6970        /** Window list entries (of wndlist_entry_t) */
    7071        list_t entries;
     72
     73        /** Window management service */
     74        wndmgt_t *wndmgt;
    7175} wndlist_t;
    7276
  • uspace/app/taskbar/wndlist.c

    r1766326 r7a05d924  
    4949 * @param res UI resource
    5050 * @param fixed Fixed layout to which buttons will be added
     51 * @param wndmgt Window management service
    5152 * @param rwndlist Place to store pointer to new window list
    5253 * @return @c EOK on success or an error code
     
    7172error:
    7273        return rc;
     74}
    7375
     76/** Attach window management service to window list.
     77 *
     78 * @param wndlist Window list
     79 * @param rwndlist Place to store pointer to new window list
     80 * @return @c EOK on success or an error code
     81 */
     82errno_t wndlist_attach_wm(wndlist_t *wndlist, wndmgt_t *wndmgt)
     83{
     84        errno_t rc;
     85        wndmgt_window_list_t *wlist = NULL;
     86        wndmgt_window_info_t *winfo = NULL;
     87        sysarg_t i;
     88
     89        rc = wndmgt_get_window_list(wndmgt, &wlist);
     90        if (rc != EOK)
     91                goto error;
     92
     93        for (i = 0; i < wlist->nwindows; i++) {
     94                rc = wndmgt_get_window_info(wndmgt, wlist->windows[i],
     95                    &winfo);
     96                if (rc != EOK)
     97                        goto error;
     98
     99                rc = wndlist_append(wndlist, winfo->caption);
     100                if (rc != EOK) {
     101                        wndmgt_free_window_info(winfo);
     102                        goto error;
     103                }
     104
     105                wndmgt_free_window_info(winfo);
     106        }
     107
     108        wndlist->wndmgt = wndmgt;
     109        return EOK;
     110error:
     111        if (wlist != NULL)
     112                wndmgt_free_window_list(wlist);
     113        return rc;
    74114}
    75115
     
    90130        wndlist_entry_t *entry = NULL;
    91131        gfx_rect_t rect;
     132        size_t nentries;
    92133        errno_t rc;
     134
     135        /* Number of existing entries */
     136        nentries = list_count(&wndlist->entries);
    93137
    94138        entry = calloc(1, sizeof(wndlist_entry_t));
     
    103147
    104148        if (ui_resource_is_textmode(wndlist->res)) {
    105                 rect.p0.x = 9;
     149                rect.p0.x = 17 * nentries + 9;
    106150                rect.p0.y = 0;
    107                 rect.p1.x = 25;
     151                rect.p1.x = 17 * nentries + 25;
    108152                rect.p1.y = 1;
    109153        } else {
    110                 rect.p0.x = 90;
     154                rect.p0.x = 145 * nentries + 90;
    111155                rect.p0.y = 3;
    112                 rect.p1.x = 230;
     156                rect.p1.x = 145 * nentries + 230;
    113157                rect.p1.y = 29;
    114158        }
  • uspace/app/taskbar/wndlist.h

    r1766326 r7a05d924  
    4040#include <ui/fixed.h>
    4141#include <ui/resource.h>
     42#include <wndmgt.h>
    4243#include "types/wndlist.h"
    4344
    4445extern errno_t wndlist_create(ui_resource_t *, ui_fixed_t *, wndlist_t **);
     46extern errno_t wndlist_attach_wm(wndlist_t *, wndmgt_t *);
    4547extern void wndlist_destroy(wndlist_t *);
    4648extern errno_t wndlist_append(wndlist_t *, const char *);
Note: See TracChangeset for help on using the changeset viewer.