Changeset 7cc30e9 in mainline for uspace/srv/hid/display
- Timestamp:
- 2022-10-24T17:50:46Z (3 years ago)
- Branches:
- master, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 913add60
- Parents:
- 7a05d924
- Location:
- uspace/srv/hid/display
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/hid/display/dsops.c
r7a05d924 r7cc30e9 57 57 static errno_t disp_window_unmaximize(void *, sysarg_t); 58 58 static errno_t disp_window_set_cursor(void *, sysarg_t, display_stock_cursor_t); 59 static errno_t disp_window_set_caption(void *, sysarg_t, const char *); 59 60 static errno_t disp_get_event(void *, sysarg_t *, display_wnd_ev_t *); 60 61 static errno_t disp_get_info(void *, display_info_t *); … … 72 73 .window_unmaximize = disp_window_unmaximize, 73 74 .window_set_cursor = disp_window_set_cursor, 75 .window_set_caption = disp_window_set_caption, 74 76 .get_event = disp_get_event, 75 77 .get_info = disp_get_info … … 306 308 } 307 309 310 static errno_t disp_window_set_caption(void *arg, sysarg_t wnd_id, 311 const char *caption) 312 { 313 ds_client_t *client = (ds_client_t *) arg; 314 ds_window_t *wnd; 315 errno_t rc; 316 317 ds_display_lock(client->display); 318 319 wnd = ds_client_find_window(client, wnd_id); 320 if (wnd == NULL) { 321 ds_display_unlock(client->display); 322 return ENOENT; 323 } 324 325 log_msg(LOG_DEFAULT, LVL_DEBUG, "disp_window_set_caption()"); 326 rc = ds_window_set_caption(wnd, caption); 327 ds_display_unlock(client->display); 328 return rc; 329 } 330 308 331 static errno_t disp_get_event(void *arg, sysarg_t *wnd_id, 309 332 display_wnd_ev_t *event) -
uspace/srv/hid/display/test/window.c
r7a05d924 r7cc30e9 851 851 } 852 852 853 /** Test ds_window_set_caption() */ 854 PCUT_TEST(window_set_caption) 855 { 856 gfx_context_t *gc; 857 ds_display_t *disp; 858 ds_client_t *client; 859 ds_seat_t *seat; 860 ds_window_t *wnd; 861 display_wnd_params_t params; 862 errno_t rc; 863 864 rc = gfx_context_new(&dummy_ops, NULL, &gc); 865 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 866 867 rc = ds_display_create(gc, df_none, &disp); 868 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 869 870 rc = ds_client_create(disp, NULL, NULL, &client); 871 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 872 873 rc = ds_seat_create(disp, &seat); 874 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 875 876 display_wnd_params_init(¶ms); 877 params.rect.p0.x = params.rect.p0.y = 0; 878 params.rect.p1.x = params.rect.p1.y = 1; 879 880 rc = ds_window_create(client, ¶ms, &wnd); 881 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 882 883 PCUT_ASSERT_EQUALS(wnd->display->cursor[dcurs_arrow], wnd->cursor); 884 885 rc = ds_window_set_caption(wnd, "Hello"); 886 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 887 PCUT_ASSERT_INT_EQUALS(0, str_cmp("Hello", wnd->caption)); 888 889 ds_window_destroy(wnd); 890 ds_seat_destroy(seat); 891 ds_client_destroy(client); 892 ds_display_destroy(disp); 893 } 894 853 895 static errno_t dummy_set_color(void *arg, gfx_color_t *color) 854 896 { -
uspace/srv/hid/display/types/display/window.h
r7a05d924 r7cc30e9 105 105 /** Window resize type (if state is dsw_resizing) */ 106 106 display_wnd_rsztype_t rsztype; 107 /** Window caption */ 108 char *caption; 107 109 } ds_window_t; 108 110 -
uspace/srv/hid/display/window.c
r7a05d924 r7cc30e9 44 44 #include <memgfx/memgc.h> 45 45 #include <stdlib.h> 46 #include <str.h> 46 47 #include "client.h" 47 48 #include "display.h" … … 81 82 wnd = calloc(1, sizeof(ds_window_t)); 82 83 if (wnd == NULL) { 84 rc = ENOMEM; 85 goto error; 86 } 87 88 wnd->caption = str_dup(params->caption); 89 if (wnd->caption == NULL) { 83 90 rc = ENOMEM; 84 91 goto error; … … 152 159 if (wnd->bitmap != NULL) 153 160 gfx_bitmap_destroy(wnd->bitmap); 161 if (wnd->caption != NULL) 162 free(wnd->caption); 154 163 free(wnd); 155 164 } … … 176 185 gfx_bitmap_destroy(wnd->bitmap); 177 186 187 free(wnd->caption); 178 188 free(wnd); 179 189 … … 902 912 * 903 913 * @param wnd Window 914 * @param cursor New cursor 904 915 * @return EOK on success, EINVAL if @a cursor is invalid 905 916 */ … … 915 926 } 916 927 928 /** Set window caption. 929 * 930 * @param wnd Window 931 * @param caption New caption 932 * 933 * @return EOK on success, EINVAL if @a cursor is invalid 934 */ 935 errno_t ds_window_set_caption(ds_window_t *wnd, const char *caption) 936 { 937 char *dcaption; 938 939 dcaption = str_dup(caption); 940 if (dcaption == NULL) 941 return ENOMEM; 942 943 free(wnd->caption); 944 wnd->caption = dcaption; 945 946 return EOK; 947 } 948 917 949 /** Window memory GC invalidate callback. 918 950 * -
uspace/srv/hid/display/window.h
r7a05d924 r7cc30e9 73 73 gfx_rect_t *); 74 74 extern errno_t ds_window_set_cursor(ds_window_t *, display_stock_cursor_t); 75 extern errno_t ds_window_set_caption(ds_window_t *, const char *); 75 76 76 77 #endif -
uspace/srv/hid/display/wmops.c
r7a05d924 r7cc30e9 98 98 wndmgt_window_info_t **rinfo) 99 99 { 100 101 /* ds_client_t *client = (ds_client_t *) arg; 100 ds_display_t *disp = (ds_display_t *)arg; 102 101 ds_window_t *wnd; 103 104 ds_display_lock(client->display);105 106 wnd = ds_client_find_window(client, wnd_id);107 if (wnd == NULL) {108 ds_display_unlock(client->display);109 return ENOENT;110 }111 112 log_msg(LOG_DEFAULT, LVL_DEBUG, "disp_window_get_pos()");113 ds_window_get_pos(wnd, pos);114 ds_display_unlock(client->display);115 return EOK;*/116 102 wndmgt_window_info_t *info; 117 103 118 104 log_msg(LOG_DEFAULT, LVL_DEBUG, "dispwm_get_window_info()"); 105 106 wnd = ds_display_find_window(disp, wnd_id); 107 if (wnd == NULL) 108 return ENOENT; 119 109 120 110 info = calloc(1, sizeof(wndmgt_window_info_t)); … … 122 112 return ENOMEM; 123 113 124 info->caption = str_dup( "Hello");114 info->caption = str_dup(wnd->caption); 125 115 if (info->caption == NULL) { 126 116 free(info);
Note:
See TracChangeset
for help on using the changeset viewer.