Fork us on GitHub Follow us on Facebook Follow us on Twitter

Changeset e422ff6 in mainline


Ignore:
Timestamp:
2019-11-06T21:10:53Z (16 months ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
master
Children:
bfddc62
Parents:
959b7ec
Message:

ds_client_get_event() should not block if no events are pending

This is a relic of older design that didn't use pending event notification
via callback session.

Location:
uspace/srv/hid/display
Files:
3 edited

Legend:

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

    r959b7ec re422ff6  
    3434 */
    3535
     36#include <adt/list.h>
    3637#include <errno.h>
    3738#include <stdlib.h>
     
    5859
    5960        list_initialize(&client->windows);
    60         prodcons_initialize(&client->events);
     61        list_initialize(&client->events);
    6162        client->cb = cb;
    6263        client->cb_arg = cb_arg;
     
    162163/** Get next event from client event queue.
    163164 *
    164  * This function blocks until an event is available.
    165  *
    166  * @param wnd Window
     165 * @param client Client
     166 * @param ewindow Place to store pointer to window receiving the event
     167 * @param event Place to store event
    167168 * @return Graphic context
    168169 */
     
    173174        ds_window_ev_t *wevent;
    174175
    175         link = prodcons_consume(&client->events);
     176        link = list_first(&client->events);
     177        if (link == NULL)
     178                return ENOENT;
    176179        wevent = list_get_instance(link, ds_window_ev_t, levents);
    177180
     
    182185}
    183186
     187/** Post keyboard event to the client's message queue.
     188 *
     189 * @param client Client
     190 * @param ewindow Window that the message is targetted to
     191 * @param event Event
     192 *
     193 * @return EOK on success or an error code
     194 */
    184195errno_t ds_client_post_kbd_event(ds_client_t *client, ds_window_t *ewindow,
    185196    kbd_event_t *event)
     
    193204        wevent->window = ewindow;
    194205        wevent->event.kbd_event = *event;
    195         prodcons_produce(&client->events, &wevent->levents);
     206        list_append(&wevent->levents, &client->events);
    196207
    197208        /* Notify the client */
  • uspace/srv/hid/display/test/client.c

    r959b7ec re422ff6  
    180180        PCUT_ASSERT_FALSE(called_cb);
    181181
    182 #if 0
    183         // XXX Forgot to change ds_client_get_event not to block
    184182        rc = ds_client_get_event(client, &rwindow, &revent);
    185183        PCUT_ASSERT_ERRNO_VAL(ENOENT, rc);
    186 #endif
    187184
    188185        rc = ds_client_post_kbd_event(client, wnd, &event);
  • uspace/srv/hid/display/types/display/client.h

    r959b7ec re422ff6  
    3838
    3939#include <adt/list.h>
    40 #include <adt/prodcons.h>
    4140
    4241typedef sysarg_t ds_wnd_id_t;
     
    6059        list_t windows;
    6160        /** Event queue (of ds_window_ev_t) */
    62         prodcons_t events;
     61        list_t events;
    6362} ds_client_t;
    6463
Note: See TracChangeset for help on using the changeset viewer.