Ignore:
File:
1 edited

Legend:

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

    r4c6fd56 r1762ceb  
    11/*
    2  * Copyright (c) 2023 Jiri Svoboda
     2 * Copyright (c) 2019 Jiri Svoboda
    33 * All rights reserved.
    44 *
     
    3636#include <async.h>
    3737#include <disp_srv.h>
    38 #include <dispcfg_srv.h>
    3938#include <errno.h>
    4039#include <gfx/context.h>
     
    4847#include <stdio.h>
    4948#include <task.h>
    50 #include <wndmgt_srv.h>
    51 #include "cfgclient.h"
    52 #include "cfgops.h"
    5349#include "client.h"
    5450#include "display.h"
     
    5955#include "seat.h"
    6056#include "window.h"
    61 #include "wmclient.h"
    62 #include "wmops.h"
    6357
    6458static void display_client_conn(ipc_call_t *, void *);
    6559static void display_client_ev_pending(void *);
    66 static void display_wmclient_ev_pending(void *);
    67 static void display_cfgclient_ev_pending(void *);
    68 static void display_gc_conn(ipc_call_t *, void *);
    69 static void display_wndmgt_conn(ipc_call_t *, void *);
    70 static void display_dispcfg_conn(ipc_call_t *, void *);
    7160
    7261#ifdef CONFIG_DISP_DOUBLE_BUF
     
    8776};
    8877
    89 static ds_wmclient_cb_t display_wmclient_cb = {
    90         .ev_pending = display_wmclient_ev_pending
    91 };
    92 
    93 static ds_cfgclient_cb_t display_cfgclient_cb = {
    94         .ev_pending = display_cfgclient_ev_pending
    95 };
    96 
    9778static void display_client_ev_pending(void *arg)
    9879{
     
    10081
    10182        display_srv_ev_pending(srv);
    102 }
    103 
    104 static void display_wmclient_ev_pending(void *arg)
    105 {
    106         wndmgt_srv_t *srv = (wndmgt_srv_t *) arg;
    107 
    108         wndmgt_srv_ev_pending(srv);
    109 }
    110 
    111 static void display_cfgclient_ev_pending(void *arg)
    112 {
    113         dispcfg_srv_t *srv = (dispcfg_srv_t *) arg;
    114 
    115         dispcfg_srv_ev_pending(srv);
    11683}
    11784
     
    12390        ds_output_t *output = NULL;
    12491        gfx_context_t *gc = NULL;
    125         port_id_t disp_port;
    126         port_id_t gc_port;
    127         port_id_t wm_port;
    128         port_id_t dc_port;
    129         loc_srv_t *srv = NULL;
    130         service_id_t sid = 0;
    13192        errno_t rc;
    13293
     
    13798                goto error;
    13899
    139         rc = ds_seat_create(disp, "Alice", &seat);
     100        rc = ds_seat_create(disp, &seat);
    140101        if (rc != EOK)
    141102                goto error;
     
    154115                goto error;
    155116
    156         rc = async_create_port(INTERFACE_DISPLAY, display_client_conn, disp,
    157             &disp_port);
    158         if (rc != EOK)
    159                 goto error;
    160 
    161         rc = async_create_port(INTERFACE_GC, display_gc_conn, disp, &gc_port);
    162         if (rc != EOK)
    163                 goto error;
    164 
    165         rc = async_create_port(INTERFACE_WNDMGT, display_wndmgt_conn, disp,
    166             &wm_port);
    167         if (rc != EOK)
    168                 goto error;
    169 
    170         rc = async_create_port(INTERFACE_DISPCFG, display_dispcfg_conn, disp,
    171             &dc_port);
    172         if (rc != EOK)
    173                 goto error;
    174 
    175         rc = loc_server_register(NAME, &srv);
     117        async_set_fallback_port_handler(display_client_conn, disp);
     118
     119        rc = loc_server_register(NAME);
    176120        if (rc != EOK) {
    177121                log_msg(LOG_DEFAULT, LVL_ERROR, "Failed registering server: %s.", str_error(rc));
     
    180124        }
    181125
    182         rc = loc_service_register(srv, SERVICE_NAME_DISPLAY, &sid);
     126        service_id_t sid;
     127        rc = loc_service_register(SERVICE_NAME_DISPLAY, &sid);
    183128        if (rc != EOK) {
    184129                log_msg(LOG_DEFAULT, LVL_ERROR, "Failed registering service: %s.", str_error(rc));
     
    190135        return EOK;
    191136error:
    192         if (sid != 0)
    193                 loc_service_unregister(srv, sid);
    194         if (srv != NULL)
    195                 loc_server_unregister(srv);
    196         // XXX destroy disp_port
    197         // XXX destroy gc_port
    198         // XXX destroy wm_port
    199         // XXX destroy dc_port
    200137#if 0
    201138        if (disp->input != NULL)
     
    217154{
    218155        display_srv_t srv;
     156        sysarg_t wnd_id;
    219157        sysarg_t svc_id;
    220158        ds_client_t *client = NULL;
     159        ds_window_t *wnd;
    221160        ds_display_t *disp = (ds_display_t *) arg;
     161        gfx_context_t *gc;
    222162        errno_t rc;
    223163
     
    226166            ipc_get_arg4(icall));
    227167
     168        (void) icall;
     169        (void) arg;
     170
    228171        svc_id = ipc_get_arg2(icall);
     172        wnd_id = ipc_get_arg3(icall);
    229173
    230174        if (svc_id != 0) {
    231175                /* Create client object */
    232                 ds_display_lock(disp);
    233176                rc = ds_client_create(disp, &display_client_cb, &srv, &client);
    234                 ds_display_unlock(disp);
    235177                if (rc != EOK) {
    236178                        async_answer_0(icall, ENOMEM);
     
    249191                ds_client_destroy(client);
    250192                ds_display_unlock(disp);
    251         }
    252 }
    253 
    254 /** Handle GC connection to display server */
    255 static void display_gc_conn(ipc_call_t *icall, void *arg)
    256 {
    257         sysarg_t wnd_id;
    258         ds_window_t *wnd;
    259         ds_display_t *disp = (ds_display_t *) arg;
    260         gfx_context_t *gc;
    261 
    262         log_msg(LOG_DEFAULT, LVL_DEBUG, "display_gc_conn arg1=%zu arg2=%zu arg3=%zu arg4=%zu.",
    263             ipc_get_arg1(icall), ipc_get_arg2(icall), ipc_get_arg3(icall),
    264             ipc_get_arg4(icall));
    265 
    266         wnd_id = ipc_get_arg3(icall);
    267 
    268         /* Window GC connection */
    269 
    270         wnd = ds_display_find_window(disp, wnd_id);
    271         if (wnd == NULL) {
    272                 async_answer_0(icall, ENOENT);
    273                 return;
    274         }
    275 
    276         /*
    277          * XXX We need a way to make sure that the connection does
    278          * not stay active after the window had been destroyed
    279          */
    280         gc = ds_window_get_ctx(wnd);
    281         gc_conn(icall, gc);
    282 }
    283 
    284 /** Handle window management connection to display server */
    285 static void display_wndmgt_conn(ipc_call_t *icall, void *arg)
    286 {
    287         ds_display_t *disp = (ds_display_t *) arg;
    288         errno_t rc;
    289         wndmgt_srv_t srv;
    290         ds_wmclient_t *wmclient = NULL;
    291 
    292         /* Create WM client object */
    293         ds_display_lock(disp);
    294         rc = ds_wmclient_create(disp, &display_wmclient_cb, &srv, &wmclient);
    295         ds_display_unlock(disp);
    296         if (rc != EOK) {
    297                 async_answer_0(icall, ENOMEM);
    298                 return;
    299         }
    300 
    301         /* Set up protocol structure */
    302         wndmgt_srv_initialize(&srv);
    303         srv.ops = &wndmgt_srv_ops;
    304         srv.arg = wmclient;
    305 
    306         /* Handle connection */
    307         wndmgt_conn(icall, &srv);
    308 
    309         ds_display_lock(disp);
    310         ds_wmclient_destroy(wmclient);
    311         ds_display_unlock(disp);
    312 }
    313 
    314 /** Handle configuration connection to display server */
    315 static void display_dispcfg_conn(ipc_call_t *icall, void *arg)
    316 {
    317         ds_display_t *disp = (ds_display_t *) arg;
    318         errno_t rc;
    319         dispcfg_srv_t srv;
    320         ds_cfgclient_t *cfgclient = NULL;
    321 
    322         /* Create CFG client object */
    323         ds_display_lock(disp);
    324         rc = ds_cfgclient_create(disp, &display_cfgclient_cb, &srv, &cfgclient);
    325         ds_display_unlock(disp);
    326         if (rc != EOK) {
    327                 async_answer_0(icall, ENOMEM);
    328                 return;
    329         }
    330 
    331         /* Set up protocol structure */
    332         dispcfg_srv_initialize(&srv);
    333         srv.ops = &dispcfg_srv_ops;
    334         srv.arg = cfgclient;
    335 
    336         /* Handle connection */
    337         dispcfg_conn(icall, &srv);
    338 
    339         ds_display_lock(disp);
    340         ds_cfgclient_destroy(cfgclient);
    341         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        }
    342209}
    343210
Note: See TracChangeset for help on using the changeset viewer.