Changes in uspace/srv/hid/display/main.c [1762ceb:4c6fd56] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/hid/display/main.c
r1762ceb r4c6fd56 1 1 /* 2 * Copyright (c) 20 19Jiri Svoboda2 * Copyright (c) 2023 Jiri Svoboda 3 3 * All rights reserved. 4 4 * … … 36 36 #include <async.h> 37 37 #include <disp_srv.h> 38 #include <dispcfg_srv.h> 38 39 #include <errno.h> 39 40 #include <gfx/context.h> … … 47 48 #include <stdio.h> 48 49 #include <task.h> 50 #include <wndmgt_srv.h> 51 #include "cfgclient.h" 52 #include "cfgops.h" 49 53 #include "client.h" 50 54 #include "display.h" … … 55 59 #include "seat.h" 56 60 #include "window.h" 61 #include "wmclient.h" 62 #include "wmops.h" 57 63 58 64 static void display_client_conn(ipc_call_t *, void *); 59 65 static 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 *); 60 71 61 72 #ifdef CONFIG_DISP_DOUBLE_BUF … … 76 87 }; 77 88 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 78 97 static void display_client_ev_pending(void *arg) 79 98 { … … 81 100 82 101 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); 83 116 } 84 117 … … 90 123 ds_output_t *output = NULL; 91 124 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; 92 131 errno_t rc; 93 132 … … 98 137 goto error; 99 138 100 rc = ds_seat_create(disp, &seat);139 rc = ds_seat_create(disp, "Alice", &seat); 101 140 if (rc != EOK) 102 141 goto error; … … 115 154 goto error; 116 155 117 async_set_fallback_port_handler(display_client_conn, disp); 118 119 rc = loc_server_register(NAME); 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); 120 176 if (rc != EOK) { 121 177 log_msg(LOG_DEFAULT, LVL_ERROR, "Failed registering server: %s.", str_error(rc)); … … 124 180 } 125 181 126 service_id_t sid; 127 rc = loc_service_register(SERVICE_NAME_DISPLAY, &sid); 182 rc = loc_service_register(srv, SERVICE_NAME_DISPLAY, &sid); 128 183 if (rc != EOK) { 129 184 log_msg(LOG_DEFAULT, LVL_ERROR, "Failed registering service: %s.", str_error(rc)); … … 135 190 return EOK; 136 191 error: 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 137 200 #if 0 138 201 if (disp->input != NULL) … … 154 217 { 155 218 display_srv_t srv; 156 sysarg_t wnd_id;157 219 sysarg_t svc_id; 158 220 ds_client_t *client = NULL; 159 ds_window_t *wnd;160 221 ds_display_t *disp = (ds_display_t *) arg; 161 gfx_context_t *gc;162 222 errno_t rc; 163 223 … … 166 226 ipc_get_arg4(icall)); 167 227 168 (void) icall;169 (void) arg;170 171 228 svc_id = ipc_get_arg2(icall); 172 wnd_id = ipc_get_arg3(icall);173 229 174 230 if (svc_id != 0) { 175 231 /* Create client object */ 232 ds_display_lock(disp); 176 233 rc = ds_client_create(disp, &display_client_cb, &srv, &client); 234 ds_display_unlock(disp); 177 235 if (rc != EOK) { 178 236 async_answer_0(icall, ENOMEM); … … 191 249 ds_client_destroy(client); 192 250 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 } 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); 209 342 } 210 343
Note:
See TracChangeset
for help on using the changeset viewer.