Changeset 1766326 in mainline
- Timestamp:
- 2022-10-18T09:06:07Z (2 years ago)
- Branches:
- master, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 7a05d924
- Parents:
- 0761448
- git-author:
- Jiri Svoboda <jiri@…> (2022-10-17 17:05:56)
- git-committer:
- Jiri Svoboda <jiri@…> (2022-10-18 09:06:07)
- Location:
- uspace
- Files:
-
- 2 added
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/taskbar/main.c
r0761448 r1766326 46 46 { 47 47 const char *display_spec = UI_ANY_DEFAULT; 48 const char *wndmgt_svc = WNDMGT_DEFAULT; 48 49 taskbar_t *taskbar; 49 50 errno_t rc; … … 61 62 62 63 display_spec = argv[i++]; 64 } else if (str_cmp(argv[i], "-w") == 0) { 65 ++i; 66 if (i >= argc) { 67 printf("Argument missing.\n"); 68 print_syntax(); 69 return 1; 70 } 71 72 wndmgt_svc = argv[i++]; 63 73 } else { 64 74 printf("Invalid option '%s'.\n", argv[i]); … … 73 83 } 74 84 75 rc = taskbar_create(display_spec, &taskbar);85 rc = taskbar_create(display_spec, wndmgt_svc, &taskbar); 76 86 if (rc != EOK) 77 87 return 1; -
uspace/app/taskbar/meson.build
r0761448 r1766326 27 27 # 28 28 29 deps = [ 'ui' ]29 deps = [ 'ui', 'wndmgt' ] 30 30 src = files( 31 31 'clock.c', -
uspace/app/taskbar/taskbar.c
r0761448 r1766326 42 42 #include <ui/ui.h> 43 43 #include <ui/window.h> 44 #include <wndmgt.h> 44 45 #include "clock.h" 45 46 #include "taskbar.h" … … 67 68 * 68 69 * @param display_spec Display specification 70 * @param wndmgt_svc Window management service (or WNDMGT_DEFAULT) 69 71 * @param rtaskbar Place to store pointer to new task bar 70 72 * @return @c EOK on success or an error coe 71 73 */ 72 errno_t taskbar_create(const char *display_spec, taskbar_t **rtaskbar) 74 errno_t taskbar_create(const char *display_spec, const char *wndmgt_svc, 75 taskbar_t **rtaskbar) 73 76 { 74 77 ui_wnd_params_t params; … … 83 86 rc = ENOMEM; 84 87 goto error; 88 } 89 90 if (wndmgt_svc != NULL) { 91 rc = wndmgt_open(wndmgt_svc, NULL, NULL, &taskbar->wndmgt); 92 if (rc != EOK) 93 goto error; 85 94 } 86 95 … … 215 224 if (taskbar->ui != NULL) 216 225 ui_destroy(taskbar->ui); 226 if (taskbar->wndmgt != NULL) 227 wndmgt_close(taskbar->wndmgt); 217 228 return rc; 218 229 … … 226 237 ui_window_destroy(taskbar->window); 227 238 ui_destroy(taskbar->ui); 239 if (taskbar->wndmgt != NULL) 240 wndmgt_close(taskbar->wndmgt); 228 241 } 229 242 -
uspace/app/taskbar/taskbar.h
r0761448 r1766326 38 38 39 39 #include <errno.h> 40 #include <wndmgt.h> 40 41 #include "types/taskbar.h" 41 42 42 extern errno_t taskbar_create(const char * display_spec, taskbar_t **);43 extern errno_t taskbar_create(const char *, const char *, taskbar_t **); 43 44 extern void taskbar_destroy(taskbar_t *); 44 45 -
uspace/app/taskbar/test/taskbar.c
r0761448 r1766326 41 41 taskbar_t *taskbar; 42 42 43 rc = taskbar_create(UI_DISPLAY_NULL, &taskbar);43 rc = taskbar_create(UI_DISPLAY_NULL, NULL, &taskbar); 44 44 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 45 45 -
uspace/app/taskbar/types/taskbar.h
r0761448 r1766326 57 57 /** Clock */ 58 58 taskbar_clock_t *clock; 59 /** Window management service */ 60 wndmgt_t *wndmgt; 59 61 } taskbar_t; 60 62 -
uspace/lib/wndmgt/src/wndmgt.c
r0761448 r1766326 169 169 if (rc != EOK) { 170 170 async_exchange_end(exch); 171 async_ forget(req);171 async_wait_for(req, &rc); 172 172 return rc; 173 173 } … … 238 238 if (rc != EOK) { 239 239 async_exchange_end(exch); 240 async_ forget(req);240 async_wait_for(req, &rc); 241 241 return rc; 242 242 } -
uspace/lib/wndmgt/test/wndmgt.c
r0761448 r1766326 34 34 #include <loc.h> 35 35 #include <pcut/pcut.h> 36 #include <str.h> 36 37 #include "../private/wndmgt.h" 37 38 … … 81 82 82 83 bool get_window_info_called; 84 sysarg_t get_window_info_wnd_id; 83 85 wndmgt_window_info_t *get_window_info_rinfo; 84 86 … … 127 129 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 128 130 } 131 132 /** wndmgt_get_window_list() with server returning error response works */ 133 PCUT_TEST(get_window_list_failure) 134 { 135 errno_t rc; 136 service_id_t sid; 137 wndmgt_t *wndmgt = NULL; 138 wndmgt_window_list_t *list; 139 test_response_t resp; 140 141 async_set_fallback_port_handler(test_wndmgt_conn, &resp); 142 143 // FIXME This causes this test to be non-reentrant! 144 rc = loc_server_register(test_wndmgt_server); 145 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 146 147 rc = loc_service_register(test_wndmgt_svc, &sid); 148 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 149 150 rc = wndmgt_open(test_wndmgt_svc, NULL, NULL, &wndmgt); 151 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 152 PCUT_ASSERT_NOT_NULL(wndmgt); 153 154 resp.rc = ENOMEM; 155 resp.get_window_list_called = false; 156 157 rc = wndmgt_get_window_list(wndmgt, &list); 158 PCUT_ASSERT_TRUE(resp.get_window_list_called); 159 PCUT_ASSERT_ERRNO_VAL(resp.rc, rc); 160 161 wndmgt_close(wndmgt); 162 rc = loc_service_unregister(sid); 163 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 164 } 165 166 /** wndmgt_get_window_list() with server returning success response works */ 167 PCUT_TEST(get_window_list_success) 168 { 169 errno_t rc; 170 service_id_t sid; 171 wndmgt_t *wndmgt = NULL; 172 wndmgt_window_list_t *list; 173 test_response_t resp; 174 175 async_set_fallback_port_handler(test_wndmgt_conn, &resp); 176 177 // FIXME This causes this test to be non-reentrant! 178 rc = loc_server_register(test_wndmgt_server); 179 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 180 181 rc = loc_service_register(test_wndmgt_svc, &sid); 182 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 183 184 rc = wndmgt_open(test_wndmgt_svc, NULL, NULL, &wndmgt); 185 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 186 PCUT_ASSERT_NOT_NULL(wndmgt); 187 188 resp.rc = EOK; 189 resp.get_window_list_called = false; 190 resp.get_window_list_rlist = calloc(1, sizeof(wndmgt_window_list_t)); 191 PCUT_ASSERT_NOT_NULL(resp.get_window_list_rlist); 192 resp.get_window_list_rlist->nwindows = 2; 193 resp.get_window_list_rlist->windows = calloc(2, sizeof(sysarg_t)); 194 PCUT_ASSERT_NOT_NULL(resp.get_window_list_rlist->windows); 195 resp.get_window_list_rlist->windows[0] = 42; 196 resp.get_window_list_rlist->windows[1] = 43; 197 198 rc = wndmgt_get_window_list(wndmgt, &list); 199 PCUT_ASSERT_TRUE(resp.get_window_list_called); 200 PCUT_ASSERT_ERRNO_VAL(resp.rc, rc); 201 202 PCUT_ASSERT_INT_EQUALS(2, list->nwindows); 203 PCUT_ASSERT_INT_EQUALS(42, list->windows[0]); 204 PCUT_ASSERT_INT_EQUALS(43, list->windows[1]); 205 206 wndmgt_free_window_list(list); 207 wndmgt_close(wndmgt); 208 rc = loc_service_unregister(sid); 209 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 210 } 211 212 /** wndmgt_get_window_infp() with server returning error response works */ 213 PCUT_TEST(get_window_info_failure) 214 { 215 errno_t rc; 216 service_id_t sid; 217 wndmgt_t *wndmgt = NULL; 218 sysarg_t wnd_id; 219 wndmgt_window_info_t *info; 220 test_response_t resp; 221 222 async_set_fallback_port_handler(test_wndmgt_conn, &resp); 223 224 // FIXME This causes this test to be non-reentrant! 225 rc = loc_server_register(test_wndmgt_server); 226 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 227 228 rc = loc_service_register(test_wndmgt_svc, &sid); 229 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 230 231 rc = wndmgt_open(test_wndmgt_svc, NULL, NULL, &wndmgt); 232 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 233 PCUT_ASSERT_NOT_NULL(wndmgt); 234 235 resp.rc = ENOMEM; 236 resp.get_window_info_called = false; 237 wnd_id = 1; 238 239 rc = wndmgt_get_window_info(wndmgt, wnd_id, &info); 240 PCUT_ASSERT_TRUE(resp.get_window_info_called); 241 PCUT_ASSERT_INT_EQUALS(wnd_id, resp.get_window_info_wnd_id); 242 PCUT_ASSERT_ERRNO_VAL(resp.rc, rc); 243 244 wndmgt_close(wndmgt); 245 rc = loc_service_unregister(sid); 246 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 247 } 248 249 /** wndmgt_get_window_info() with server returning success response works */ 250 PCUT_TEST(get_window_info_success) 251 { 252 errno_t rc; 253 service_id_t sid; 254 wndmgt_t *wndmgt = NULL; 255 sysarg_t wnd_id; 256 wndmgt_window_info_t *info; 257 test_response_t resp; 258 259 async_set_fallback_port_handler(test_wndmgt_conn, &resp); 260 261 // FIXME This causes this test to be non-reentrant! 262 rc = loc_server_register(test_wndmgt_server); 263 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 264 265 rc = loc_service_register(test_wndmgt_svc, &sid); 266 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 267 268 rc = wndmgt_open(test_wndmgt_svc, NULL, NULL, &wndmgt); 269 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 270 PCUT_ASSERT_NOT_NULL(wndmgt); 271 272 resp.rc = EOK; 273 resp.get_window_info_called = false; 274 resp.get_window_info_rinfo = calloc(1, sizeof(wndmgt_window_info_t)); 275 PCUT_ASSERT_NOT_NULL(resp.get_window_info_rinfo); 276 resp.get_window_info_rinfo->caption = str_dup("Hello"); 277 PCUT_ASSERT_NOT_NULL(resp.get_window_info_rinfo->caption); 278 wnd_id = 1; 279 280 rc = wndmgt_get_window_info(wndmgt, wnd_id, &info); 281 PCUT_ASSERT_TRUE(resp.get_window_info_called); 282 PCUT_ASSERT_INT_EQUALS(wnd_id, resp.get_window_info_wnd_id); 283 PCUT_ASSERT_ERRNO_VAL(resp.rc, rc); 284 285 PCUT_ASSERT_STR_EQUALS("Hello", info->caption); 286 287 wndmgt_free_window_info(info); 288 wndmgt_close(wndmgt); 289 rc = loc_service_unregister(sid); 290 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 291 } 292 129 293 /** wndmgt_activate_window() with server returning error response works */ 130 294 PCUT_TEST(activate_window_failure) … … 199 363 } 200 364 365 /** wndmgt_close_window() with server returning error response works */ 366 PCUT_TEST(close_window_failure) 367 { 368 errno_t rc; 369 service_id_t sid; 370 wndmgt_t *wndmgt = NULL; 371 sysarg_t wnd_id; 372 test_response_t resp; 373 374 async_set_fallback_port_handler(test_wndmgt_conn, &resp); 375 376 // FIXME This causes this test to be non-reentrant! 377 rc = loc_server_register(test_wndmgt_server); 378 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 379 380 rc = loc_service_register(test_wndmgt_svc, &sid); 381 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 382 383 rc = wndmgt_open(test_wndmgt_svc, NULL, NULL, &wndmgt); 384 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 385 PCUT_ASSERT_NOT_NULL(wndmgt); 386 387 wnd_id = 42; 388 resp.rc = ENOMEM; 389 resp.close_window_called = false; 390 391 rc = wndmgt_close_window(wndmgt, wnd_id); 392 PCUT_ASSERT_TRUE(resp.close_window_called); 393 PCUT_ASSERT_INT_EQUALS(wnd_id, resp.close_window_wnd_id); 394 PCUT_ASSERT_ERRNO_VAL(resp.rc, rc); 395 396 wndmgt_close(wndmgt); 397 rc = loc_service_unregister(sid); 398 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 399 } 400 401 /** wndmgt_close_window() with server returning success response works */ 402 PCUT_TEST(close_window_success) 403 { 404 errno_t rc; 405 service_id_t sid; 406 wndmgt_t *wndmgt = NULL; 407 sysarg_t wnd_id; 408 test_response_t resp; 409 410 async_set_fallback_port_handler(test_wndmgt_conn, &resp); 411 412 // FIXME This causes this test to be non-reentrant! 413 rc = loc_server_register(test_wndmgt_server); 414 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 415 416 rc = loc_service_register(test_wndmgt_svc, &sid); 417 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 418 419 rc = wndmgt_open(test_wndmgt_svc, NULL, NULL, &wndmgt); 420 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 421 PCUT_ASSERT_NOT_NULL(wndmgt); 422 423 wnd_id = 42; 424 resp.rc = EOK; 425 resp.close_window_called = false; 426 427 rc = wndmgt_close_window(wndmgt, wnd_id); 428 PCUT_ASSERT_TRUE(resp.close_window_called); 429 PCUT_ASSERT_INT_EQUALS(wnd_id, resp.close_window_wnd_id); 430 PCUT_ASSERT_ERRNO_VAL(resp.rc, rc); 431 432 wndmgt_close(wndmgt); 433 rc = loc_service_unregister(sid); 434 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 435 } 436 201 437 /** Window added event can be delivered from server to client callback function */ 202 PCUT_TEST(window_added_ event_deliver)438 PCUT_TEST(window_added_deliver) 203 439 { 204 440 errno_t rc; … … 247 483 248 484 /** Window removed event can be delivered from server to client callback function */ 249 PCUT_TEST(window_removed_ event_deliver)485 PCUT_TEST(window_removed_deliver) 250 486 { 251 487 errno_t rc; … … 341 577 test_response_t *resp = (test_response_t *) arg; 342 578 579 resp->get_window_list_called = true; 580 343 581 if (resp->rc != EOK) 344 582 return resp->rc; 345 583 346 resp->get_window_list_called = true;347 584 *rlist = resp->get_window_list_rlist; 348 585 return EOK; … … 354 591 test_response_t *resp = (test_response_t *) arg; 355 592 593 resp->get_window_info_called = true; 594 resp->get_window_info_wnd_id = wnd_id; 595 356 596 if (resp->rc != EOK) 357 597 return resp->rc; 358 598 359 resp->get_window_info_called = true;360 599 *rinfo = resp->get_window_info_rinfo; 361 600 return EOK; -
uspace/srv/hid/display/main.c
r0761448 r1766326 1 1 /* 2 * Copyright (c) 20 19Jiri Svoboda2 * Copyright (c) 2022 Jiri Svoboda 3 3 * All rights reserved. 4 4 * … … 47 47 #include <stdio.h> 48 48 #include <task.h> 49 #include <wndmgt_srv.h> 49 50 #include "client.h" 50 51 #include "display.h" … … 55 56 #include "seat.h" 56 57 #include "window.h" 58 #include "wmops.h" 57 59 58 60 static void display_client_conn(ipc_call_t *, void *); 59 61 static void display_client_ev_pending(void *); 62 static void display_gc_conn(ipc_call_t *, void *); 63 static void display_wndmgt_conn(ipc_call_t *, void *); 60 64 61 65 #ifdef CONFIG_DISP_DOUBLE_BUF … … 90 94 ds_output_t *output = NULL; 91 95 gfx_context_t *gc = NULL; 96 port_id_t disp_port; 97 port_id_t gc_port; 98 port_id_t wm_port; 92 99 errno_t rc; 93 100 … … 115 122 goto error; 116 123 117 async_set_fallback_port_handler(display_client_conn, disp); 124 rc = async_create_port(INTERFACE_DISPLAY, display_client_conn, disp, 125 &disp_port); 126 if (rc != EOK) 127 goto error; 128 129 rc = async_create_port(INTERFACE_GC, display_gc_conn, disp, &gc_port); 130 if (rc != EOK) 131 goto error; 132 133 rc = async_create_port(INTERFACE_WNDMGT, display_wndmgt_conn, disp, 134 &wm_port); 135 if (rc != EOK) 136 goto error; 118 137 119 138 rc = loc_server_register(NAME); … … 135 154 return EOK; 136 155 error: 156 // XXX destroy disp_port 157 // XXX destroy gc_port 158 // XXX destroy wm_port 137 159 #if 0 138 160 if (disp->input != NULL) … … 154 176 { 155 177 display_srv_t srv; 156 sysarg_t wnd_id;157 178 sysarg_t svc_id; 158 179 ds_client_t *client = NULL; 159 ds_window_t *wnd;160 180 ds_display_t *disp = (ds_display_t *) arg; 161 gfx_context_t *gc;162 181 errno_t rc; 163 182 … … 166 185 ipc_get_arg4(icall)); 167 186 168 (void) icall;169 (void) arg;170 171 187 svc_id = ipc_get_arg2(icall); 172 wnd_id = ipc_get_arg3(icall);173 188 174 189 if (svc_id != 0) { … … 191 206 ds_client_destroy(client); 192 207 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 } 208 } 209 } 210 211 /** Handle GC connection to display server */ 212 static void display_gc_conn(ipc_call_t *icall, void *arg) 213 { 214 sysarg_t wnd_id; 215 ds_window_t *wnd; 216 ds_display_t *disp = (ds_display_t *) arg; 217 gfx_context_t *gc; 218 219 log_msg(LOG_DEFAULT, LVL_DEBUG, "display_gc_conn arg1=%zu arg2=%zu arg3=%zu arg4=%zu.", 220 ipc_get_arg1(icall), ipc_get_arg2(icall), ipc_get_arg3(icall), 221 ipc_get_arg4(icall)); 222 223 wnd_id = ipc_get_arg3(icall); 224 225 /* Window GC connection */ 226 227 wnd = ds_display_find_window(disp, wnd_id); 228 if (wnd == NULL) { 229 async_answer_0(icall, ENOENT); 230 return; 231 } 232 233 /* 234 * XXX We need a way to make sure that the connection does 235 * not stay active after the window had been destroyed 236 */ 237 gc = ds_window_get_ctx(wnd); 238 gc_conn(icall, gc); 239 } 240 241 /** Handle window management connection to display server */ 242 static void display_wndmgt_conn(ipc_call_t *icall, void *arg) 243 { 244 wndmgt_srv_t srv; 245 246 /* Set up protocol structure */ 247 wndmgt_srv_initialize(&srv); 248 srv.ops = &wndmgt_srv_ops; 249 srv.arg = NULL; // XXX 250 251 /* Handle connection */ 252 wndmgt_conn(icall, &srv); 209 253 } 210 254 -
uspace/srv/hid/display/meson.build
r0761448 r1766326 1 1 # 2 # Copyright (c) 20 19Jiri Svoboda2 # Copyright (c) 2022 Jiri Svoboda 3 3 # All rights reserved. 4 4 # … … 27 27 # 28 28 29 deps = [ 'ipcgfx', 'memgfx', 'display', 'ddev' ]29 deps = [ 'ipcgfx', 'memgfx', 'display', 'ddev', 'wndmgt' ] 30 30 31 31 src = files( … … 42 42 'seat.c', 43 43 'window.c', 44 'wmops.c', 44 45 ) 45 46
Note:
See TracChangeset
for help on using the changeset viewer.