Changeset 913add60 in mainline for uspace/srv/hid/display/wmops.c


Ignore:
Timestamp:
2022-10-31T10:53:53Z (16 months ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
master, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
1b92d4b
Parents:
7cc30e9
git-author:
Jiri Svoboda <jiri@…> (2022-10-30 10:53:48)
git-committer:
Jiri Svoboda <jiri@…> (2022-10-31 10:53:53)
Message:

Deliver WM events for windows being added and removed

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/hid/display/wmops.c

    r7cc30e9 r913add60  
    4040#include <wndmgt_srv.h>
    4141#include "display.h"
     42#include "wmclient.h"
    4243
    4344static errno_t dispwm_get_window_list(void *, wndmgt_window_list_t **);
     
    5556};
    5657
     58/** Get window list.
     59 *
     60 * @param arg Argument (WM client)
     61 * @param rlist Place to store pointer to new list
     62 * @return EOK on success or an error code
     63 */
    5764static errno_t dispwm_get_window_list(void *arg, wndmgt_window_list_t **rlist)
    5865{
     66        ds_wmclient_t *wmclient = (ds_wmclient_t *)arg;
    5967        wndmgt_window_list_t *list;
    60         ds_display_t *disp = (ds_display_t *)arg;
    6168        ds_window_t *wnd;
    6269        unsigned i;
     
    6875                return ENOMEM;
    6976
     77        ds_display_lock(wmclient->display);
     78
    7079        /* Count the number of windows */
    7180        list->nwindows = 0;
    72         wnd = ds_display_first_window(disp);
     81        wnd = ds_display_first_window(wmclient->display);
    7382        while (wnd != NULL) {
    7483                ++list->nwindows;
     
    7988        list->windows = calloc(list->nwindows, sizeof(sysarg_t));
    8089        if (list->windows == NULL) {
     90                ds_display_unlock(wmclient->display);
    8191                free(list);
    8292                return ENOMEM;
     
    8595        /* Fill in window IDs */
    8696        i = 0;
    87         wnd = ds_display_first_window(disp);
     97        wnd = ds_display_first_window(wmclient->display);
    8898        while (wnd != NULL) {
    8999                list->windows[i++] = wnd->id;
     
    91101        }
    92102
     103        ds_display_unlock(wmclient->display);
    93104        *rlist = list;
    94105        return EOK;
    95106}
    96107
     108/** Get window information.
     109 *
     110 * @param arg Argument (WM client)
     111 * @param wnd_id Window ID
     112 * @param rinfo Place to store pointer to new window information structure
     113 * @return EOK on success or an error code
     114 */
    97115static errno_t dispwm_get_window_info(void *arg, sysarg_t wnd_id,
    98116    wndmgt_window_info_t **rinfo)
    99117{
    100         ds_display_t *disp = (ds_display_t *)arg;
     118        ds_wmclient_t *wmclient = (ds_wmclient_t *)arg;
    101119        ds_window_t *wnd;
    102120        wndmgt_window_info_t *info;
     
    104122        log_msg(LOG_DEFAULT, LVL_DEBUG, "dispwm_get_window_info()");
    105123
    106         wnd = ds_display_find_window(disp, wnd_id);
    107         if (wnd == NULL)
     124        ds_display_lock(wmclient->display);
     125        wnd = ds_display_find_window(wmclient->display, wnd_id);
     126        if (wnd == NULL) {
     127                ds_display_unlock(wmclient->display);
    108128                return ENOENT;
     129        }
    109130
    110131        info = calloc(1, sizeof(wndmgt_window_info_t));
    111         if (info == NULL)
     132        if (info == NULL) {
     133                ds_display_unlock(wmclient->display);
    112134                return ENOMEM;
     135        }
    113136
    114137        info->caption = str_dup(wnd->caption);
    115138        if (info->caption == NULL) {
     139                ds_display_unlock(wmclient->display);
    116140                free(info);
    117141                return ENOMEM;
    118142        }
    119143
     144        ds_display_unlock(wmclient->display);
    120145        *rinfo = info;
    121146        return EOK;
    122147}
    123148
     149/** Activate window.
     150 *
     151 * @param arg Argument (WM client)
     152 * @param wnd_id Window ID
     153 * @return EOK on success or an error code
     154 */
    124155static errno_t dispwm_activate_window(void *arg, sysarg_t wnd_id)
    125156{
     
    130161}
    131162
     163/** Close window.
     164 *
     165 * @param arg Argument (WM client)
     166 * @param wnd_id Window ID
     167 * @return EOK on success or an error code
     168 */
    132169static errno_t dispwm_close_window(void *arg, sysarg_t wnd_id)
    133170{
     
    138175}
    139176
     177/** Get window management event.
     178 *
     179 * @param arg Argument (WM client)
     180 * @param ev Place to store event
     181 * @return EOK on success, ENOENT if there are no events
     182 */
    140183static errno_t dispwm_get_event(void *arg, wndmgt_ev_t *ev)
    141184{
    142         return ENOTSUP;
     185        ds_wmclient_t *wmclient = (ds_wmclient_t *)arg;
     186        errno_t rc;
     187
     188        log_msg(LOG_DEFAULT, LVL_DEBUG, "dispwm_get_event()");
     189
     190        ds_display_lock(wmclient->display);
     191        rc = ds_wmclient_get_event(wmclient, ev);
     192        ds_display_unlock(wmclient->display);
     193        return rc;
    143194}
    144195
Note: See TracChangeset for help on using the changeset viewer.