Ignore:
File:
1 edited

Legend:

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

    rca48672 r8630748  
    11/*
    2  * Copyright (c) 2025 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"
    5551#include "dsops.h"
    56 #include "ievent.h"
    5752#include "input.h"
    5853#include "main.h"
     
    6055#include "seat.h"
    6156#include "window.h"
    62 #include "wmclient.h"
    63 #include "wmops.h"
    64 
    65 const char *cfg_file_path = "/w/cfg/display.sif";
    6657
    6758static void display_client_conn(ipc_call_t *, void *);
    6859static void display_client_ev_pending(void *);
    69 static void display_wmclient_ev_pending(void *);
    70 static void display_cfgclient_ev_pending(void *);
    71 static void display_gc_conn(ipc_call_t *, void *);
    72 static void display_wndmgt_conn(ipc_call_t *, void *);
    73 static void display_dispcfg_conn(ipc_call_t *, void *);
    7460
    7561#ifdef CONFIG_DISP_DOUBLE_BUF
     
    9076};
    9177
    92 static ds_wmclient_cb_t display_wmclient_cb = {
    93         .ev_pending = display_wmclient_ev_pending
    94 };
    95 
    96 static ds_cfgclient_cb_t display_cfgclient_cb = {
    97         .ev_pending = display_cfgclient_ev_pending
    98 };
    99 
    10078static void display_client_ev_pending(void *arg)
    10179{
     
    10381
    10482        display_srv_ev_pending(srv);
    105 }
    106 
    107 static void display_wmclient_ev_pending(void *arg)
    108 {
    109         wndmgt_srv_t *srv = (wndmgt_srv_t *) arg;
    110 
    111         wndmgt_srv_ev_pending(srv);
    112 }
    113 
    114 static void display_cfgclient_ev_pending(void *arg)
    115 {
    116         dispcfg_srv_t *srv = (dispcfg_srv_t *) arg;
    117 
    118         dispcfg_srv_ev_pending(srv);
    11983}
    12084
     
    12690        ds_output_t *output = NULL;
    12791        gfx_context_t *gc = NULL;
    128         port_id_t port = 0;
    129         loc_srv_t *srv = NULL;
    130         service_id_t sid = 0;
    13192        errno_t rc;
    13293
     
    13798                goto error;
    13899
    139         rc = ds_display_load_cfg(disp, cfg_file_path);
    140         if (rc != EOK) {
    141                 log_msg(LOG_DEFAULT, LVL_NOTE,
    142                     "Starting with fresh configuration.");
    143 
    144                 /* Create first seat */
    145                 rc = ds_seat_create(disp, "Alice", &seat);
    146                 if (rc != EOK)
    147                         goto error;
    148         }
     100        rc = ds_seat_create(disp, &seat);
     101        if (rc != EOK)
     102                goto error;
    149103
    150104        rc = ds_output_create(&output);
     
    157111                goto error;
    158112
    159         rc = ds_ievent_init(disp);
    160         if (rc != EOK)
    161                 goto error;
    162 
    163113        rc = ds_input_open(disp);
    164114        if (rc != EOK)
    165115                goto error;
    166116
    167         rc = async_create_port(INTERFACE_DISPLAY, display_client_conn, disp,
    168             &port);
    169         if (rc != EOK)
    170                 goto error;
    171 
    172         rc = async_port_create_interface(port, INTERFACE_GC, display_gc_conn,
    173             disp);
    174         if (rc != EOK)
    175                 goto error;
    176 
    177         rc = async_port_create_interface(port, INTERFACE_WNDMGT,
    178             display_wndmgt_conn, disp);
    179         if (rc != EOK)
    180                 goto error;
    181 
    182         rc = async_port_create_interface(port, INTERFACE_DISPCFG,
    183             display_dispcfg_conn, disp);
    184         if (rc != EOK)
    185                 goto error;
    186 
    187         rc = loc_server_register(NAME, &srv);
     117        async_set_fallback_port_handler(display_client_conn, disp);
     118
     119        rc = loc_server_register(NAME);
    188120        if (rc != EOK) {
    189121                log_msg(LOG_DEFAULT, LVL_ERROR, "Failed registering server: %s.", str_error(rc));
     
    192124        }
    193125
    194         rc = loc_service_register(srv, SERVICE_NAME_DISPLAY, port, &sid);
     126        service_id_t sid;
     127        rc = loc_service_register(SERVICE_NAME_DISPLAY, &sid);
    195128        if (rc != EOK) {
    196129                log_msg(LOG_DEFAULT, LVL_ERROR, "Failed registering service: %s.", str_error(rc));
     
    202135        return EOK;
    203136error:
    204         if (sid != 0)
    205                 loc_service_unregister(srv, sid);
    206         if (srv != NULL)
    207                 loc_server_unregister(srv);
    208         if (port != 0)
    209                 async_port_destroy(port);
    210137#if 0
    211138        if (disp->input != NULL)
    212139                ds_input_close(disp);
    213140#endif
    214         ds_ievent_fini(disp);
    215141        if (output != NULL)
    216142                ds_output_destroy(output);
     
    228154{
    229155        display_srv_t srv;
     156        sysarg_t wnd_id;
    230157        sysarg_t svc_id;
    231158        ds_client_t *client = NULL;
     159        ds_window_t *wnd;
    232160        ds_display_t *disp = (ds_display_t *) arg;
     161        gfx_context_t *gc;
    233162        errno_t rc;
    234163
     
    237166            ipc_get_arg4(icall));
    238167
     168        (void) icall;
     169        (void) arg;
     170
    239171        svc_id = ipc_get_arg2(icall);
     172        wnd_id = ipc_get_arg3(icall);
    240173
    241174        if (svc_id != 0) {
    242175                /* Create client object */
    243                 ds_display_lock(disp);
    244176                rc = ds_client_create(disp, &display_client_cb, &srv, &client);
    245                 ds_display_unlock(disp);
    246177                if (rc != EOK) {
    247178                        async_answer_0(icall, ENOMEM);
     
    257188                display_conn(icall, &srv);
    258189
    259                 ds_display_lock(disp);
    260190                ds_client_destroy(client);
    261                 ds_display_unlock(disp);
    262         }
    263 }
    264 
    265 /** Handle GC connection to display server */
    266 static void display_gc_conn(ipc_call_t *icall, void *arg)
    267 {
    268         sysarg_t wnd_id;
    269         ds_window_t *wnd;
    270         ds_display_t *disp = (ds_display_t *) arg;
    271         gfx_context_t *gc;
    272 
    273         log_msg(LOG_DEFAULT, LVL_DEBUG, "display_gc_conn arg1=%zu arg2=%zu arg3=%zu arg4=%zu.",
    274             ipc_get_arg1(icall), ipc_get_arg2(icall), ipc_get_arg3(icall),
    275             ipc_get_arg4(icall));
    276 
    277         wnd_id = ipc_get_arg3(icall);
    278 
    279         /* Window GC connection */
    280 
    281         wnd = ds_display_find_window(disp, wnd_id);
    282         if (wnd == NULL) {
    283                 async_answer_0(icall, ENOENT);
    284                 return;
    285         }
    286 
    287         /*
    288          * XXX We need a way to make sure that the connection does
    289          * not stay active after the window had been destroyed
    290          */
    291         gc = ds_window_get_ctx(wnd);
    292         gc_conn(icall, gc);
    293 }
    294 
    295 /** Handle window management connection to display server */
    296 static void display_wndmgt_conn(ipc_call_t *icall, void *arg)
    297 {
    298         ds_display_t *disp = (ds_display_t *) arg;
    299         errno_t rc;
    300         wndmgt_srv_t srv;
    301         ds_wmclient_t *wmclient = NULL;
    302 
    303         /* Create WM client object */
    304         ds_display_lock(disp);
    305         rc = ds_wmclient_create(disp, &display_wmclient_cb, &srv, &wmclient);
    306         ds_display_unlock(disp);
    307         if (rc != EOK) {
    308                 async_answer_0(icall, ENOMEM);
    309                 return;
    310         }
    311 
    312         /* Set up protocol structure */
    313         wndmgt_srv_initialize(&srv);
    314         srv.ops = &wndmgt_srv_ops;
    315         srv.arg = wmclient;
    316 
    317         /* Handle connection */
    318         wndmgt_conn(icall, &srv);
    319 
    320         ds_display_lock(disp);
    321         ds_wmclient_destroy(wmclient);
    322         ds_display_unlock(disp);
    323 }
    324 
    325 /** Handle configuration connection to display server */
    326 static void display_dispcfg_conn(ipc_call_t *icall, void *arg)
    327 {
    328         ds_display_t *disp = (ds_display_t *) arg;
    329         errno_t rc;
    330         dispcfg_srv_t srv;
    331         ds_cfgclient_t *cfgclient = NULL;
    332 
    333         /* Create CFG client object */
    334         ds_display_lock(disp);
    335         rc = ds_cfgclient_create(disp, &display_cfgclient_cb, &srv, &cfgclient);
    336         ds_display_unlock(disp);
    337         if (rc != EOK) {
    338                 async_answer_0(icall, ENOMEM);
    339                 return;
    340         }
    341 
    342         /* Set up protocol structure */
    343         dispcfg_srv_initialize(&srv);
    344         srv.ops = &dispcfg_srv_ops;
    345         srv.arg = cfgclient;
    346 
    347         /* Handle connection */
    348         dispcfg_conn(icall, &srv);
    349 
    350         ds_display_lock(disp);
    351         ds_cfgclient_destroy(cfgclient);
    352         ds_display_unlock(disp);
     191        } else {
     192                /* Window GC connection */
     193
     194                wnd = ds_display_find_window(disp, wnd_id);
     195                if (wnd == NULL) {
     196                        async_answer_0(icall, ENOENT);
     197                        return;
     198                }
     199
     200                /*
     201                 * XXX We need a way to make sure that the connection does
     202                 * not stay active after the window had been destroyed
     203                 */
     204                gc = ds_window_get_ctx(wnd);
     205                gc_conn(icall, gc);
     206        }
    353207}
    354208
Note: See TracChangeset for help on using the changeset viewer.