Ignore:
File:
1 edited

Legend:

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

    r1762ceb r913add60  
    11/*
    2  * Copyright (c) 2019 Jiri Svoboda
     2 * Copyright (c) 2022 Jiri Svoboda
    33 * All rights reserved.
    44 *
     
    4747#include <stdio.h>
    4848#include <task.h>
     49#include <wndmgt_srv.h>
    4950#include "client.h"
    5051#include "display.h"
     
    5556#include "seat.h"
    5657#include "window.h"
     58#include "wmclient.h"
     59#include "wmops.h"
    5760
    5861static void display_client_conn(ipc_call_t *, void *);
    5962static void display_client_ev_pending(void *);
     63static void display_wmclient_ev_pending(void *);
     64static void display_gc_conn(ipc_call_t *, void *);
     65static void display_wndmgt_conn(ipc_call_t *, void *);
    6066
    6167#ifdef CONFIG_DISP_DOUBLE_BUF
     
    7682};
    7783
     84static ds_wmclient_cb_t display_wmclient_cb = {
     85        .ev_pending = display_wmclient_ev_pending
     86};
     87
    7888static void display_client_ev_pending(void *arg)
    7989{
     
    8191
    8292        display_srv_ev_pending(srv);
     93}
     94
     95static void display_wmclient_ev_pending(void *arg)
     96{
     97        wndmgt_srv_t *srv = (wndmgt_srv_t *) arg;
     98
     99        wndmgt_srv_ev_pending(srv);
    83100}
    84101
     
    90107        ds_output_t *output = NULL;
    91108        gfx_context_t *gc = NULL;
     109        port_id_t disp_port;
     110        port_id_t gc_port;
     111        port_id_t wm_port;
    92112        errno_t rc;
    93113
     
    115135                goto error;
    116136
    117         async_set_fallback_port_handler(display_client_conn, disp);
     137        rc = async_create_port(INTERFACE_DISPLAY, display_client_conn, disp,
     138            &disp_port);
     139        if (rc != EOK)
     140                goto error;
     141
     142        rc = async_create_port(INTERFACE_GC, display_gc_conn, disp, &gc_port);
     143        if (rc != EOK)
     144                goto error;
     145
     146        rc = async_create_port(INTERFACE_WNDMGT, display_wndmgt_conn, disp,
     147            &wm_port);
     148        if (rc != EOK)
     149                goto error;
    118150
    119151        rc = loc_server_register(NAME);
     
    135167        return EOK;
    136168error:
     169        // XXX destroy disp_port
     170        // XXX destroy gc_port
     171        // XXX destroy wm_port
    137172#if 0
    138173        if (disp->input != NULL)
     
    154189{
    155190        display_srv_t srv;
    156         sysarg_t wnd_id;
    157191        sysarg_t svc_id;
    158192        ds_client_t *client = NULL;
    159         ds_window_t *wnd;
    160193        ds_display_t *disp = (ds_display_t *) arg;
    161         gfx_context_t *gc;
    162194        errno_t rc;
    163195
     
    166198            ipc_get_arg4(icall));
    167199
    168         (void) icall;
    169         (void) arg;
    170 
    171200        svc_id = ipc_get_arg2(icall);
    172         wnd_id = ipc_get_arg3(icall);
    173201
    174202        if (svc_id != 0) {
    175203                /* Create client object */
     204                ds_display_lock(disp);
    176205                rc = ds_client_create(disp, &display_client_cb, &srv, &client);
     206                ds_display_unlock(disp);
    177207                if (rc != EOK) {
    178208                        async_answer_0(icall, ENOMEM);
     
    191221                ds_client_destroy(client);
    192222                ds_display_unlock(disp);
    193         } else {
    194                 /* Window GC connection */
    195 
    196                 wnd = ds_display_find_window(disp, wnd_id);
    197                 if (wnd == NULL) {
    198                         async_answer_0(icall, ENOENT);
    199                         return;
    200                 }
    201 
    202                 /*
    203                  * XXX We need a way to make sure that the connection does
    204                  * not stay active after the window had been destroyed
    205                  */
    206                 gc = ds_window_get_ctx(wnd);
    207                 gc_conn(icall, gc);
    208         }
     223        }
     224}
     225
     226/** Handle GC connection to display server */
     227static void display_gc_conn(ipc_call_t *icall, void *arg)
     228{
     229        sysarg_t wnd_id;
     230        ds_window_t *wnd;
     231        ds_display_t *disp = (ds_display_t *) arg;
     232        gfx_context_t *gc;
     233
     234        log_msg(LOG_DEFAULT, LVL_DEBUG, "display_gc_conn arg1=%zu arg2=%zu arg3=%zu arg4=%zu.",
     235            ipc_get_arg1(icall), ipc_get_arg2(icall), ipc_get_arg3(icall),
     236            ipc_get_arg4(icall));
     237
     238        wnd_id = ipc_get_arg3(icall);
     239
     240        /* Window GC connection */
     241
     242        wnd = ds_display_find_window(disp, wnd_id);
     243        if (wnd == NULL) {
     244                async_answer_0(icall, ENOENT);
     245                return;
     246        }
     247
     248        /*
     249         * XXX We need a way to make sure that the connection does
     250         * not stay active after the window had been destroyed
     251         */
     252        gc = ds_window_get_ctx(wnd);
     253        gc_conn(icall, gc);
     254}
     255
     256/** Handle window management connection to display server */
     257static void display_wndmgt_conn(ipc_call_t *icall, void *arg)
     258{
     259        ds_display_t *disp = (ds_display_t *) arg;
     260        errno_t rc;
     261        wndmgt_srv_t srv;
     262        ds_wmclient_t *wmclient = NULL;
     263
     264        /* Create WM client object */
     265        ds_display_lock(disp);
     266        rc = ds_wmclient_create(disp, &display_wmclient_cb, &srv, &wmclient);
     267        ds_display_unlock(disp);
     268        if (rc != EOK) {
     269                async_answer_0(icall, ENOMEM);
     270                return;
     271        }
     272
     273        /* Set up protocol structure */
     274        wndmgt_srv_initialize(&srv);
     275        srv.ops = &wndmgt_srv_ops;
     276        srv.arg = wmclient;
     277
     278        /* Handle connection */
     279        wndmgt_conn(icall, &srv);
     280
     281        ds_display_lock(disp);
     282        ds_wmclient_destroy(wmclient);
     283        ds_display_unlock(disp);
    209284}
    210285
Note: See TracChangeset for help on using the changeset viewer.