Changeset 35cffea in mainline for uspace/lib/display
- Timestamp:
- 2022-05-19T08:02:31Z (3 years ago)
- Branches:
- master, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- ad698f4
- Parents:
- fd05ea6
- git-author:
- Jiri Svoboda <jiri@…> (2022-05-18 17:02:12)
- git-committer:
- Jiri Svoboda <jiri@…> (2022-05-19 08:02:31)
- Location:
- uspace/lib/display
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/display/include/disp_srv.h
rfd05ea6 r35cffea 1 1 /* 2 * Copyright (c) 202 1Jiri Svoboda2 * Copyright (c) 2022 Jiri Svoboda 3 3 * All rights reserved. 4 4 * … … 62 62 errno_t (*window_move)(void *, sysarg_t, gfx_coord2_t *); 63 63 errno_t (*window_get_pos)(void *, sysarg_t, gfx_coord2_t *); 64 errno_t (*window_get_max_rect)(void *, sysarg_t, gfx_rect_t *); 64 65 errno_t (*window_resize)(void *, sysarg_t, gfx_coord2_t *, gfx_rect_t *); 66 errno_t (*window_maximize)(void *, sysarg_t); 67 errno_t (*window_unmaximize)(void *, sysarg_t); 65 68 errno_t (*window_set_cursor)(void *, sysarg_t, display_stock_cursor_t); 66 69 errno_t (*get_event)(void *, sysarg_t *, display_wnd_ev_t *); -
uspace/lib/display/include/display.h
rfd05ea6 r35cffea 1 1 /* 2 * Copyright (c) 202 1Jiri Svoboda2 * Copyright (c) 2022 Jiri Svoboda 3 3 * All rights reserved. 4 4 * … … 59 59 extern errno_t display_window_move(display_window_t *, gfx_coord2_t *); 60 60 extern errno_t display_window_get_pos(display_window_t *, gfx_coord2_t *); 61 extern errno_t display_window_get_max_rect(display_window_t *, gfx_rect_t *); 61 62 extern errno_t display_window_resize(display_window_t *, 62 63 gfx_coord2_t *, gfx_rect_t *); 64 extern errno_t display_window_maximize(display_window_t *); 65 extern errno_t display_window_unmaximize(display_window_t *); 63 66 extern errno_t display_window_set_cursor(display_window_t *, 64 67 display_stock_cursor_t); -
uspace/lib/display/include/ipc/display.h
rfd05ea6 r35cffea 1 1 /* 2 * Copyright (c) 202 1Jiri Svoboda2 * Copyright (c) 2022 Jiri Svoboda 3 3 * All rights reserved. 4 4 * … … 42 42 DISPLAY_WINDOW_CREATE, 43 43 DISPLAY_WINDOW_DESTROY, 44 DISPLAY_WINDOW_MAXIMIZE, 44 45 DISPLAY_WINDOW_MOVE, 45 46 DISPLAY_WINDOW_MOVE_REQ, 46 47 DISPLAY_WINDOW_GET_POS, 48 DISPLAY_WINDOW_GET_MAX_RECT, 47 49 DISPLAY_WINDOW_RESIZE, 48 50 DISPLAY_WINDOW_RESIZE_REQ, 49 51 DISPLAY_WINDOW_SET_CURSOR, 52 DISPLAY_WINDOW_UNMAXIMIZE, 50 53 DISPLAY_GET_EVENT, 51 54 DISPLAY_GET_INFO -
uspace/lib/display/include/types/display/wndparams.h
rfd05ea6 r35cffea 1 1 /* 2 * Copyright (c) 202 1Jiri Svoboda2 * Copyright (c) 2022 Jiri Svoboda 3 3 * All rights reserved. 4 4 * … … 43 43 wndf_popup = 0x1, 44 44 /** Set specific initial window position */ 45 wndf_setpos = 0x2 45 wndf_setpos = 0x2, 46 /** Window is maximized */ 47 wndf_maximized = 0x4 46 48 } display_wnd_flags_t; 47 49 -
uspace/lib/display/src/disp_srv.c
rfd05ea6 r35cffea 1 1 /* 2 * Copyright (c) 202 1Jiri Svoboda2 * Copyright (c) 2022 Jiri Svoboda 3 3 * All rights reserved. 4 4 * … … 230 230 } 231 231 232 static void display_window_get_max_rect_srv(display_srv_t *srv, 233 ipc_call_t *icall) 234 { 235 sysarg_t wnd_id; 236 ipc_call_t call; 237 gfx_rect_t rect; 238 size_t size; 239 errno_t rc; 240 241 wnd_id = ipc_get_arg1(icall); 242 243 if (srv->ops->window_get_max_rect == NULL) { 244 async_answer_0(icall, ENOTSUP); 245 return; 246 } 247 248 if (!async_data_read_receive(&call, &size)) { 249 async_answer_0(icall, EREFUSED); 250 return; 251 } 252 253 rc = srv->ops->window_get_max_rect(srv->arg, wnd_id, &rect); 254 if (rc != EOK) { 255 async_answer_0(&call, rc); 256 async_answer_0(icall, rc); 257 return; 258 } 259 260 if (size != sizeof(gfx_rect_t)) { 261 async_answer_0(&call, EINVAL); 262 async_answer_0(icall, EINVAL); 263 return; 264 } 265 266 rc = async_data_read_finalize(&call, &rect, size); 267 if (rc != EOK) { 268 async_answer_0(&call, rc); 269 async_answer_0(icall, rc); 270 return; 271 } 272 273 async_answer_0(icall, EOK); 274 } 275 232 276 static void display_window_resize_req_srv(display_srv_t *srv, ipc_call_t *icall) 233 277 { … … 306 350 rc = srv->ops->window_resize(srv->arg, wnd_id, &wresize.offs, 307 351 &wresize.nrect); 352 async_answer_0(icall, rc); 353 } 354 355 static void display_window_maximize_srv(display_srv_t *srv, ipc_call_t *icall) 356 { 357 sysarg_t wnd_id; 358 errno_t rc; 359 360 wnd_id = ipc_get_arg1(icall); 361 362 if (srv->ops->window_maximize == NULL) { 363 async_answer_0(icall, ENOTSUP); 364 return; 365 } 366 367 rc = srv->ops->window_maximize(srv->arg, wnd_id); 368 async_answer_0(icall, rc); 369 } 370 371 static void display_window_unmaximize_srv(display_srv_t *srv, ipc_call_t *icall) 372 { 373 sysarg_t wnd_id; 374 errno_t rc; 375 376 wnd_id = ipc_get_arg1(icall); 377 378 if (srv->ops->window_unmaximize == NULL) { 379 async_answer_0(icall, ENOTSUP); 380 return; 381 } 382 383 rc = srv->ops->window_unmaximize(srv->arg, wnd_id); 308 384 async_answer_0(icall, rc); 309 385 } … … 445 521 display_window_get_pos_srv(srv, &call); 446 522 break; 523 case DISPLAY_WINDOW_GET_MAX_RECT: 524 display_window_get_max_rect_srv(srv, &call); 525 break; 447 526 case DISPLAY_WINDOW_RESIZE_REQ: 448 527 display_window_resize_req_srv(srv, &call); … … 450 529 case DISPLAY_WINDOW_RESIZE: 451 530 display_window_resize_srv(srv, &call); 531 break; 532 case DISPLAY_WINDOW_MAXIMIZE: 533 display_window_maximize_srv(srv, &call); 534 break; 535 case DISPLAY_WINDOW_UNMAXIMIZE: 536 display_window_unmaximize_srv(srv, &call); 452 537 break; 453 538 case DISPLAY_WINDOW_SET_CURSOR: -
uspace/lib/display/src/display.c
rfd05ea6 r35cffea 1 1 /* 2 * Copyright (c) 202 1Jiri Svoboda2 * Copyright (c) 2022 Jiri Svoboda 3 3 * All rights reserved. 4 4 * … … 350 350 } 351 351 352 /** Get display window maximized rectangle. 353 * 354 * Get the rectangle to which a window would be maximized. 355 * 356 * @param window Window 357 * @param rect Place to store maximized rectangle 358 * @return EOK on success or an error code 359 */ 360 errno_t display_window_get_max_rect(display_window_t *window, gfx_rect_t *rect) 361 { 362 async_exch_t *exch; 363 aid_t req; 364 ipc_call_t answer; 365 errno_t rc; 366 367 exch = async_exchange_begin(window->display->sess); 368 req = async_send_1(exch, DISPLAY_WINDOW_GET_MAX_RECT, window->id, 369 &answer); 370 rc = async_data_read_start(exch, rect, sizeof (gfx_rect_t)); 371 async_exchange_end(exch); 372 if (rc != EOK) { 373 async_forget(req); 374 return rc; 375 } 376 377 async_wait_for(req, &rc); 378 if (rc != EOK) 379 return rc; 380 381 return EOK; 382 } 383 352 384 /** Request a window resize. 353 385 * … … 453 485 454 486 return EOK; 487 } 488 489 /** Maximize window. 490 * 491 * @param window Window 492 * @return EOK on success or an error code 493 */ 494 errno_t display_window_maximize(display_window_t *window) 495 { 496 async_exch_t *exch; 497 errno_t rc; 498 499 exch = async_exchange_begin(window->display->sess); 500 rc = async_req_1_0(exch, DISPLAY_WINDOW_MAXIMIZE, window->id); 501 async_exchange_end(exch); 502 503 return rc; 504 } 505 506 /** Unmaximize window. 507 * 508 * @param window Window 509 * @return EOK on success or an error code 510 */ 511 errno_t display_window_unmaximize(display_window_t *window) 512 { 513 async_exch_t *exch; 514 errno_t rc; 515 516 exch = async_exchange_begin(window->display->sess); 517 rc = async_req_1_0(exch, DISPLAY_WINDOW_UNMAXIMIZE, window->id); 518 async_exchange_end(exch); 519 520 return rc; 455 521 } 456 522 -
uspace/lib/display/test/display.c
rfd05ea6 r35cffea 1 1 /* 2 * Copyright (c) 202 1Jiri Svoboda2 * Copyright (c) 2022 Jiri Svoboda 3 3 * All rights reserved. 4 4 * … … 60 60 static errno_t test_window_move(void *, sysarg_t, gfx_coord2_t *); 61 61 static errno_t test_window_get_pos(void *, sysarg_t, gfx_coord2_t *); 62 static errno_t test_window_get_max_rect(void *, sysarg_t, gfx_rect_t *); 62 63 static errno_t test_window_resize_req(void *, sysarg_t, display_wnd_rsztype_t, 63 64 gfx_coord2_t *); 64 65 static errno_t test_window_resize(void *, sysarg_t, gfx_coord2_t *, 65 66 gfx_rect_t *); 67 static errno_t test_window_maximize(void *, sysarg_t); 68 static errno_t test_window_unmaximize(void *, sysarg_t); 66 69 static errno_t test_window_set_cursor(void *, sysarg_t, display_stock_cursor_t); 67 70 static errno_t test_get_event(void *, sysarg_t *, display_wnd_ev_t *); … … 76 79 .window_move = test_window_move, 77 80 .window_get_pos = test_window_get_pos, 81 .window_get_max_rect = test_window_get_max_rect, 78 82 .window_resize_req = test_window_resize_req, 79 83 .window_resize = test_window_resize, 84 .window_maximize = test_window_maximize, 85 .window_unmaximize = test_window_unmaximize, 80 86 .window_set_cursor = test_window_set_cursor, 81 87 .get_event = test_get_event, … … 122 128 gfx_coord2_t get_pos_rpos; 123 129 130 bool window_get_max_rect_called; 131 sysarg_t get_max_rect_wnd_id; 132 gfx_rect_t get_max_rect_rrect; 133 124 134 bool window_resize_req_called; 125 135 sysarg_t resize_req_wnd_id; … … 131 141 gfx_rect_t resize_nbound; 132 142 sysarg_t resize_wnd_id; 143 144 bool window_maximize_called; 145 bool window_unmaximize_called; 133 146 134 147 bool window_set_cursor_called; … … 674 687 } 675 688 689 /** display_window_get_max_rect() with server returning error response works. */ 690 PCUT_TEST(window_get_max_rect_failure) 691 { 692 errno_t rc; 693 service_id_t sid; 694 display_t *disp = NULL; 695 display_wnd_params_t params; 696 display_window_t *wnd; 697 gfx_rect_t rect; 698 test_response_t resp; 699 700 async_set_fallback_port_handler(test_display_conn, &resp); 701 702 // FIXME This causes this test to be non-reentrant! 703 rc = loc_server_register(test_display_server); 704 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 705 706 rc = loc_service_register(test_display_svc, &sid); 707 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 708 709 rc = display_open(test_display_svc, &disp); 710 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 711 PCUT_ASSERT_NOT_NULL(disp); 712 713 resp.rc = EOK; 714 display_wnd_params_init(¶ms); 715 params.rect.p0.x = 0; 716 params.rect.p0.y = 0; 717 params.rect.p0.x = 100; 718 params.rect.p0.y = 100; 719 720 rc = display_window_create(disp, ¶ms, &test_display_wnd_cb, 721 (void *) &resp, &wnd); 722 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 723 PCUT_ASSERT_NOT_NULL(wnd); 724 725 resp.rc = EIO; 726 resp.window_get_max_rect_called = false; 727 728 rect.p0.x = 0; 729 rect.p0.y = 0; 730 rect.p1.x = 0; 731 rect.p1.y = 0; 732 733 rc = display_window_get_max_rect(wnd, &rect); 734 PCUT_ASSERT_TRUE(resp.window_get_max_rect_called); 735 PCUT_ASSERT_ERRNO_VAL(resp.rc, rc); 736 PCUT_ASSERT_INT_EQUALS(wnd->id, resp.get_max_rect_wnd_id); 737 PCUT_ASSERT_INT_EQUALS(0, rect.p0.x); 738 PCUT_ASSERT_INT_EQUALS(0, rect.p0.y); 739 PCUT_ASSERT_INT_EQUALS(0, rect.p1.x); 740 PCUT_ASSERT_INT_EQUALS(0, rect.p1.y); 741 742 display_window_destroy(wnd); 743 display_close(disp); 744 rc = loc_service_unregister(sid); 745 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 746 } 747 748 /** display_window_get_max_rect() with server returning success response works. */ 749 PCUT_TEST(window_get_max_rect_success) 750 { 751 errno_t rc; 752 service_id_t sid; 753 display_t *disp = NULL; 754 display_wnd_params_t params; 755 display_window_t *wnd; 756 gfx_rect_t rect; 757 test_response_t resp; 758 759 async_set_fallback_port_handler(test_display_conn, &resp); 760 761 // FIXME This causes this test to be non-reentrant! 762 rc = loc_server_register(test_display_server); 763 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 764 765 rc = loc_service_register(test_display_svc, &sid); 766 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 767 768 rc = display_open(test_display_svc, &disp); 769 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 770 PCUT_ASSERT_NOT_NULL(disp); 771 772 resp.rc = EOK; 773 display_wnd_params_init(¶ms); 774 params.rect.p0.x = 0; 775 params.rect.p0.y = 0; 776 params.rect.p0.x = 100; 777 params.rect.p0.y = 100; 778 779 rc = display_window_create(disp, ¶ms, &test_display_wnd_cb, 780 (void *) &resp, &wnd); 781 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 782 PCUT_ASSERT_NOT_NULL(wnd); 783 784 resp.rc = EOK; 785 resp.window_get_max_rect_called = false; 786 resp.get_max_rect_rrect.p0.x = 11; 787 resp.get_max_rect_rrect.p0.y = 12; 788 resp.get_max_rect_rrect.p1.x = 13; 789 resp.get_max_rect_rrect.p1.y = 14; 790 791 rect.p0.x = 0; 792 rect.p0.y = 0; 793 rect.p1.x = 0; 794 rect.p1.y = 0; 795 796 rc = display_window_get_max_rect(wnd, &rect); 797 PCUT_ASSERT_TRUE(resp.window_get_max_rect_called); 798 PCUT_ASSERT_ERRNO_VAL(resp.rc, rc); 799 PCUT_ASSERT_INT_EQUALS(wnd->id, resp.get_max_rect_wnd_id); 800 PCUT_ASSERT_INT_EQUALS(resp.get_max_rect_rrect.p0.x, rect.p0.x); 801 PCUT_ASSERT_INT_EQUALS(resp.get_max_rect_rrect.p0.y, rect.p0.y); 802 PCUT_ASSERT_INT_EQUALS(resp.get_max_rect_rrect.p1.x, rect.p1.x); 803 PCUT_ASSERT_INT_EQUALS(resp.get_max_rect_rrect.p1.y, rect.p1.y); 804 805 display_window_destroy(wnd); 806 display_close(disp); 807 rc = loc_service_unregister(sid); 808 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 809 } 810 676 811 /** display_window_resize_req() with server returning error response works. */ 677 812 PCUT_TEST(window_resize_req_failure) … … 908 1043 PCUT_ASSERT_INT_EQUALS(nrect.p1.x, resp.resize_nbound.p1.x); 909 1044 PCUT_ASSERT_INT_EQUALS(nrect.p1.y, resp.resize_nbound.p1.y); 1045 1046 display_window_destroy(wnd); 1047 display_close(disp); 1048 rc = loc_service_unregister(sid); 1049 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 1050 } 1051 1052 /** display_window_maximize() with server returning error response works. */ 1053 PCUT_TEST(window_maximize_failure) 1054 { 1055 errno_t rc; 1056 service_id_t sid; 1057 display_t *disp = NULL; 1058 display_wnd_params_t params; 1059 display_window_t *wnd; 1060 test_response_t resp; 1061 1062 async_set_fallback_port_handler(test_display_conn, &resp); 1063 1064 // FIXME This causes this test to be non-reentrant! 1065 rc = loc_server_register(test_display_server); 1066 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 1067 1068 rc = loc_service_register(test_display_svc, &sid); 1069 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 1070 1071 rc = display_open(test_display_svc, &disp); 1072 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 1073 PCUT_ASSERT_NOT_NULL(disp); 1074 1075 resp.rc = EOK; 1076 display_wnd_params_init(¶ms); 1077 params.rect.p0.x = 0; 1078 params.rect.p0.y = 0; 1079 params.rect.p0.x = 100; 1080 params.rect.p0.y = 100; 1081 1082 rc = display_window_create(disp, ¶ms, &test_display_wnd_cb, 1083 (void *) &resp, &wnd); 1084 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 1085 PCUT_ASSERT_NOT_NULL(wnd); 1086 1087 resp.rc = EIO; 1088 resp.window_maximize_called = false; 1089 1090 rc = display_window_maximize(wnd); 1091 PCUT_ASSERT_TRUE(resp.window_maximize_called); 1092 PCUT_ASSERT_ERRNO_VAL(resp.rc, rc); 1093 1094 display_window_destroy(wnd); 1095 display_close(disp); 1096 rc = loc_service_unregister(sid); 1097 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 1098 } 1099 1100 /** display_window_maximize() with server returning success response works. */ 1101 PCUT_TEST(window_maximize_success) 1102 { 1103 errno_t rc; 1104 service_id_t sid; 1105 display_t *disp = NULL; 1106 display_wnd_params_t params; 1107 display_window_t *wnd; 1108 test_response_t resp; 1109 1110 async_set_fallback_port_handler(test_display_conn, &resp); 1111 1112 // FIXME This causes this test to be non-reentrant! 1113 rc = loc_server_register(test_display_server); 1114 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 1115 1116 rc = loc_service_register(test_display_svc, &sid); 1117 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 1118 1119 rc = display_open(test_display_svc, &disp); 1120 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 1121 PCUT_ASSERT_NOT_NULL(disp); 1122 1123 resp.rc = EOK; 1124 display_wnd_params_init(¶ms); 1125 params.rect.p0.x = 0; 1126 params.rect.p0.y = 0; 1127 params.rect.p0.x = 100; 1128 params.rect.p0.y = 100; 1129 1130 rc = display_window_create(disp, ¶ms, &test_display_wnd_cb, 1131 (void *) &resp, &wnd); 1132 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 1133 PCUT_ASSERT_NOT_NULL(wnd); 1134 1135 resp.rc = EOK; 1136 resp.window_maximize_called = false; 1137 1138 rc = display_window_maximize(wnd); 1139 PCUT_ASSERT_TRUE(resp.window_maximize_called); 1140 PCUT_ASSERT_ERRNO_VAL(resp.rc, rc); 910 1141 911 1142 display_window_destroy(wnd); … … 1719 1950 } 1720 1951 1952 static errno_t test_window_get_max_rect(void *arg, sysarg_t wnd_id, 1953 gfx_rect_t *rect) 1954 { 1955 test_response_t *resp = (test_response_t *) arg; 1956 1957 resp->window_get_max_rect_called = true; 1958 resp->get_max_rect_wnd_id = wnd_id; 1959 1960 if (resp->rc == EOK) 1961 *rect = resp->get_max_rect_rrect; 1962 1963 return resp->rc; 1964 } 1965 1721 1966 static errno_t test_window_resize_req(void *arg, sysarg_t wnd_id, 1722 1967 display_wnd_rsztype_t rsztype, gfx_coord2_t *pos) … … 1740 1985 resp->resize_offs = *offs; 1741 1986 resp->resize_nbound = *nrect; 1987 return resp->rc; 1988 } 1989 1990 static errno_t test_window_maximize(void *arg, sysarg_t wnd_id) 1991 { 1992 test_response_t *resp = (test_response_t *) arg; 1993 1994 resp->window_maximize_called = true; 1995 resp->resize_wnd_id = wnd_id; 1996 return resp->rc; 1997 } 1998 1999 static errno_t test_window_unmaximize(void *arg, sysarg_t wnd_id) 2000 { 2001 test_response_t *resp = (test_response_t *) arg; 2002 2003 resp->window_unmaximize_called = true; 2004 resp->resize_wnd_id = wnd_id; 1742 2005 return resp->rc; 1743 2006 }
Note:
See TracChangeset
for help on using the changeset viewer.