Changeset aeb3037 in mainline
- Timestamp:
- 2020-03-18T17:27:18Z (5 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 0680854
- Parents:
- 1a1271d
- git-author:
- Jiri Svoboda <jiri@…> (2020-03-18 16:57:15)
- git-committer:
- Jiri Svoboda <jiri@…> (2020-03-18 17:27:18)
- Location:
- uspace
- Files:
-
- 2 added
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/display/include/disp_srv.h
r1a1271d raeb3037 41 41 #include "display/wndparams.h" 42 42 #include "types/display/event.h" 43 #include "types/display/info.h" 43 44 #include "types/display/wndresize.h" 44 45 … … 60 61 errno_t (*window_resize)(void *, sysarg_t, gfx_coord2_t *, gfx_rect_t *); 61 62 errno_t (*get_event)(void *, sysarg_t *, display_wnd_ev_t *); 63 errno_t (*get_info)(void *, display_info_t *); 62 64 }; 63 65 -
uspace/lib/display/include/display.h
r1a1271d raeb3037 43 43 #include "display/wndresize.h" 44 44 #include "types/display.h" 45 #include "types/display/info.h" 45 46 46 47 extern errno_t display_open(const char *, display_t **); 47 48 extern void display_close(display_t *); 49 extern errno_t display_get_info(display_t *, display_info_t *); 50 48 51 extern errno_t display_window_create(display_t *, display_wnd_params_t *, 49 52 display_wnd_cb_t *, void *, display_window_t **); -
uspace/lib/display/include/ipc/display.h
r1a1271d raeb3037 45 45 DISPLAY_WINDOW_RESIZE, 46 46 DISPLAY_WINDOW_RESIZE_REQ, 47 DISPLAY_GET_EVENT 47 DISPLAY_GET_EVENT, 48 DISPLAY_GET_INFO 48 49 } display_request_t; 49 50 -
uspace/lib/display/src/disp_srv.c
r1a1271d raeb3037 37 37 #include <disp_srv.h> 38 38 #include <display/event.h> 39 #include <display/info.h> 39 40 #include <display/wndresize.h> 40 41 #include <errno.h> … … 268 269 } 269 270 271 static void display_get_info_srv(display_srv_t *srv, ipc_call_t *icall) 272 { 273 display_info_t info; 274 ipc_call_t call; 275 size_t size; 276 errno_t rc; 277 278 if (srv->ops->get_info == NULL) { 279 async_answer_0(icall, ENOTSUP); 280 return; 281 } 282 283 /* Transfer information */ 284 if (!async_data_read_receive(&call, &size)) { 285 async_answer_0(icall, EREFUSED); 286 return; 287 } 288 289 if (size != sizeof(info)) { 290 async_answer_0(icall, EREFUSED); 291 async_answer_0(&call, EREFUSED); 292 return; 293 } 294 295 rc = srv->ops->get_info(srv->arg, &info); 296 if (rc != EOK) { 297 async_answer_0(icall, rc); 298 async_answer_0(&call, rc); 299 return; 300 } 301 302 rc = async_data_read_finalize(&call, &info, sizeof(info)); 303 if (rc != EOK) { 304 async_answer_0(icall, rc); 305 async_answer_0(&call, rc); 306 return; 307 } 308 309 async_answer_0(icall, EOK); 310 } 311 270 312 void display_conn(ipc_call_t *icall, display_srv_t *srv) 271 313 { … … 306 348 case DISPLAY_GET_EVENT: 307 349 display_get_event_srv(srv, &call); 350 break; 351 case DISPLAY_GET_INFO: 352 display_get_info_srv(srv, &call); 308 353 break; 309 354 default: -
uspace/lib/display/src/display.c
r1a1271d raeb3037 385 385 * 386 386 * @param display Display 387 * @param rwindow Place to store pointe to window that received event387 * @param rwindow Place to store pointer to window that received event 388 388 * @param event Place to store event 389 389 * @return EOK on success or an error code … … 418 418 419 419 *rwindow = window; 420 return EOK; 421 } 422 423 /** Get display information. 424 * 425 * @param display Display 426 * @param info Place to store display information 427 * @return EOK on success or an error code 428 */ 429 errno_t display_get_info(display_t *display, display_info_t *info) 430 { 431 async_exch_t *exch; 432 ipc_call_t answer; 433 aid_t req; 434 errno_t rc; 435 436 exch = async_exchange_begin(display->sess); 437 req = async_send_0(exch, DISPLAY_GET_INFO, &answer); 438 rc = async_data_read_start(exch, info, sizeof(*info)); 439 async_exchange_end(exch); 440 if (rc != EOK) { 441 async_forget(req); 442 return rc; 443 } 444 445 async_wait_for(req, &rc); 446 if (rc != EOK) 447 return rc; 448 420 449 return EOK; 421 450 } -
uspace/lib/display/test/display.c
r1a1271d raeb3037 62 62 gfx_rect_t *); 63 63 static errno_t test_get_event(void *, sysarg_t *, display_wnd_ev_t *); 64 static errno_t test_get_info(void *, display_info_t *); 64 65 65 66 static errno_t test_gc_set_color(void *, gfx_color_t *); … … 71 72 .window_resize_req = test_window_resize_req, 72 73 .window_resize = test_window_resize, 73 .get_event = test_get_event 74 .get_event = test_get_event, 75 .get_info = test_get_info 74 76 }; 75 77 … … 116 118 117 119 bool get_event_called; 120 121 bool get_info_called; 122 gfx_rect_t get_info_rect; 123 118 124 bool set_color_called; 119 125 bool close_event_called; … … 831 837 832 838 /* Verify that the event was delivered correctly */ 833 PCUT_ASSERT_ EQUALS(resp.event.etype,839 PCUT_ASSERT_INT_EQUALS(resp.event.etype, 834 840 resp.revent.etype); 835 841 … … 896 902 897 903 /* Verify that the event was delivered correctly */ 898 PCUT_ASSERT_ EQUALS(resp.event.etype,904 PCUT_ASSERT_INT_EQUALS(resp.event.etype, 899 905 resp.revent.etype); 900 906 … … 965 971 966 972 /* Verify that the event was delivered correctly */ 967 PCUT_ASSERT_ EQUALS(resp.event.etype,973 PCUT_ASSERT_INT_EQUALS(resp.event.etype, 968 974 resp.revent.etype); 969 PCUT_ASSERT_ EQUALS(resp.event.ev.kbd.type,975 PCUT_ASSERT_INT_EQUALS(resp.event.ev.kbd.type, 970 976 resp.revent.ev.kbd.type); 971 PCUT_ASSERT_ EQUALS(resp.event.ev.kbd.key,977 PCUT_ASSERT_INT_EQUALS(resp.event.ev.kbd.key, 972 978 resp.revent.ev.kbd.key); 973 PCUT_ASSERT_ EQUALS(resp.event.ev.kbd.mods,979 PCUT_ASSERT_INT_EQUALS(resp.event.ev.kbd.mods, 974 980 resp.revent.ev.kbd.mods); 975 PCUT_ASSERT_ EQUALS(resp.event.ev.kbd.c,981 PCUT_ASSERT_INT_EQUALS(resp.event.ev.kbd.c, 976 982 resp.revent.ev.kbd.c); 977 983 … … 1042 1048 1043 1049 /* Verify that the event was delivered correctly */ 1044 PCUT_ASSERT_ EQUALS(resp.event.etype,1050 PCUT_ASSERT_INT_EQUALS(resp.event.etype, 1045 1051 resp.revent.etype); 1046 PCUT_ASSERT_ EQUALS(resp.event.ev.pos.type,1052 PCUT_ASSERT_INT_EQUALS(resp.event.ev.pos.type, 1047 1053 resp.revent.ev.pos.type); 1048 PCUT_ASSERT_ EQUALS(resp.event.ev.pos.btn_num,1054 PCUT_ASSERT_INT_EQUALS(resp.event.ev.pos.btn_num, 1049 1055 resp.revent.ev.pos.btn_num); 1050 PCUT_ASSERT_ EQUALS(resp.event.ev.pos.hpos,1056 PCUT_ASSERT_INT_EQUALS(resp.event.ev.pos.hpos, 1051 1057 resp.revent.ev.pos.hpos); 1052 PCUT_ASSERT_ EQUALS(resp.event.ev.pos.vpos,1058 PCUT_ASSERT_INT_EQUALS(resp.event.ev.pos.vpos, 1053 1059 resp.revent.ev.pos.vpos); 1054 1060 … … 1102 1108 resp.event.etype = wev_unfocus; 1103 1109 resp.wnd_id = wnd->id; 1104 resp. focus_event_called = false;1110 resp.unfocus_event_called = false; 1105 1111 fibril_mutex_initialize(&resp.event_lock); 1106 1112 fibril_condvar_initialize(&resp.event_cv); … … 1115 1121 1116 1122 /* Verify that the event was delivered correctly */ 1117 PCUT_ASSERT_ EQUALS(resp.event.etype,1123 PCUT_ASSERT_INT_EQUALS(resp.event.etype, 1118 1124 resp.revent.etype); 1119 1125 … … 1123 1129 display_close(disp); 1124 1130 1131 rc = loc_service_unregister(sid); 1132 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 1133 } 1134 1135 /** display_get_info() with server returning failure response works. */ 1136 PCUT_TEST(get_info_failure) 1137 { 1138 errno_t rc; 1139 service_id_t sid; 1140 display_t *disp = NULL; 1141 display_info_t info; 1142 test_response_t resp; 1143 1144 async_set_fallback_port_handler(test_display_conn, &resp); 1145 1146 // FIXME This causes this test to be non-reentrant! 1147 rc = loc_server_register(test_display_server); 1148 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 1149 1150 rc = loc_service_register(test_display_svc, &sid); 1151 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 1152 1153 rc = display_open(test_display_svc, &disp); 1154 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 1155 PCUT_ASSERT_NOT_NULL(disp); 1156 1157 resp.rc = ENOMEM; 1158 resp.get_info_called = false; 1159 1160 rc = display_get_info(disp, &info); 1161 PCUT_ASSERT_TRUE(resp.get_info_called); 1162 PCUT_ASSERT_ERRNO_VAL(resp.rc, rc); 1163 1164 display_close(disp); 1165 rc = loc_service_unregister(sid); 1166 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 1167 } 1168 1169 /** display_get_info() with server returning success response works. */ 1170 PCUT_TEST(get_info_success) 1171 { 1172 errno_t rc; 1173 service_id_t sid; 1174 display_t *disp = NULL; 1175 display_info_t info; 1176 test_response_t resp; 1177 1178 async_set_fallback_port_handler(test_display_conn, &resp); 1179 1180 // FIXME This causes this test to be non-reentrant! 1181 rc = loc_server_register(test_display_server); 1182 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 1183 1184 rc = loc_service_register(test_display_svc, &sid); 1185 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 1186 1187 rc = display_open(test_display_svc, &disp); 1188 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 1189 PCUT_ASSERT_NOT_NULL(disp); 1190 1191 resp.rc = EOK; 1192 resp.get_info_called = false; 1193 resp.get_info_rect.p0.x = 10; 1194 resp.get_info_rect.p0.y = 11; 1195 resp.get_info_rect.p1.x = 20; 1196 resp.get_info_rect.p1.y = 21; 1197 1198 rc = display_get_info(disp, &info); 1199 PCUT_ASSERT_TRUE(resp.get_info_called); 1200 PCUT_ASSERT_ERRNO_VAL(resp.rc, rc); 1201 PCUT_ASSERT_INT_EQUALS(resp.get_info_rect.p0.x, info.rect.p0.x); 1202 PCUT_ASSERT_INT_EQUALS(resp.get_info_rect.p0.y, info.rect.p0.y); 1203 PCUT_ASSERT_INT_EQUALS(resp.get_info_rect.p1.x, info.rect.p1.x); 1204 PCUT_ASSERT_INT_EQUALS(resp.get_info_rect.p1.y, info.rect.p1.y); 1205 1206 display_close(disp); 1125 1207 rc = loc_service_unregister(sid); 1126 1208 PCUT_ASSERT_ERRNO_VAL(EOK, rc); … … 1294 1376 } 1295 1377 1296 static errno_t test_get_event(void *arg, sysarg_t *wnd_id, display_wnd_ev_t *event) 1378 static errno_t test_get_event(void *arg, sysarg_t *wnd_id, 1379 display_wnd_ev_t *event) 1297 1380 { 1298 1381 test_response_t *resp = (test_response_t *) arg; … … 1309 1392 } 1310 1393 1394 static errno_t test_get_info(void *arg, display_info_t *info) 1395 { 1396 test_response_t *resp = (test_response_t *) arg; 1397 1398 resp->get_info_called = true; 1399 info->rect = resp->get_info_rect; 1400 1401 return resp->rc; 1402 } 1403 1311 1404 static errno_t test_gc_set_color(void *arg, gfx_color_t *color) 1312 1405 { -
uspace/srv/hid/display/display.c
r1a1271d raeb3037 84 84 gfx_color_delete(disp->bg_color); 85 85 free(disp); 86 } 87 88 /** Get display information. 89 * 90 * @param disp Display 91 */ 92 void ds_display_get_info(ds_display_t *disp, display_info_t *info) 93 { 94 info->rect = disp->rect; 86 95 } 87 96 -
uspace/srv/hid/display/display.h
r1a1271d raeb3037 37 37 #define DISPLAY_H 38 38 39 #include <display/info.h> 39 40 #include <errno.h> 40 41 #include <gfx/context.h> … … 49 50 extern errno_t ds_display_create(gfx_context_t *, ds_display_t **); 50 51 extern void ds_display_destroy(ds_display_t *); 52 extern void ds_display_get_info(ds_display_t *, display_info_t *); 51 53 extern void ds_display_add_client(ds_display_t *, ds_client_t *); 52 54 extern void ds_display_remove_client(ds_client_t *); -
uspace/srv/hid/display/dsops.c
r1a1271d raeb3037 52 52 gfx_rect_t *); 53 53 static errno_t disp_get_event(void *, sysarg_t *, display_wnd_ev_t *); 54 static errno_t disp_get_info(void *, display_info_t *); 54 55 55 56 display_ops_t display_srv_ops = { … … 59 60 .window_resize_req = disp_window_resize_req, 60 61 .window_resize = disp_window_resize, 61 .get_event = disp_get_event 62 .get_event = disp_get_event, 63 .get_info = disp_get_info 62 64 }; 63 65 … … 168 170 } 169 171 172 static errno_t disp_get_info(void *arg, display_info_t *info) 173 { 174 ds_client_t *client = (ds_client_t *) arg; 175 176 log_msg(LOG_DEFAULT, LVL_DEBUG, "disp_get_info()"); 177 178 ds_display_get_info(client->display, info); 179 return EOK; 180 } 181 170 182 /** @} 171 183 */
Note:
See TracChangeset
for help on using the changeset viewer.