Changeset 4b72e81 in mainline
- Timestamp:
- 2021-06-09T11:56:03Z (3 years ago)
- Children:
- 1bebc906
- Parents:
- 4055fe63
- git-author:
- Jiri Svoboda <jiri@…> (2021-06-08 17:55:50)
- git-committer:
- Jiri Svoboda <jiri@…> (2021-06-09 11:56:03)
- Location:
- uspace/srv/hid/display
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/hid/display/client.c
r4055fe63 r4b72e81 119 119 } 120 120 121 /* Make sure no event in the queue is referencing the window */ 122 ds_client_purge_window_events(wnd->client, wnd); 123 121 124 list_remove(&wnd->lcwindows); 122 125 wnd->client = NULL; … … 199 202 } 200 203 204 /** Purge events from client event queue referring to a window. 205 * 206 * @param client Client 207 * @param window Window 208 */ 209 void ds_client_purge_window_events(ds_client_t *client, 210 ds_window_t *window) 211 { 212 link_t *cur; 213 link_t *next; 214 ds_window_ev_t *wevent; 215 216 cur = list_first(&client->events); 217 while (cur != NULL) { 218 next = list_next(cur, &client->events); 219 wevent = list_get_instance(cur, ds_window_ev_t, levents); 220 221 if (wevent->window == window) 222 list_remove(cur); 223 224 cur = next; 225 } 226 } 227 201 228 /** Post close event to the client's message queue. 202 229 * -
uspace/srv/hid/display/client.h
r4055fe63 r4b72e81 53 53 extern errno_t ds_client_get_event(ds_client_t *, ds_window_t **, 54 54 display_wnd_ev_t *); 55 extern void ds_client_purge_window_events(ds_client_t *, ds_window_t *); 55 56 extern errno_t ds_client_post_close_event(ds_client_t *, ds_window_t *); 56 57 extern errno_t ds_client_post_focus_event(ds_client_t *, ds_window_t *); -
uspace/srv/hid/display/test/client.c
r4055fe63 r4b72e81 553 553 } 554 554 555 /** Test ds_client_purge_window_events() */ 556 PCUT_TEST(client_purge_window_events) 557 { 558 ds_display_t *disp; 559 ds_client_t *client; 560 ds_seat_t *seat; 561 ds_window_t *wnd; 562 display_wnd_params_t params; 563 ds_window_t *rwindow; 564 display_wnd_ev_t revent; 565 bool called_cb = NULL; 566 errno_t rc; 567 568 rc = ds_display_create(NULL, df_none, &disp); 569 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 570 571 rc = ds_client_create(disp, &test_ds_client_cb, &called_cb, &client); 572 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 573 574 rc = ds_seat_create(disp, &seat); 575 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 576 577 display_wnd_params_init(¶ms); 578 params.rect.p0.x = params.rect.p0.y = 0; 579 params.rect.p1.x = params.rect.p1.y = 1; 580 581 rc = ds_window_create(client, ¶ms, &wnd); 582 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 583 584 /* New window gets focused event */ 585 PCUT_ASSERT_TRUE(called_cb); 586 587 /* Purge it */ 588 ds_client_purge_window_events(client, wnd); 589 590 /* The queue should be empty now */ 591 rc = ds_client_get_event(client, &rwindow, &revent); 592 PCUT_ASSERT_ERRNO_VAL(ENOENT, rc); 593 594 ds_window_destroy(wnd); 595 ds_seat_destroy(seat); 596 ds_client_destroy(client); 597 ds_display_destroy(disp); 598 } 599 555 600 /** Test client being destroyed while still having a window. 556 601 *
Note:
See TracChangeset
for help on using the changeset viewer.