Changeset b3c185b6 in mainline for uspace/lib/display/src/disp_srv.c


Ignore:
Timestamp:
2019-11-04T14:05:35Z (4 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
be15256
Parents:
22faaf2
git-author:
Jiri Svoboda <jiri@…> (2019-10-03 18:05:09)
git-committer:
Jiri Svoboda <jiri@…> (2019-11-04 14:05:35)
Message:

Window event delivery mechanism

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/display/src/disp_srv.c

    r22faaf2 rb3c185b6  
    3636
    3737#include <disp_srv.h>
     38#include <display/event.h>
    3839#include <errno.h>
     40#include <io/log.h>
    3941#include <ipc/display.h>
    4042#include <stdlib.h>
    4143#include <stddef.h>
     44
     45#include <stdio.h>
     46static void display_callback_create_srv(display_srv_t *srv, ipc_call_t *call)
     47{
     48        printf("display_callback_create_srv\n");
     49
     50        async_sess_t *sess = async_callback_receive(EXCHANGE_SERIALIZE);
     51        if (sess == NULL) {
     52                async_answer_0(call, ENOMEM);
     53                return;
     54        }
     55
     56        srv->client_sess = sess;
     57        async_answer_0(call, EOK);
     58}
    4259
    4360static void display_window_create_srv(display_srv_t *srv, ipc_call_t *icall)
     
    4562        sysarg_t wnd_id;
    4663        errno_t rc;
     64
     65        printf("display_window_create_srv\n");
    4766
    4867        if (srv->ops->window_create == NULL) {
     
    6079        errno_t rc;
    6180
     81        printf("display_window_destroy_srv\n");
     82
    6283        wnd_id = ipc_get_arg1(icall);
    6384
     
    7192}
    7293
     94static void display_get_event_srv(display_srv_t *srv, ipc_call_t *icall)
     95{
     96        sysarg_t wnd_id;
     97        display_wnd_ev_t event;
     98        ipc_call_t call;
     99        size_t size;
     100        errno_t rc;
     101
     102        printf("display_get_event_srv\n");
     103
     104        if (srv->ops->get_event == NULL) {
     105                async_answer_0(icall, ENOTSUP);
     106                return;
     107        }
     108
     109        rc = srv->ops->get_event(srv->arg, &wnd_id, &event);
     110        if (rc != EOK)
     111                async_answer_0(icall, rc);
     112
     113        /* Transfer event data */
     114        if (!async_data_read_receive(&call, &size)) {
     115                async_answer_0(icall, EREFUSED);
     116                return;
     117        }
     118
     119        if (size != sizeof(event)) {
     120                async_answer_0(icall, EREFUSED);
     121                async_answer_0(&call, EREFUSED);
     122                return;
     123        }
     124
     125        rc = async_data_read_finalize(&call, &event, sizeof(event));
     126        if (rc != EOK) {
     127                async_answer_0(icall, rc);
     128                async_answer_0(&call, rc);
     129                return;
     130        }
     131
     132        async_answer_1(icall, EOK, wnd_id);
     133}
     134
    73135void display_conn(ipc_call_t *icall, display_srv_t *srv)
    74136{
    75137        /* Accept the connection */
    76138        async_accept_0(icall);
     139        printf("display_conn\n");
    77140
    78141        while (true) {
     
    88151                }
    89152
     153                printf("display_conn method=%lu\n", method);
    90154                switch (method) {
     155                case DISPLAY_CALLBACK_CREATE:
     156                        display_callback_create_srv(srv, &call);
     157                        break;
    91158                case DISPLAY_WINDOW_CREATE:
    92159                        display_window_create_srv(srv, &call);
     
    94161                case DISPLAY_WINDOW_DESTROY:
    95162                        display_window_destroy_srv(srv, &call);
     163                        break;
     164                case DISPLAY_GET_EVENT:
     165                        display_get_event_srv(srv, &call);
    96166                        break;
    97167                default:
     
    101171}
    102172
     173/** Send 'pending' event to client.
     174 *
     175 * @param srv Display server structure
     176 */
     177void display_srv_ev_pending(display_srv_t *srv)
     178{
     179        async_exch_t *exch;
     180
     181        printf("display_srv_ev_pending()\n");
     182
     183        exch = async_exchange_begin(srv->client_sess);
     184        async_msg_0(exch, DISPLAY_EV_PENDING);
     185        async_exchange_end(exch);
     186}
     187
    103188/** @}
    104189 */
Note: See TracChangeset for help on using the changeset viewer.