Changeset b0a94854 in mainline for uspace/srv
- Timestamp:
- 2020-02-19T13:28:34Z (6 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 0a052b0
- Parents:
- e1f2079
- git-author:
- Jiri Svoboda <jiri@…> (2020-01-18 18:28:21)
- git-committer:
- Jiri Svoboda <jiri@…> (2020-02-19 13:28:34)
- Location:
- uspace/srv/hid/display
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/hid/display/client.c
re1f2079 rb0a94854 203 203 } 204 204 205 /** Post focus event to the client's message queue. 206 * 207 * @param client Client 208 * @param ewindow Window that the message is targetted to 209 * 210 * @return EOK on success or an error code 211 */ 212 errno_t ds_client_post_focus_event(ds_client_t *client, ds_window_t *ewindow) 213 { 214 ds_window_ev_t *wevent; 215 216 wevent = calloc(1, sizeof(ds_window_ev_t)); 217 if (wevent == NULL) 218 return ENOMEM; 219 220 wevent->window = ewindow; 221 wevent->event.etype = wev_focus; 222 list_append(&wevent->levents, &client->events); 223 224 /* Notify the client */ 225 // TODO Do not send more than once until client drains the queue 226 if (client->cb != NULL && client->cb->ev_pending != NULL) 227 client->cb->ev_pending(client->cb_arg); 228 229 return EOK; 230 } 231 205 232 /** Post keyboard event to the client's message queue. 206 233 * … … 262 289 } 263 290 291 /** Post unfocus event to the client's message queue. 292 * 293 * @param client Client 294 * @param ewindow Window that the message is targetted to 295 * 296 * @return EOK on success or an error code 297 */ 298 errno_t ds_client_post_unfocus_event(ds_client_t *client, ds_window_t *ewindow) 299 { 300 ds_window_ev_t *wevent; 301 302 wevent = calloc(1, sizeof(ds_window_ev_t)); 303 if (wevent == NULL) 304 return ENOMEM; 305 306 wevent->window = ewindow; 307 wevent->event.etype = wev_unfocus; 308 list_append(&wevent->levents, &client->events); 309 310 /* Notify the client */ 311 // TODO Do not send more than once until client drains the queue 312 if (client->cb != NULL && client->cb->ev_pending != NULL) 313 client->cb->ev_pending(client->cb_arg); 314 315 return EOK; 316 } 317 264 318 /** @} 265 319 */ -
uspace/srv/hid/display/client.h
re1f2079 rb0a94854 53 53 extern errno_t ds_client_get_event(ds_client_t *, ds_window_t **, 54 54 display_wnd_ev_t *); 55 extern errno_t ds_client_post_focus_event(ds_client_t *, ds_window_t *); 55 56 extern errno_t ds_client_post_kbd_event(ds_client_t *, ds_window_t *, 56 57 kbd_event_t *); 57 58 extern errno_t ds_client_post_pos_event(ds_client_t *, ds_window_t *, 58 59 pos_event_t *); 60 extern errno_t ds_client_post_unfocus_event(ds_client_t *, ds_window_t *); 59 61 60 62 #endif -
uspace/srv/hid/display/seat.c
re1f2079 rb0a94854 83 83 void ds_seat_set_focus(ds_seat_t *seat, ds_window_t *wnd) 84 84 { 85 if (seat->focus != NULL) 86 ds_window_post_unfocus_event(seat->focus); 87 85 88 seat->focus = wnd; 89 90 if (wnd != NULL) 91 ds_window_post_focus_event(wnd); 86 92 } 87 93 -
uspace/srv/hid/display/test/client.c
re1f2079 rb0a94854 163 163 } 164 164 165 /** Test ds_client_get_event(), ds_client_post_focus_event(). */ 166 PCUT_TEST(client_get_post_focus_event) 167 { 168 ds_display_t *disp; 169 ds_client_t *client; 170 ds_window_t *wnd; 171 display_wnd_params_t params; 172 ds_window_t *rwindow; 173 display_wnd_ev_t revent; 174 bool called_cb = NULL; 175 errno_t rc; 176 177 rc = ds_display_create(NULL, &disp); 178 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 179 180 rc = ds_client_create(disp, &test_ds_client_cb, &called_cb, &client); 181 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 182 183 display_wnd_params_init(¶ms); 184 params.rect.p0.x = params.rect.p0.y = 0; 185 params.rect.p1.x = params.rect.p1.y = 1; 186 187 rc = ds_window_create(client, ¶ms, &wnd); 188 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 189 190 PCUT_ASSERT_FALSE(called_cb); 191 192 rc = ds_client_get_event(client, &rwindow, &revent); 193 PCUT_ASSERT_ERRNO_VAL(ENOENT, rc); 194 195 rc = ds_client_post_focus_event(client, wnd); 196 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 197 PCUT_ASSERT_TRUE(called_cb); 198 199 rc = ds_client_get_event(client, &rwindow, &revent); 200 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 201 PCUT_ASSERT_EQUALS(wnd, rwindow); 202 PCUT_ASSERT_EQUALS(wev_focus, revent.etype); 203 204 rc = ds_client_get_event(client, &rwindow, &revent); 205 PCUT_ASSERT_ERRNO_VAL(ENOENT, rc); 206 207 ds_window_destroy(wnd); 208 ds_client_destroy(client); 209 ds_display_destroy(disp); 210 } 211 165 212 /** Test ds_client_get_event(), ds_client_post_kbd_event(). */ 166 213 PCUT_TEST(client_get_post_kbd_event) … … 275 322 } 276 323 324 /** Test ds_client_get_event(), ds_client_post_unfocus_event(). */ 325 PCUT_TEST(client_get_post_unfocus_event) 326 { 327 ds_display_t *disp; 328 ds_client_t *client; 329 ds_window_t *wnd; 330 display_wnd_params_t params; 331 ds_window_t *rwindow; 332 display_wnd_ev_t revent; 333 bool called_cb = NULL; 334 errno_t rc; 335 336 rc = ds_display_create(NULL, &disp); 337 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 338 339 rc = ds_client_create(disp, &test_ds_client_cb, &called_cb, &client); 340 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 341 342 display_wnd_params_init(¶ms); 343 params.rect.p0.x = params.rect.p0.y = 0; 344 params.rect.p1.x = params.rect.p1.y = 1; 345 346 rc = ds_window_create(client, ¶ms, &wnd); 347 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 348 349 PCUT_ASSERT_FALSE(called_cb); 350 351 rc = ds_client_get_event(client, &rwindow, &revent); 352 PCUT_ASSERT_ERRNO_VAL(ENOENT, rc); 353 354 rc = ds_client_post_unfocus_event(client, wnd); 355 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 356 PCUT_ASSERT_TRUE(called_cb); 357 358 rc = ds_client_get_event(client, &rwindow, &revent); 359 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 360 PCUT_ASSERT_EQUALS(wnd, rwindow); 361 PCUT_ASSERT_EQUALS(wev_unfocus, revent.etype); 362 363 rc = ds_client_get_event(client, &rwindow, &revent); 364 PCUT_ASSERT_ERRNO_VAL(ENOENT, rc); 365 366 ds_window_destroy(wnd); 367 ds_client_destroy(client); 368 ds_display_destroy(disp); 369 } 370 277 371 /** Test client being destroyed while still having a window. 278 372 * -
uspace/srv/hid/display/window.c
re1f2079 rb0a94854 518 518 } 519 519 520 /** Post focus event to window. 521 * 522 * @param wnd Window 523 */ 524 errno_t ds_window_post_focus_event(ds_window_t *wnd) 525 { 526 log_msg(LOG_DEFAULT, LVL_DEBUG, "ds_window_post_focus_event\n"); 527 528 return ds_client_post_focus_event(wnd->client, wnd); 529 } 530 531 /** Post unfocus event to window. 532 * 533 * @param wnd Window 534 */ 535 errno_t ds_window_post_unfocus_event(ds_window_t *wnd) 536 { 537 log_msg(LOG_DEFAULT, LVL_DEBUG, "ds_window_post_unfocus_event\n"); 538 539 return ds_client_post_unfocus_event(wnd->client, wnd); 540 } 541 520 542 /** @} 521 543 */ -
uspace/srv/hid/display/window.h
re1f2079 rb0a94854 54 54 extern errno_t ds_window_paint(ds_window_t *, gfx_rect_t *); 55 55 extern errno_t ds_window_post_pos_event(ds_window_t *, pos_event_t *); 56 extern errno_t ds_window_post_focus_event(ds_window_t *); 57 extern errno_t ds_window_post_unfocus_event(ds_window_t *); 56 58 57 59 #endif
Note:
See TracChangeset
for help on using the changeset viewer.