Changeset f7fb2b21 in mainline for uspace/srv/hid/display
- Timestamp:
- 2020-02-10T19:01:42Z (6 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- b43edabe
- Parents:
- 287688f2
- Location:
- uspace/srv/hid/display
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/hid/display/client.c
r287688f2 rf7fb2b21 221 221 222 222 wevent->window = ewindow; 223 wevent->event.kbd_event = *event; 223 wevent->event.etype = wev_kbd; 224 wevent->event.ev.kbd = *event; 224 225 list_append(&wevent->levents, &client->events); 225 226 … … 231 232 } 232 233 234 /** Post position event to the client's message queue. 235 * 236 * @param client Client 237 * @param ewindow Window that the message is targetted to 238 * @param event Event 239 * 240 * @return EOK on success or an error code 241 */ 242 errno_t ds_client_post_pos_event(ds_client_t *client, ds_window_t *ewindow, 243 pos_event_t *event) 244 { 245 ds_window_ev_t *wevent; 246 247 wevent = calloc(1, sizeof(ds_window_ev_t)); 248 if (wevent == NULL) 249 return ENOMEM; 250 251 wevent->window = ewindow; 252 wevent->event.etype = wev_pos; 253 wevent->event.ev.pos = *event; 254 list_append(&wevent->levents, &client->events); 255 256 /* Notify the client */ 257 // TODO Do not send more than once until client drains the queue 258 if (client->cb != NULL && client->cb->ev_pending != NULL) 259 client->cb->ev_pending(client->cb_arg); 260 261 return EOK; 262 } 263 233 264 /** @} 234 265 */ -
uspace/srv/hid/display/client.h
r287688f2 rf7fb2b21 39 39 #include <errno.h> 40 40 #include <io/kbd_event.h> 41 #include <io/pos_event.h> 41 42 #include "types/display/client.h" 42 43 #include "types/display/display.h" … … 54 55 extern errno_t ds_client_post_kbd_event(ds_client_t *, ds_window_t *, 55 56 kbd_event_t *); 57 extern errno_t ds_client_post_pos_event(ds_client_t *, ds_window_t *, 58 pos_event_t *); 56 59 57 60 #endif -
uspace/srv/hid/display/test/client.c
r287688f2 rf7fb2b21 206 206 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 207 207 PCUT_ASSERT_EQUALS(wnd, rwindow); 208 PCUT_ASSERT_EQUALS(event.type, revent.kbd_event.type); 209 PCUT_ASSERT_EQUALS(event.key, revent.kbd_event.key); 210 PCUT_ASSERT_EQUALS(event.mods, revent.kbd_event.mods); 211 PCUT_ASSERT_EQUALS(event.c, revent.kbd_event.c); 208 PCUT_ASSERT_EQUALS(wev_kbd, revent.etype); 209 PCUT_ASSERT_EQUALS(event.type, revent.ev.kbd.type); 210 PCUT_ASSERT_EQUALS(event.key, revent.ev.kbd.key); 211 PCUT_ASSERT_EQUALS(event.mods, revent.ev.kbd.mods); 212 PCUT_ASSERT_EQUALS(event.c, revent.ev.kbd.c); 213 214 rc = ds_client_get_event(client, &rwindow, &revent); 215 PCUT_ASSERT_ERRNO_VAL(ENOENT, rc); 216 217 ds_window_destroy(wnd); 218 ds_client_destroy(client); 219 ds_display_destroy(disp); 220 } 221 222 /** Test ds_client_get_event(), ds_client_post_pos_event(). */ 223 PCUT_TEST(client_get_post_pos_event) 224 { 225 ds_display_t *disp; 226 ds_client_t *client; 227 ds_window_t *wnd; 228 display_wnd_params_t params; 229 pos_event_t event; 230 ds_window_t *rwindow; 231 display_wnd_ev_t revent; 232 bool called_cb = NULL; 233 errno_t rc; 234 235 rc = ds_display_create(NULL, &disp); 236 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 237 238 rc = ds_client_create(disp, &test_ds_client_cb, &called_cb, &client); 239 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 240 241 display_wnd_params_init(¶ms); 242 params.rect.p0.x = params.rect.p0.y = 0; 243 params.rect.p1.x = params.rect.p1.y = 1; 244 245 rc = ds_window_create(client, ¶ms, &wnd); 246 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 247 248 event.type = POS_PRESS; 249 event.hpos = 1; 250 event.vpos = 2; 251 252 PCUT_ASSERT_FALSE(called_cb); 253 254 rc = ds_client_get_event(client, &rwindow, &revent); 255 PCUT_ASSERT_ERRNO_VAL(ENOENT, rc); 256 257 rc = ds_client_post_pos_event(client, wnd, &event); 258 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 259 PCUT_ASSERT_TRUE(called_cb); 260 261 rc = ds_client_get_event(client, &rwindow, &revent); 262 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 263 PCUT_ASSERT_EQUALS(wnd, rwindow); 264 PCUT_ASSERT_EQUALS(wev_pos, revent.etype); 265 PCUT_ASSERT_EQUALS(event.type, revent.ev.pos.type); 266 PCUT_ASSERT_EQUALS(event.hpos, revent.ev.pos.hpos); 267 PCUT_ASSERT_EQUALS(event.vpos, revent.ev.pos.vpos); 212 268 213 269 rc = ds_client_get_event(client, &rwindow, &revent); -
uspace/srv/hid/display/test/display.c
r287688f2 rf7fb2b21 377 377 w1->dpos.y = 400; 378 378 379 PCUT_ASSERT_FALSE(called_cb);380 381 379 ds_seat_set_focus(seat, w0); 382 380 … … 386 384 rc = ds_display_post_ptd_event(disp, &event); 387 385 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 388 PCUT_ASSERT_FALSE(called_cb);389 386 390 387 event.type = PTD_PRESS; … … 392 389 rc = ds_display_post_ptd_event(disp, &event); 393 390 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 394 PCUT_ASSERT_FALSE(called_cb);395 391 396 392 PCUT_ASSERT_EQUALS(w1, seat->focus); … … 400 396 rc = ds_display_post_ptd_event(disp, &event); 401 397 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 402 PCUT_ASSERT_FALSE(called_cb);403 398 404 399 event.type = PTD_MOVE; … … 407 402 rc = ds_display_post_ptd_event(disp, &event); 408 403 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 409 PCUT_ASSERT_FALSE(called_cb);410 404 411 405 event.type = PTD_PRESS; … … 413 407 rc = ds_display_post_ptd_event(disp, &event); 414 408 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 415 PCUT_ASSERT_FALSE(called_cb);416 409 417 410 PCUT_ASSERT_EQUALS(w0, seat->focus); -
uspace/srv/hid/display/test/seat.c
r287688f2 rf7fb2b21 232 232 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 233 233 PCUT_ASSERT_EQUALS(wnd, rwindow); 234 PCUT_ASSERT_EQUALS(event.type, revent.kbd_event.type); 235 PCUT_ASSERT_EQUALS(event.key, revent.kbd_event.key); 236 PCUT_ASSERT_EQUALS(event.mods, revent.kbd_event.mods); 237 PCUT_ASSERT_EQUALS(event.c, revent.kbd_event.c); 234 PCUT_ASSERT_EQUALS(wev_kbd, revent.etype); 235 PCUT_ASSERT_EQUALS(event.type, revent.ev.kbd.type); 236 PCUT_ASSERT_EQUALS(event.key, revent.ev.kbd.key); 237 PCUT_ASSERT_EQUALS(event.mods, revent.ev.kbd.mods); 238 PCUT_ASSERT_EQUALS(event.c, revent.ev.kbd.c); 238 239 239 240 rc = ds_client_get_event(client, &rwindow, &revent); -
uspace/srv/hid/display/window.c
r287688f2 rf7fb2b21 489 489 errno_t ds_window_post_pos_event(ds_window_t *wnd, pos_event_t *event) 490 490 { 491 pos_event_t tevent; 492 491 493 log_msg(LOG_DEFAULT, LVL_DEBUG, 492 494 "ds_window_post_pos_event type=%d pos=%d,%d\n", event->type, … … 508 510 } 509 511 510 return EOK; 512 /* Transform event coordinates to window-local */ 513 tevent = *event; 514 tevent.hpos -= wnd->dpos.x; 515 tevent.vpos -= wnd->dpos.y; 516 517 return ds_client_post_pos_event(wnd->client, wnd, &tevent); 511 518 } 512 519
Note:
See TracChangeset
for help on using the changeset viewer.