Changeset 5480d5e in mainline
- Timestamp:
- 2020-05-19T21:51:11Z (5 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 9242ad9
- Parents:
- 4c4d6142
- Location:
- uspace/lib/display
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/display/include/disp_srv.h
r4c4d6142 r5480d5e 40 40 #include <gfx/coord.h> 41 41 #include "display/wndparams.h" 42 #include "types/display/cursor.h" 42 43 #include "types/display/event.h" 43 44 #include "types/display/info.h" … … 61 62 errno_t (*window_move)(void *, sysarg_t, gfx_coord2_t *); 62 63 errno_t (*window_resize)(void *, sysarg_t, gfx_coord2_t *, gfx_rect_t *); 64 errno_t (*window_set_cursor)(void *, sysarg_t, display_stock_cursor_t); 63 65 errno_t (*get_event)(void *, sysarg_t *, display_wnd_ev_t *); 64 66 errno_t (*get_info)(void *, display_info_t *); -
uspace/lib/display/include/display.h
r4c4d6142 r5480d5e 43 43 #include "display/wndresize.h" 44 44 #include "types/display.h" 45 #include "types/display/cursor.h" 45 46 #include "types/display/info.h" 46 47 … … 59 60 extern errno_t display_window_resize(display_window_t *, 60 61 gfx_coord2_t *, gfx_rect_t *); 62 extern errno_t display_window_set_cursor(display_window_t *, 63 display_stock_cursor_t); 61 64 62 65 #endif -
uspace/lib/display/include/ipc/display.h
r4c4d6142 r5480d5e 46 46 DISPLAY_WINDOW_RESIZE, 47 47 DISPLAY_WINDOW_RESIZE_REQ, 48 DISPLAY_WINDOW_SET_CURSOR, 48 49 DISPLAY_GET_EVENT, 49 50 DISPLAY_GET_INFO -
uspace/lib/display/src/disp_srv.c
r4c4d6142 r5480d5e 266 266 } 267 267 268 static void display_window_set_cursor_srv(display_srv_t *srv, ipc_call_t *icall) 269 { 270 sysarg_t wnd_id; 271 display_stock_cursor_t cursor; 272 errno_t rc; 273 274 wnd_id = ipc_get_arg1(icall); 275 cursor = ipc_get_arg2(icall); 276 277 if (srv->ops->window_set_cursor == NULL) { 278 async_answer_0(icall, ENOTSUP); 279 return; 280 } 281 282 rc = srv->ops->window_set_cursor(srv->arg, wnd_id, cursor); 283 async_answer_0(icall, rc); 284 } 285 268 286 static void display_get_event_srv(display_srv_t *srv, ipc_call_t *icall) 269 287 { … … 386 404 case DISPLAY_WINDOW_RESIZE: 387 405 display_window_resize_srv(srv, &call); 406 break; 407 case DISPLAY_WINDOW_SET_CURSOR: 408 display_window_set_cursor_srv(srv, &call); 388 409 break; 389 410 case DISPLAY_GET_EVENT: -
uspace/lib/display/src/display.c
r4c4d6142 r5480d5e 416 416 } 417 417 418 /** Set window cursor. 419 * 420 * Set cursor that is displayed when pointer is over the window. The default 421 * is the arrow pointer. 422 * 423 * @param window Window 424 * @param cursor Cursor to display 425 * @return EOK on success or an error code 426 */ 427 errno_t display_window_set_cursor(display_window_t *window, 428 display_stock_cursor_t cursor) 429 { 430 async_exch_t *exch; 431 errno_t rc; 432 433 exch = async_exchange_begin(window->display->sess); 434 rc = async_req_2_0(exch, DISPLAY_WINDOW_SET_CURSOR, window->id, 435 cursor); 436 async_exchange_end(exch); 437 return rc; 438 } 439 418 440 /** Get display event. 419 441 * -
uspace/lib/display/test/display.c
r4c4d6142 r5480d5e 62 62 static errno_t test_window_resize(void *, sysarg_t, gfx_coord2_t *, 63 63 gfx_rect_t *); 64 static errno_t test_window_set_cursor(void *, sysarg_t, display_stock_cursor_t); 64 65 static errno_t test_get_event(void *, sysarg_t *, display_wnd_ev_t *); 65 66 static errno_t test_get_info(void *, display_info_t *); … … 74 75 .window_resize_req = test_window_resize_req, 75 76 .window_resize = test_window_resize, 77 .window_set_cursor = test_window_set_cursor, 76 78 .get_event = test_get_event, 77 79 .get_info = test_get_info … … 122 124 gfx_rect_t resize_nbound; 123 125 sysarg_t resize_wnd_id; 126 127 bool window_set_cursor_called; 128 sysarg_t set_cursor_wnd_id; 129 display_stock_cursor_t set_cursor_cursor; 124 130 125 131 bool get_event_called; … … 777 783 PCUT_ASSERT_INT_EQUALS(nrect.p1.x, resp.resize_nbound.p1.x); 778 784 PCUT_ASSERT_INT_EQUALS(nrect.p1.y, resp.resize_nbound.p1.y); 785 786 display_window_destroy(wnd); 787 display_close(disp); 788 rc = loc_service_unregister(sid); 789 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 790 } 791 792 /** display_window_set_cursor() with server returning error response works. */ 793 PCUT_TEST(window_set_cursor_failure) 794 { 795 errno_t rc; 796 service_id_t sid; 797 display_t *disp = NULL; 798 display_wnd_params_t params; 799 display_window_t *wnd; 800 test_response_t resp; 801 802 async_set_fallback_port_handler(test_display_conn, &resp); 803 804 // FIXME This causes this test to be non-reentrant! 805 rc = loc_server_register(test_display_server); 806 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 807 808 rc = loc_service_register(test_display_svc, &sid); 809 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 810 811 rc = display_open(test_display_svc, &disp); 812 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 813 PCUT_ASSERT_NOT_NULL(disp); 814 815 resp.rc = EOK; 816 display_wnd_params_init(¶ms); 817 params.rect.p0.x = 0; 818 params.rect.p0.y = 0; 819 params.rect.p0.x = 100; 820 params.rect.p0.y = 100; 821 822 rc = display_window_create(disp, ¶ms, &test_display_wnd_cb, 823 (void *) &resp, &wnd); 824 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 825 PCUT_ASSERT_NOT_NULL(wnd); 826 827 resp.rc = EIO; 828 resp.window_set_cursor_called = false; 829 830 rc = display_window_set_cursor(wnd, dcurs_size_ud); 831 PCUT_ASSERT_INT_EQUALS(wnd->id, resp.set_cursor_wnd_id); 832 PCUT_ASSERT_TRUE(resp.window_set_cursor_called); 833 PCUT_ASSERT_ERRNO_VAL(resp.rc, rc); 834 PCUT_ASSERT_INT_EQUALS(dcurs_size_ud, resp.set_cursor_cursor); 835 836 display_window_destroy(wnd); 837 display_close(disp); 838 rc = loc_service_unregister(sid); 839 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 840 } 841 842 /** display_window_set_cursor() with server returning success response works. */ 843 PCUT_TEST(window_set_cursor_success) 844 { 845 errno_t rc; 846 service_id_t sid; 847 display_t *disp = NULL; 848 display_wnd_params_t params; 849 display_window_t *wnd; 850 test_response_t resp; 851 852 async_set_fallback_port_handler(test_display_conn, &resp); 853 854 // FIXME This causes this test to be non-reentrant! 855 rc = loc_server_register(test_display_server); 856 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 857 858 rc = loc_service_register(test_display_svc, &sid); 859 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 860 861 rc = display_open(test_display_svc, &disp); 862 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 863 PCUT_ASSERT_NOT_NULL(disp); 864 865 resp.rc = EOK; 866 display_wnd_params_init(¶ms); 867 params.rect.p0.x = 0; 868 params.rect.p0.y = 0; 869 params.rect.p0.x = 100; 870 params.rect.p0.y = 100; 871 872 rc = display_window_create(disp, ¶ms, &test_display_wnd_cb, 873 (void *) &resp, &wnd); 874 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 875 PCUT_ASSERT_NOT_NULL(wnd); 876 877 resp.rc = EOK; 878 resp.window_set_cursor_called = false; 879 880 rc = display_window_set_cursor(wnd, dcurs_size_ud); 881 PCUT_ASSERT_INT_EQUALS(wnd->id, resp.set_cursor_wnd_id); 882 PCUT_ASSERT_TRUE(resp.window_set_cursor_called); 883 PCUT_ASSERT_ERRNO_VAL(resp.rc, EOK); 884 PCUT_ASSERT_INT_EQUALS(dcurs_size_ud, resp.set_cursor_cursor); 779 885 780 886 display_window_destroy(wnd); … … 1500 1606 } 1501 1607 1608 static errno_t test_window_set_cursor(void *arg, sysarg_t wnd_id, 1609 display_stock_cursor_t cursor) 1610 { 1611 test_response_t *resp = (test_response_t *) arg; 1612 1613 resp->window_set_cursor_called = true; 1614 resp->set_cursor_wnd_id = wnd_id; 1615 resp->set_cursor_cursor = cursor; 1616 1617 return resp->rc; 1618 } 1619 1502 1620 static errno_t test_get_event(void *arg, sysarg_t *wnd_id, 1503 1621 display_wnd_ev_t *event)
Note:
See TracChangeset
for help on using the changeset viewer.