Changeset c0757e1f in mainline
- Timestamp:
- 2023-04-19T11:13:06Z (21 months ago)
- Branches:
- master, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 37087c8
- Parents:
- ec8ef12
- Location:
- uspace
- Files:
-
- 16 added
- 25 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/disp/disp.c
rec8ef12 rc0757e1f 56 56 printf(" %s assign-dev <device> <seat>\n", NAME); 57 57 printf(" %s unassign-dev <device>\n", NAME); 58 printf(" %s list-dev <seat>\n", NAME); 58 59 } 59 60 … … 393 394 } 394 395 396 /** List dev subcommand. 397 * 398 * @param dcfg_svc Display configuration service name 399 * @param argc Number of arguments 400 * @param argv Arguments 401 * @return EOK on success or an erro code 402 */ 403 static errno_t list_dev(const char *dcfg_svc, int argc, char *argv[]) 404 { 405 dispcfg_t *dispcfg; 406 char *seat_name; 407 sysarg_t seat_id; 408 dispcfg_dev_list_t *dev_list; 409 size_t i; 410 char *svc_name; 411 table_t *table = NULL; 412 errno_t rc; 413 414 if (argc < 1) { 415 printf(NAME ": Missing arguments.\n"); 416 print_syntax(); 417 return EINVAL; 418 } 419 420 if (argc > 1) { 421 printf(NAME ": Too many arguments.\n"); 422 print_syntax(); 423 return EINVAL; 424 } 425 426 seat_name = argv[0]; 427 428 rc = dispcfg_open(dcfg_svc, NULL, NULL, &dispcfg); 429 if (rc != EOK) { 430 printf(NAME ": Failed connecting to display configuration " 431 "service: %s.\n", str_error(rc)); 432 return rc; 433 } 434 435 rc = seat_find_by_name(dispcfg, seat_name, &seat_id); 436 if (rc != EOK) { 437 printf(NAME ": Seat '%s' not found.\n", seat_name); 438 dispcfg_close(dispcfg); 439 return ENOENT; 440 } 441 442 rc = dispcfg_get_asgn_dev_list(dispcfg, seat_id, &dev_list); 443 if (rc != EOK) { 444 printf(NAME ": Failed getting seat list.\n"); 445 dispcfg_close(dispcfg); 446 return rc; 447 } 448 449 rc = table_create(&table); 450 if (rc != EOK) { 451 printf("Memory allocation failed.\n"); 452 dispcfg_free_dev_list(dev_list); 453 dispcfg_close(dispcfg); 454 return rc; 455 } 456 457 table_header_row(table); 458 table_printf(table, "Device Name\n"); 459 460 for (i = 0; i < dev_list->ndevs; i++) { 461 rc = loc_service_get_name(dev_list->devs[i], &svc_name); 462 if (rc != EOK) { 463 printf("Failed getting name of service %zu\n", 464 (size_t)dev_list->devs[i]); 465 continue; 466 } 467 468 table_printf(table, "%s\n", svc_name); 469 free(svc_name); 470 } 471 472 if (dev_list->ndevs != 0) { 473 rc = table_print_out(table, stdout); 474 if (rc != EOK) { 475 printf("Error printing table.\n"); 476 table_destroy(table); 477 dispcfg_free_dev_list(dev_list); 478 dispcfg_close(dispcfg); 479 return rc; 480 } 481 } 482 483 dispcfg_close(dispcfg); 484 return EOK; 485 } 486 395 487 int main(int argc, char *argv[]) 396 488 { … … 423 515 if (rc != EOK) 424 516 return 1; 517 } else if (str_cmp(argv[1], "list-dev") == 0) { 518 rc = list_dev(dispcfg_svc, argc - 2, argv + 2); 519 if (rc != EOK) 520 return 1; 425 521 } else { 426 522 printf(NAME ": Unknown command '%s'.\n", argv[1]); -
uspace/app/meson.build
rec8ef12 rc0757e1f 40 40 'df', 41 41 'disp', 42 'display-cfg', 42 43 'dnscfg', 43 44 'dnsres', -
uspace/app/uidemo/uidemo.c
rec8ef12 rc0757e1f 52 52 #include <ui/promptdialog.h> 53 53 #include <ui/resource.h> 54 #include <ui/selectdialog.h> 54 55 #include <ui/tab.h> 55 56 #include <ui/tabset.h> … … 108 109 static void uidemo_file_exit(ui_menu_entry_t *, void *); 109 110 static void uidemo_edit_modify(ui_menu_entry_t *, void *); 111 static void uidemo_edit_insert_character(ui_menu_entry_t *, void *); 110 112 111 113 static void file_dialog_bok(ui_file_dialog_t *, void *, const char *); … … 127 129 .bcancel = prompt_dialog_bcancel, 128 130 .close = prompt_dialog_close 131 }; 132 133 static void select_dialog_bok(ui_select_dialog_t *, void *, void *); 134 static void select_dialog_bcancel(ui_select_dialog_t *, void *); 135 static void select_dialog_close(ui_select_dialog_t *, void *); 136 137 static ui_select_dialog_cb_t select_dialog_cb = { 138 .bok = select_dialog_bok, 139 .bcancel = select_dialog_bcancel, 140 .close = select_dialog_close 129 141 }; 130 142 … … 432 444 rc = ui_prompt_dialog_create(demo->ui, &pdparams, &dialog); 433 445 if (rc != EOK) { 434 printf("Error creating messagedialog.\n");446 printf("Error creating prompt dialog.\n"); 435 447 return; 436 448 } 437 449 438 450 ui_prompt_dialog_set_cb(dialog, &prompt_dialog_cb, demo); 451 } 452 453 /** Edit / Insert Character menu entry selected. 454 * 455 * @param mentry Menu entry 456 * @param arg Argument (demo) 457 */ 458 static void uidemo_edit_insert_character(ui_menu_entry_t *mentry, void *arg) 459 { 460 ui_demo_t *demo = (ui_demo_t *) arg; 461 ui_select_dialog_params_t sdparams; 462 ui_select_dialog_t *dialog; 463 ui_list_entry_attr_t attr; 464 errno_t rc; 465 466 ui_select_dialog_params_init(&sdparams); 467 sdparams.caption = "Insert Character"; 468 sdparams.prompt = "Select character to insert"; 469 470 rc = ui_select_dialog_create(demo->ui, &sdparams, &dialog); 471 if (rc != EOK) { 472 printf("Error creating select dialog.\n"); 473 return; 474 } 475 476 ui_list_entry_attr_init(&attr); 477 attr.caption = "Dollar sign ($)"; 478 attr.arg = (void *)'$'; 479 rc = ui_select_dialog_append(dialog, &attr); 480 if (rc != EOK) { 481 printf("Error appending entry to list.\n"); 482 return; 483 } 484 485 ui_list_entry_attr_init(&attr); 486 attr.caption = "Hash sign (#)"; 487 attr.arg = (void *)'#'; 488 rc = ui_select_dialog_append(dialog, &attr); 489 if (rc != EOK) { 490 printf("Error appending entry to list.\n"); 491 return; 492 } 493 494 ui_list_entry_attr_init(&attr); 495 attr.caption = "Question mark (?)"; 496 attr.arg = (void *)'?'; 497 rc = ui_select_dialog_append(dialog, &attr); 498 if (rc != EOK) { 499 printf("Error appending entry to list.\n"); 500 return; 501 } 502 503 ui_select_dialog_set_cb(dialog, &select_dialog_cb, demo); 504 505 (void) ui_select_dialog_paint(dialog); 439 506 } 440 507 … … 525 592 /** Prompt dialog cancel button press. 526 593 * 527 * @param dialog Filedialog594 * @param dialog Prompt dialog 528 595 * @param arg Argument (ui_demo_t *) 529 596 */ … … 538 605 /** Prompt dialog close request. 539 606 * 540 * @param dialog Filedialog607 * @param dialog Prompt dialog 541 608 * @param arg Argument (ui_demo_t *) 542 609 */ … … 547 614 (void) demo; 548 615 ui_prompt_dialog_destroy(dialog); 616 } 617 618 /** Select dialog OK button press. 619 * 620 * @param dialog Select dialog 621 * @param arg Argument (ui_demo_t *) 622 * @param text Submitted text 623 */ 624 static void select_dialog_bok(ui_select_dialog_t *dialog, void *arg, 625 void *earg) 626 { 627 ui_demo_t *demo = (ui_demo_t *) arg; 628 char str[2]; 629 630 ui_select_dialog_destroy(dialog); 631 str[0] = (char)(intptr_t)earg; 632 str[1] = '\0'; 633 (void) ui_entry_insert_str(demo->entry, str); 634 } 635 636 /** Select dialog cancel button press. 637 * 638 * @param dialog Select dialog 639 * @param arg Argument (ui_demo_t *) 640 */ 641 static void select_dialog_bcancel(ui_select_dialog_t *dialog, void *arg) 642 { 643 ui_demo_t *demo = (ui_demo_t *) arg; 644 645 (void) demo; 646 ui_select_dialog_destroy(dialog); 647 } 648 649 /** Select dialog close request. 650 * 651 * @param dialog Select dialog 652 * @param arg Argument (ui_demo_t *) 653 */ 654 static void select_dialog_close(ui_select_dialog_t *dialog, void *arg) 655 { 656 ui_demo_t *demo = (ui_demo_t *) arg; 657 658 (void) demo; 659 ui_select_dialog_destroy(dialog); 549 660 } 550 661 … … 598 709 ui_menu_entry_t *mexit; 599 710 ui_menu_entry_t *mmodify; 711 ui_menu_entry_t *minsert_char; 600 712 ui_menu_entry_t *mabout; 601 713 ui_list_entry_attr_t eattr; … … 719 831 720 832 ui_menu_entry_set_cb(mmodify, uidemo_edit_modify, (void *) &demo); 833 834 rc = ui_menu_entry_create(demo.medit, "~I~nsert Character", 835 "", &minsert_char); 836 if (rc != EOK) { 837 printf("Error creating menu.\n"); 838 return rc; 839 } 840 841 ui_menu_entry_set_cb(minsert_char, uidemo_edit_insert_character, 842 (void *) &demo); 721 843 722 844 rc = ui_menu_create(demo.mbar, "~P~references", &demo.mpreferences); -
uspace/lib/dispcfg/include/dispcfg.h
rec8ef12 rc0757e1f 51 51 extern errno_t dispcfg_dev_assign(dispcfg_t *, sysarg_t, sysarg_t); 52 52 extern errno_t dispcfg_dev_unassign(dispcfg_t *, sysarg_t); 53 extern errno_t dispcfg_get_asgn_dev_list(dispcfg_t *, sysarg_t, 54 dispcfg_dev_list_t **); 55 extern void dispcfg_free_dev_list(dispcfg_dev_list_t *); 53 56 54 57 #endif -
uspace/lib/dispcfg/include/dispcfg_srv.h
rec8ef12 rc0757e1f 56 56 errno_t (*dev_assign)(void *, sysarg_t, sysarg_t); 57 57 errno_t (*dev_unassign)(void *, sysarg_t); 58 errno_t (*get_asgn_dev_list)(void *, sysarg_t, dispcfg_dev_list_t **); 58 59 errno_t (*get_event)(void *, dispcfg_ev_t *); 59 60 }; -
uspace/lib/dispcfg/include/ipc/dispcfg.h
rec8ef12 rc0757e1f 46 46 DISPCFG_DEV_ASSIGN, 47 47 DISPCFG_DEV_UNASSIGN, 48 DISPCFG_GET_ASGN_DEV_LIST, 48 49 DISPCFG_GET_EVENT, 49 50 } dispcfg_request_t; -
uspace/lib/dispcfg/include/types/dispcfg.h
rec8ef12 rc0757e1f 85 85 } dispcfg_seat_info_t; 86 86 87 /** Assigned device list */ 88 typedef struct { 89 /** Number of devices */ 90 size_t ndevs; 91 /** ID for each device */ 92 sysarg_t *devs; 93 } dispcfg_dev_list_t; 94 87 95 #endif 88 96 -
uspace/lib/dispcfg/src/dispcfg.c
rec8ef12 rc0757e1f 206 206 /** Free seat list. 207 207 * 208 * @param list Display configurationlist208 * @param list Seat list 209 209 */ 210 210 void dispcfg_free_seat_list(dispcfg_seat_list_t *list) … … 277 277 /** Free seat information. 278 278 * 279 * @param info Display configurationinformation279 * @param info Seat information 280 280 */ 281 281 void dispcfg_free_seat_info(dispcfg_seat_info_t *info) … … 378 378 async_exchange_end(exch); 379 379 return rc; 380 } 381 382 /** Get list of devices assigned to a seat. 383 * 384 * @param dispcfg Display configuration 385 * @param seat_id Seat ID 386 * @param rlist Place to store pointer to new device list structure 387 * @return EOK on success or an error code 388 */ 389 errno_t dispcfg_get_asgn_dev_list(dispcfg_t *dispcfg, sysarg_t seat_id, 390 dispcfg_dev_list_t **rlist) 391 { 392 async_exch_t *exch; 393 aid_t req; 394 ipc_call_t answer; 395 dispcfg_dev_list_t *list; 396 sysarg_t ndevs; 397 sysarg_t *devs; 398 errno_t rc; 399 400 exch = async_exchange_begin(dispcfg->sess); 401 req = async_send_1(exch, DISPCFG_GET_ASGN_DEV_LIST, seat_id, &answer); 402 403 /* Receive device list length */ 404 rc = async_data_read_start(exch, &ndevs, sizeof (ndevs)); 405 if (rc != EOK) { 406 async_exchange_end(exch); 407 async_wait_for(req, &rc); 408 return rc; 409 } 410 411 devs = calloc(ndevs, sizeof(sysarg_t)); 412 if (devs == NULL) { 413 async_exchange_end(exch); 414 async_forget(req); 415 return ENOMEM; 416 } 417 418 /* Receive device list */ 419 rc = async_data_read_start(exch, devs, ndevs * sizeof (sysarg_t)); 420 async_exchange_end(exch); 421 422 if (rc != EOK) { 423 async_forget(req); 424 return rc; 425 } 426 427 async_wait_for(req, &rc); 428 if (rc != EOK) 429 return rc; 430 431 list = calloc(1, sizeof(dispcfg_dev_list_t)); 432 if (list == NULL) 433 return ENOMEM; 434 435 list->ndevs = ndevs; 436 list->devs = devs; 437 *rlist = list; 438 return EOK; 439 } 440 441 /** Free device list. 442 * 443 * @param list Device list 444 */ 445 void dispcfg_free_dev_list(dispcfg_dev_list_t *list) 446 { 447 free(list->devs); 448 free(list); 380 449 } 381 450 -
uspace/lib/dispcfg/src/dispcfg_srv.c
rec8ef12 rc0757e1f 293 293 } 294 294 295 static void dispcfg_get_asgn_dev_list_srv(dispcfg_srv_t *srv, ipc_call_t *icall) 296 { 297 sysarg_t seat_id; 298 ipc_call_t call; 299 dispcfg_dev_list_t *list = NULL; 300 size_t size; 301 errno_t rc; 302 303 seat_id = ipc_get_arg1(icall); 304 305 if (srv->ops->get_asgn_dev_list == NULL) { 306 async_answer_0(icall, ENOTSUP); 307 return; 308 } 309 310 rc = srv->ops->get_asgn_dev_list(srv->arg, seat_id, &list); 311 if (rc != EOK) { 312 async_answer_0(icall, rc); 313 return; 314 } 315 316 /* Send list size */ 317 318 if (!async_data_read_receive(&call, &size)) { 319 dispcfg_free_dev_list(list); 320 async_answer_0(&call, EREFUSED); 321 async_answer_0(icall, EREFUSED); 322 return; 323 } 324 325 if (size != sizeof(list->ndevs)) { 326 dispcfg_free_dev_list(list); 327 async_answer_0(&call, EINVAL); 328 async_answer_0(icall, EINVAL); 329 return; 330 } 331 332 rc = async_data_read_finalize(&call, &list->ndevs, size); 333 if (rc != EOK) { 334 dispcfg_free_dev_list(list); 335 async_answer_0(&call, rc); 336 async_answer_0(icall, rc); 337 return; 338 } 339 340 /* Send device list */ 341 342 if (!async_data_read_receive(&call, &size)) { 343 dispcfg_free_dev_list(list); 344 async_answer_0(&call, EREFUSED); 345 async_answer_0(icall, EREFUSED); 346 return; 347 } 348 349 if (size != list->ndevs * sizeof(sysarg_t)) { 350 dispcfg_free_dev_list(list); 351 async_answer_0(&call, EINVAL); 352 async_answer_0(icall, EINVAL); 353 return; 354 } 355 356 rc = async_data_read_finalize(&call, list->devs, size); 357 if (rc != EOK) { 358 dispcfg_free_dev_list(list); 359 async_answer_0(&call, rc); 360 async_answer_0(icall, rc); 361 return; 362 } 363 364 async_answer_0(icall, EOK); 365 dispcfg_free_dev_list(list); 366 } 367 295 368 static void dispcfg_get_event_srv(dispcfg_srv_t *srv, ipc_call_t *icall) 296 369 { … … 372 445 case DISPCFG_DEV_UNASSIGN: 373 446 dispcfg_dev_unassign_srv(srv, &call); 447 break; 448 case DISPCFG_GET_ASGN_DEV_LIST: 449 dispcfg_get_asgn_dev_list_srv(srv, &call); 374 450 break; 375 451 case DISPCFG_GET_EVENT: -
uspace/lib/dispcfg/test/dispcfg.c
rec8ef12 rc0757e1f 52 52 static errno_t test_dev_assign(void *, sysarg_t, sysarg_t); 53 53 static errno_t test_dev_unassign(void *, sysarg_t); 54 static errno_t test_get_asgn_dev_list(void *, sysarg_t, dispcfg_dev_list_t **); 54 55 static errno_t test_get_event(void *, dispcfg_ev_t *); 55 56 … … 64 65 .dev_assign = test_dev_assign, 65 66 .dev_unassign = test_dev_unassign, 67 .get_asgn_dev_list = test_get_asgn_dev_list, 66 68 .get_event = test_get_event 67 69 }; … … 102 104 bool dev_unassign_called; 103 105 sysarg_t dev_unassign_svc_id; 106 107 bool get_asgn_dev_list_called; 108 sysarg_t get_asgn_dev_list_seat_id; 109 dispcfg_dev_list_t *get_asgn_dev_list_rlist; 104 110 105 111 bool get_event_called; … … 604 610 } 605 611 612 /** dispcfg_get_asgn_dev_list() with server returning error response works */ 613 PCUT_TEST(get_asgn_dev_list_failure) 614 { 615 errno_t rc; 616 service_id_t sid; 617 dispcfg_t *dispcfg = NULL; 618 dispcfg_dev_list_t *list; 619 sysarg_t seat_id; 620 test_response_t resp; 621 622 async_set_fallback_port_handler(test_dispcfg_conn, &resp); 623 624 // FIXME This causes this test to be non-reentrant! 625 rc = loc_server_register(test_dispcfg_server); 626 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 627 628 rc = loc_service_register(test_dispcfg_svc, &sid); 629 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 630 631 rc = dispcfg_open(test_dispcfg_svc, NULL, NULL, &dispcfg); 632 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 633 PCUT_ASSERT_NOT_NULL(dispcfg); 634 635 resp.rc = ENOMEM; 636 resp.get_asgn_dev_list_called = false; 637 seat_id = 42; 638 639 rc = dispcfg_get_asgn_dev_list(dispcfg, seat_id, &list); 640 PCUT_ASSERT_TRUE(resp.get_asgn_dev_list_called); 641 PCUT_ASSERT_INT_EQUALS(seat_id, resp.get_asgn_dev_list_seat_id); 642 PCUT_ASSERT_ERRNO_VAL(resp.rc, rc); 643 644 dispcfg_close(dispcfg); 645 rc = loc_service_unregister(sid); 646 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 647 } 648 649 /** dispcfg_get_asgn_dev_list() with server returning success response works */ 650 PCUT_TEST(get_asgn_dev_list_success) 651 { 652 errno_t rc; 653 service_id_t sid; 654 dispcfg_t *dispcfg = NULL; 655 dispcfg_dev_list_t *list; 656 sysarg_t seat_id; 657 test_response_t resp; 658 659 async_set_fallback_port_handler(test_dispcfg_conn, &resp); 660 661 // FIXME This causes this test to be non-reentrant! 662 rc = loc_server_register(test_dispcfg_server); 663 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 664 665 rc = loc_service_register(test_dispcfg_svc, &sid); 666 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 667 668 rc = dispcfg_open(test_dispcfg_svc, NULL, NULL, &dispcfg); 669 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 670 PCUT_ASSERT_NOT_NULL(dispcfg); 671 672 resp.rc = EOK; 673 resp.get_asgn_dev_list_called = false; 674 resp.get_asgn_dev_list_rlist = calloc(1, sizeof(dispcfg_dev_list_t)); 675 PCUT_ASSERT_NOT_NULL(resp.get_asgn_dev_list_rlist); 676 resp.get_asgn_dev_list_rlist->ndevs = 2; 677 resp.get_asgn_dev_list_rlist->devs = calloc(2, sizeof(sysarg_t)); 678 PCUT_ASSERT_NOT_NULL(resp.get_asgn_dev_list_rlist->devs); 679 resp.get_asgn_dev_list_rlist->devs[0] = 11; 680 resp.get_asgn_dev_list_rlist->devs[1] = 12; 681 seat_id = 42; 682 683 rc = dispcfg_get_asgn_dev_list(dispcfg, seat_id, &list); 684 PCUT_ASSERT_TRUE(resp.get_asgn_dev_list_called); 685 PCUT_ASSERT_INT_EQUALS(seat_id, resp.get_asgn_dev_list_seat_id); 686 PCUT_ASSERT_ERRNO_VAL(resp.rc, rc); 687 688 PCUT_ASSERT_INT_EQUALS(2, list->ndevs); 689 PCUT_ASSERT_INT_EQUALS(11, list->devs[0]); 690 PCUT_ASSERT_INT_EQUALS(12, list->devs[1]); 691 692 dispcfg_free_dev_list(list); 693 dispcfg_close(dispcfg); 694 rc = loc_service_unregister(sid); 695 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 696 } 697 606 698 /** Window added event can be delivered from server to client callback function */ 607 699 PCUT_TEST(seat_added_deliver) … … 808 900 } 809 901 902 static errno_t test_get_asgn_dev_list(void *arg, sysarg_t seat_id, 903 dispcfg_dev_list_t **rlist) 904 { 905 test_response_t *resp = (test_response_t *) arg; 906 907 resp->get_asgn_dev_list_called = true; 908 resp->get_asgn_dev_list_seat_id = seat_id; 909 910 if (resp->rc != EOK) 911 return resp->rc; 912 913 *rlist = resp->get_asgn_dev_list_rlist; 914 return EOK; 915 } 916 810 917 static errno_t test_get_event(void *arg, dispcfg_ev_t *event) 811 918 { -
uspace/lib/ui/include/ui/entry.h
rec8ef12 rc0757e1f 54 54 extern const char *ui_entry_get_text(ui_entry_t *); 55 55 extern errno_t ui_entry_paint(ui_entry_t *); 56 extern errno_t ui_entry_insert_str(ui_entry_t *, const char *); 56 57 extern void ui_entry_activate(ui_entry_t *); 57 58 extern void ui_entry_deactivate(ui_entry_t *); -
uspace/lib/ui/include/ui/list.h
rec8ef12 rc0757e1f 48 48 extern ui_control_t *ui_list_ctl(ui_list_t *); 49 49 extern void ui_list_set_cb(ui_list_t *, ui_list_cb_t *, void *); 50 extern void *ui_list_get_cb_arg(ui_list_t *); 50 51 extern void ui_list_set_rect(ui_list_t *, gfx_rect_t *); 51 52 extern errno_t ui_list_activate(ui_list_t *); 52 53 extern void ui_list_deactivate(ui_list_t *); 53 54 extern ui_list_entry_t *ui_list_get_cursor(ui_list_t *); 55 extern void ui_list_set_cursor(ui_list_t *, ui_list_entry_t *); 54 56 extern void ui_list_entry_attr_init(ui_list_entry_attr_t *); 55 57 extern errno_t ui_list_entry_append(ui_list_t *, … … 57 59 extern void ui_list_entry_delete(ui_list_entry_t *); 58 60 extern void *ui_list_entry_get_arg(ui_list_entry_t *); 61 extern ui_list_t *ui_list_entry_get_list(ui_list_entry_t *); 59 62 extern size_t ui_list_entries_cnt(ui_list_t *); 60 63 extern errno_t ui_list_sort(ui_list_t *); -
uspace/lib/ui/include/ui/tab.h
rec8ef12 rc0757e1f 43 43 #include <stdbool.h> 44 44 #include <types/common.h> 45 #include <types/ui/control.h> 45 46 #include <types/ui/tab.h> 46 47 #include <types/ui/tabset.h> -
uspace/lib/ui/meson.build
rec8ef12 rc0757e1f 52 52 'src/resource.c', 53 53 'src/scrollbar.c', 54 'src/selectdialog.c', 54 55 'src/slider.c', 55 56 'src/tab.c', … … 85 86 'test/resource.c', 86 87 'test/scrollbar.c', 88 'test/selectdialog.c', 87 89 'test/slider.c', 88 90 'test/tab.c', -
uspace/lib/ui/private/entry.h
rec8ef12 rc0757e1f 92 92 } ui_entry_geom_t; 93 93 94 extern errno_t ui_entry_insert_str(ui_entry_t *, const char *);95 94 extern ui_evclaim_t ui_entry_key_press_ctrl(ui_entry_t *, kbd_event_t *); 96 95 extern ui_evclaim_t ui_entry_key_press_shift(ui_entry_t *, kbd_event_t *); -
uspace/lib/ui/private/filelist.h
rec8ef12 rc0757e1f 103 103 104 104 extern bool ui_file_list_is_active(ui_file_list_t *); 105 extern void ui_file_list_entry_de lete(ui_file_list_entry_t *);105 extern void ui_file_list_entry_destroy(ui_file_list_entry_t *); 106 106 extern void ui_file_list_clear_entries(ui_file_list_t *); 107 107 extern errno_t ui_file_list_sort(ui_file_list_t *); -
uspace/lib/ui/private/list.h
rec8ef12 rc0757e1f 136 136 extern int ui_list_entry_ptr_cmp(const void *, const void *); 137 137 extern size_t ui_list_entry_get_idx(ui_list_entry_t *); 138 extern void ui_list_entry_destroy(ui_list_entry_t *); 138 139 139 140 #endif -
uspace/lib/ui/private/promptdialog.h
rec8ef12 rc0757e1f 45 45 /** Dialog window */ 46 46 struct ui_window *window; 47 /** File nameentry */47 /** Text entry */ 48 48 struct ui_entry *ename; 49 49 /** OK button */ -
uspace/lib/ui/src/filelist.c
rec8ef12 rc0757e1f 46 46 #include <qsort.h> 47 47 #include "../private/filelist.h" 48 #include "../private/list.h" 48 49 #include "../private/resource.h" 49 50 … … 290 291 * @param entry File list entry 291 292 */ 292 void ui_file_list_entry_de lete(ui_file_list_entry_t *entry)293 { 294 ui_list_entry_de lete(entry->entry);293 void ui_file_list_entry_destroy(ui_file_list_entry_t *entry) 294 { 295 ui_list_entry_destroy(entry->entry); 295 296 free(entry->name); 296 297 free(entry); … … 307 308 entry = ui_file_list_first(flist); 308 309 while (entry != NULL) { 309 ui_file_list_entry_de lete(entry);310 ui_file_list_entry_destroy(entry); 310 311 entry = ui_file_list_first(flist); 311 312 } -
uspace/lib/ui/src/list.c
rec8ef12 rc0757e1f 149 149 list->cb = cb; 150 150 list->cb_arg = arg; 151 } 152 153 /** Get UI list callback argument. 154 * 155 * @param list UI list 156 * @return Callback argument 157 */ 158 void *ui_list_get_cb_arg(ui_list_t *list) 159 { 160 return list->cb_arg; 151 161 } 152 162 … … 701 711 } 702 712 703 /** Delete UI list entry. 713 /** Destroy UI list entry. 714 * 715 * This is the quick way, but does not update cursor or page position. 704 716 * 705 717 * @param entry UI list entry 706 718 */ 707 void ui_list_entry_de lete(ui_list_entry_t *entry)719 void ui_list_entry_destroy(ui_list_entry_t *entry) 708 720 { 709 721 if (entry->list->cursor == entry) … … 718 730 } 719 731 732 /** Delete UI list entry. 733 * 734 * If required, update cursor and page position and repaint. 735 * 736 * @param entry UI list entry 737 */ 738 void ui_list_entry_delete(ui_list_entry_t *entry) 739 { 740 /* Try to make sure entry does not disappear between cursor and page */ 741 if (entry->list->cursor == entry) 742 ui_list_cursor_up(entry->list); 743 if (entry->list->cursor == entry) 744 ui_list_cursor_down(entry->list); 745 if (entry->list->page == entry) 746 ui_list_scroll_up(entry->list); 747 if (entry->list->page == entry) 748 ui_list_scroll_down(entry->list); 749 750 ui_list_entry_destroy(entry); 751 } 752 720 753 /** Get entry argument. 721 754 * … … 728 761 } 729 762 763 /** Get containing list. 764 * 765 * @param entry UI list entry 766 * @return Containing list 767 */ 768 ui_list_t *ui_list_entry_get_list(ui_list_entry_t *entry) 769 { 770 return entry->list; 771 } 772 730 773 /** Clear UI list entry list. 731 774 * … … 738 781 entry = ui_list_first(list); 739 782 while (entry != NULL) { 740 ui_list_entry_de lete(entry);783 ui_list_entry_destroy(entry); 741 784 entry = ui_list_first(list); 742 785 } … … 858 901 { 859 902 return list->cursor; 903 } 904 905 /** Set new cursor position. 906 * 907 * O(N) in list size, use with caution. 908 * 909 * @param list UI list 910 * @param entry New cursor position 911 */ 912 void ui_list_set_cursor(ui_list_t *list, ui_list_entry_t *entry) 913 { 914 size_t idx; 915 916 idx = ui_list_entry_get_idx(entry); 917 ui_list_cursor_move(list, entry, idx); 860 918 } 861 919 … … 912 970 /* Find first page entry (go back rows - 1) */ 913 971 e = entry; 914 for (i = 0; i < rows - 1; i++) {972 for (i = 0; i + 1 < rows; i++) { 915 973 e = ui_list_prev(e); 916 974 } … … 1098 1156 ui_list_entry_t *prev; 1099 1157 1158 if (list->page == NULL) 1159 return; 1160 1100 1161 prev = ui_list_prev(list->page); 1101 1162 if (prev == NULL) … … 1120 1181 size_t i; 1121 1182 size_t rows; 1183 1184 if (list->page == NULL) 1185 return; 1122 1186 1123 1187 next = ui_list_next(list->page); -
uspace/lib/ui/src/promptdialog.c
rec8ef12 rc0757e1f 327 327 { 328 328 ui_prompt_dialog_t *dialog = (ui_prompt_dialog_t *) arg; 329 const char * fname;329 const char *text; 330 330 331 331 if (event->type == KEY_PRESS && … … 334 334 /* Confirm */ 335 335 if (dialog->cb != NULL && dialog->cb->bok != NULL) { 336 fname= ui_entry_get_text(dialog->ename);337 dialog->cb->bok(dialog, dialog->arg, fname);336 text = ui_entry_get_text(dialog->ename); 337 dialog->cb->bok(dialog, dialog->arg, text); 338 338 return; 339 339 } … … 358 358 { 359 359 ui_prompt_dialog_t *dialog = (ui_prompt_dialog_t *) arg; 360 const char * fname;360 const char *text; 361 361 362 362 if (dialog->cb != NULL && dialog->cb->bok != NULL) { 363 fname= ui_entry_get_text(dialog->ename);364 dialog->cb->bok(dialog, dialog->arg, fname);363 text = ui_entry_get_text(dialog->ename); 364 dialog->cb->bok(dialog, dialog->arg, text); 365 365 } 366 366 } -
uspace/lib/ui/test/filelist.c
rec8ef12 rc0757e1f 350 350 } 351 351 352 /** ui_file_list_entry_de lete() deletes entry */353 PCUT_TEST(entry_de lete)352 /** ui_file_list_entry_destroy() destroys entry */ 353 PCUT_TEST(entry_destroy) 354 354 { 355 355 ui_t *ui; … … 386 386 387 387 entry = ui_file_list_first(flist); 388 ui_file_list_entry_de lete(entry);388 ui_file_list_entry_destroy(entry); 389 389 390 390 PCUT_ASSERT_INT_EQUALS(1, ui_list_entries_cnt(flist->list)); 391 391 392 392 entry = ui_file_list_first(flist); 393 ui_file_list_entry_de lete(entry);393 ui_file_list_entry_destroy(entry); 394 394 395 395 PCUT_ASSERT_INT_EQUALS(0, ui_list_entries_cnt(flist->list)); -
uspace/lib/ui/test/list.c
rec8ef12 rc0757e1f 119 119 } 120 120 121 //XXX 122 PCUT_TEST(get_cb_arg) 123 { 124 } 125 121 126 /** ui_list_entry_height() gives the correct height */ 122 127 PCUT_TEST(entry_height) … … 751 756 } 752 757 758 //XXX TODO 759 PCUT_TEST(set_cursor) 760 { 761 } 762 753 763 /** ui_list_entry_attr_init() initializes entry attribute structure */ 754 764 PCUT_TEST(entry_attr_init) … … 902 912 ui_window_destroy(window); 903 913 ui_destroy(ui); 914 } 915 916 //XXX 917 PCUT_TEST(entry_get_list) 918 { 904 919 } 905 920 -
uspace/lib/ui/test/main.c
rec8ef12 rc0757e1f 52 52 PCUT_IMPORT(resource); 53 53 PCUT_IMPORT(scrollbar); 54 PCUT_IMPORT(select_dialog); 54 55 PCUT_IMPORT(slider); 55 56 PCUT_IMPORT(tab); … … 59 60 PCUT_IMPORT(wdecor); 60 61 PCUT_IMPORT(window); 62 61 63 PCUT_MAIN(); -
uspace/srv/hid/display/cfgops.c
rec8ef12 rc0757e1f 50 50 static errno_t dispc_dev_assign(void *, sysarg_t, sysarg_t); 51 51 static errno_t dispc_dev_unassign(void *, sysarg_t); 52 static errno_t dispc_get_asgn_dev_list(void *, sysarg_t, dispcfg_dev_list_t **); 52 53 static errno_t dispc_get_event(void *, dispcfg_ev_t *); 53 54 … … 59 60 .dev_assign = dispc_dev_assign, 60 61 .dev_unassign = dispc_dev_unassign, 62 .get_asgn_dev_list = dispc_get_asgn_dev_list, 61 63 .get_event = dispc_get_event, 62 64 }; … … 281 283 } 282 284 285 /** Get assigned device list. 286 * 287 * @param arg Argument (CFG client) 288 * @param seat_id Seat ID 289 * @param rlist Place to store pointer to new list 290 * @return EOK on success or an error code 291 */ 292 static errno_t dispc_get_asgn_dev_list(void *arg, sysarg_t seat_id, 293 dispcfg_dev_list_t **rlist) 294 { 295 ds_cfgclient_t *cfgclient = (ds_cfgclient_t *)arg; 296 dispcfg_dev_list_t *list; 297 ds_seat_t *seat; 298 ds_idevcfg_t *idevcfg; 299 unsigned i; 300 301 log_msg(LOG_DEFAULT, LVL_DEBUG, "dispcfg_get_asgn_dev_list()"); 302 303 list = calloc(1, sizeof(dispcfg_dev_list_t)); 304 if (list == NULL) 305 return ENOMEM; 306 307 ds_display_lock(cfgclient->display); 308 309 seat = ds_display_find_seat(cfgclient->display, seat_id); 310 if (seat == NULL) { 311 ds_display_unlock(cfgclient->display); 312 free(list); 313 return ENOENT; 314 } 315 316 /* Count the number of devices */ 317 list->ndevs = 0; 318 idevcfg = ds_seat_first_idevcfg(seat); 319 while (idevcfg != NULL) { 320 ++list->ndevs; 321 idevcfg = ds_display_next_idevcfg(idevcfg); 322 } 323 324 /* Allocate array for device IDs */ 325 list->devs = calloc(list->ndevs, sizeof(sysarg_t)); 326 if (list->devs == NULL) { 327 ds_display_unlock(cfgclient->display); 328 free(list); 329 return ENOMEM; 330 } 331 332 /* Fill in device IDs */ 333 i = 0; 334 idevcfg = ds_seat_first_idevcfg(seat); 335 while (idevcfg != NULL) { 336 list->devs[i++] = idevcfg->svc_id; 337 idevcfg = ds_display_next_idevcfg(idevcfg); 338 } 339 340 ds_display_unlock(cfgclient->display); 341 *rlist = list; 342 return EOK; 343 } 344 283 345 /** Get display configuration event. 284 346 *
Note:
See TracChangeset
for help on using the changeset viewer.