Changes in uspace/srv/hid/display/main.c [ca48672:8630748] in mainline
- File:
-
- 1 edited
-
uspace/srv/hid/display/main.c (modified) (14 diffs)
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/hid/display/main.c
rca48672 r8630748 1 1 /* 2 * Copyright (c) 20 25Jiri Svoboda2 * Copyright (c) 2019 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>39 38 #include <errno.h> 40 39 #include <gfx/context.h> … … 48 47 #include <stdio.h> 49 48 #include <task.h> 50 #include <wndmgt_srv.h>51 #include "cfgclient.h"52 #include "cfgops.h"53 49 #include "client.h" 54 50 #include "display.h" 55 51 #include "dsops.h" 56 #include "ievent.h"57 52 #include "input.h" 58 53 #include "main.h" … … 60 55 #include "seat.h" 61 56 #include "window.h" 62 #include "wmclient.h"63 #include "wmops.h"64 65 const char *cfg_file_path = "/w/cfg/display.sif";66 57 67 58 static void display_client_conn(ipc_call_t *, void *); 68 59 static 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 *);74 60 75 61 #ifdef CONFIG_DISP_DOUBLE_BUF … … 90 76 }; 91 77 92 static ds_wmclient_cb_t display_wmclient_cb = {93 .ev_pending = display_wmclient_ev_pending94 };95 96 static ds_cfgclient_cb_t display_cfgclient_cb = {97 .ev_pending = display_cfgclient_ev_pending98 };99 100 78 static void display_client_ev_pending(void *arg) 101 79 { … … 103 81 104 82 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);119 83 } 120 84 … … 126 90 ds_output_t *output = NULL; 127 91 gfx_context_t *gc = NULL; 128 port_id_t port = 0;129 loc_srv_t *srv = NULL;130 service_id_t sid = 0;131 92 errno_t rc; 132 93 … … 137 98 goto error; 138 99 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; 149 103 150 104 rc = ds_output_create(&output); … … 157 111 goto error; 158 112 159 rc = ds_ievent_init(disp);160 if (rc != EOK)161 goto error;162 163 113 rc = ds_input_open(disp); 164 114 if (rc != EOK) 165 115 goto error; 166 116 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); 188 120 if (rc != EOK) { 189 121 log_msg(LOG_DEFAULT, LVL_ERROR, "Failed registering server: %s.", str_error(rc)); … … 192 124 } 193 125 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); 195 128 if (rc != EOK) { 196 129 log_msg(LOG_DEFAULT, LVL_ERROR, "Failed registering service: %s.", str_error(rc)); … … 202 135 return EOK; 203 136 error: 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);210 137 #if 0 211 138 if (disp->input != NULL) 212 139 ds_input_close(disp); 213 140 #endif 214 ds_ievent_fini(disp);215 141 if (output != NULL) 216 142 ds_output_destroy(output); … … 228 154 { 229 155 display_srv_t srv; 156 sysarg_t wnd_id; 230 157 sysarg_t svc_id; 231 158 ds_client_t *client = NULL; 159 ds_window_t *wnd; 232 160 ds_display_t *disp = (ds_display_t *) arg; 161 gfx_context_t *gc; 233 162 errno_t rc; 234 163 … … 237 166 ipc_get_arg4(icall)); 238 167 168 (void) icall; 169 (void) arg; 170 239 171 svc_id = ipc_get_arg2(icall); 172 wnd_id = ipc_get_arg3(icall); 240 173 241 174 if (svc_id != 0) { 242 175 /* Create client object */ 243 ds_display_lock(disp);244 176 rc = ds_client_create(disp, &display_client_cb, &srv, &client); 245 ds_display_unlock(disp);246 177 if (rc != EOK) { 247 178 async_answer_0(icall, ENOMEM); … … 257 188 display_conn(icall, &srv); 258 189 259 ds_display_lock(disp);260 190 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 } 353 207 } 354 208
Note:
See TracChangeset
for help on using the changeset viewer.
