Ignore:
File:
1 edited

Legend:

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

    r913add60 r1762ceb  
    11/*
    2  * Copyright (c) 2022 Jiri Svoboda
     2 * Copyright (c) 2019 Jiri Svoboda
    33 * All rights reserved.
    44 *
     
    4747#include <stdio.h>
    4848#include <task.h>
    49 #include <wndmgt_srv.h>
    5049#include "client.h"
    5150#include "display.h"
     
    5655#include "seat.h"
    5756#include "window.h"
    58 #include "wmclient.h"
    59 #include "wmops.h"
    6057
    6158static void display_client_conn(ipc_call_t *, void *);
    6259static void display_client_ev_pending(void *);
    63 static void display_wmclient_ev_pending(void *);
    64 static void display_gc_conn(ipc_call_t *, void *);
    65 static void display_wndmgt_conn(ipc_call_t *, void *);
    6660
    6761#ifdef CONFIG_DISP_DOUBLE_BUF
     
    8276};
    8377
    84 static ds_wmclient_cb_t display_wmclient_cb = {
    85         .ev_pending = display_wmclient_ev_pending
    86 };
    87 
    8878static void display_client_ev_pending(void *arg)
    8979{
     
    9181
    9282        display_srv_ev_pending(srv);
    93 }
    94 
    95 static void display_wmclient_ev_pending(void *arg)
    96 {
    97         wndmgt_srv_t *srv = (wndmgt_srv_t *) arg;
    98 
    99         wndmgt_srv_ev_pending(srv);
    10083}
    10184
     
    10790        ds_output_t *output = NULL;
    10891        gfx_context_t *gc = NULL;
    109         port_id_t disp_port;
    110         port_id_t gc_port;
    111         port_id_t wm_port;
    11292        errno_t rc;
    11393
     
    135115                goto error;
    136116
    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;
     117        async_set_fallback_port_handler(display_client_conn, disp);
    150118
    151119        rc = loc_server_register(NAME);
     
    167135        return EOK;
    168136error:
    169         // XXX destroy disp_port
    170         // XXX destroy gc_port
    171         // XXX destroy wm_port
    172137#if 0
    173138        if (disp->input != NULL)
     
    189154{
    190155        display_srv_t srv;
     156        sysarg_t wnd_id;
    191157        sysarg_t svc_id;
    192158        ds_client_t *client = NULL;
     159        ds_window_t *wnd;
    193160        ds_display_t *disp = (ds_display_t *) arg;
     161        gfx_context_t *gc;
    194162        errno_t rc;
    195163
     
    198166            ipc_get_arg4(icall));
    199167
     168        (void) icall;
     169        (void) arg;
     170
    200171        svc_id = ipc_get_arg2(icall);
     172        wnd_id = ipc_get_arg3(icall);
    201173
    202174        if (svc_id != 0) {
    203175                /* Create client object */
    204                 ds_display_lock(disp);
    205176                rc = ds_client_create(disp, &display_client_cb, &srv, &client);
    206                 ds_display_unlock(disp);
    207177                if (rc != EOK) {
    208178                        async_answer_0(icall, ENOMEM);
     
    221191                ds_client_destroy(client);
    222192                ds_display_unlock(disp);
    223         }
    224 }
    225 
    226 /** Handle GC connection to display server */
    227 static 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 */
    257 static 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);
     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        }
    284209}
    285210
Note: See TracChangeset for help on using the changeset viewer.