Changeset 76a02db in mainline for uspace/srv/hid/display/window.c
- Timestamp:
- 2020-03-24T11:03:08Z (5 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 1b443cc0
- Parents:
- 0b7e394
- git-author:
- Jiri Svoboda <jiri@…> (2020-03-23 18:39:29)
- git-committer:
- Jiri Svoboda <jiri@…> (2020-03-24 11:03:08)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/hid/display/window.c
r0b7e394 r76a02db 405 405 * 406 406 * @param wnd Window 407 * @param event Button press event408 */ 409 static void ds_window_start_move(ds_window_t *wnd, pos_event_t *event)407 * @param pos Position where mouse button was pressed 408 */ 409 static void ds_window_start_move(ds_window_t *wnd, gfx_coord2_t *pos) 410 410 { 411 411 log_msg(LOG_DEFAULT, LVL_DEBUG, "ds_window_start_move (%d, %d)", 412 (int) event->hpos, (int) event->vpos);412 (int) pos->x, (int) pos->y); 413 413 414 414 if (wnd->state != dsw_idle) 415 415 return; 416 416 417 wnd->orig_pos.x = event->hpos; 418 wnd->orig_pos.y = event->vpos; 417 wnd->orig_pos = *pos; 419 418 wnd->state = dsw_moving; 420 419 } … … 423 422 * 424 423 * @param wnd Window 425 * @param event Button release event 426 */ 427 static void ds_window_finish_move(ds_window_t *wnd, pos_event_t *event) 428 { 429 gfx_coord2_t pos; 424 * @param pos Position where mouse button was released 425 */ 426 static void ds_window_finish_move(ds_window_t *wnd, gfx_coord2_t *pos) 427 { 430 428 gfx_coord2_t dmove; 431 429 gfx_coord2_t nwpos; 432 430 433 431 log_msg(LOG_DEFAULT, LVL_DEBUG, "ds_window_finish_move (%d, %d)", 434 (int) event->hpos, (int) event->vpos);432 (int) pos->x, (int) pos->y); 435 433 436 434 if (wnd->state != dsw_moving) 437 435 return; 438 436 439 pos.x = event->hpos; 440 pos.y = event->vpos; 441 gfx_coord2_subtract(&pos, &wnd->orig_pos, &dmove); 437 gfx_coord2_subtract(pos, &wnd->orig_pos, &dmove); 442 438 443 439 gfx_coord2_add(&wnd->dpos, &dmove, &nwpos); … … 451 447 * 452 448 * @param wnd Window 453 * @param event Position update event 454 */ 455 static void ds_window_update_move(ds_window_t *wnd, pos_event_t *event) 456 { 457 gfx_coord2_t pos; 449 * @param pos Current mouse position 450 */ 451 static void ds_window_update_move(ds_window_t *wnd, gfx_coord2_t *pos) 452 { 458 453 gfx_coord2_t dmove; 459 454 gfx_coord2_t nwpos; … … 464 459 465 460 log_msg(LOG_DEFAULT, LVL_DEBUG, "ds_window_update_move (%d, %d)", 466 (int) event->hpos, (int) event->vpos);461 (int) pos->x, (int) pos->y); 467 462 468 463 if (wnd->state != dsw_moving) … … 477 472 } 478 473 479 pos.x = event->hpos; 480 pos.y = event->vpos; 481 gfx_coord2_subtract(&pos, &wnd->orig_pos, &dmove); 474 gfx_coord2_subtract(pos, &wnd->orig_pos, &dmove); 482 475 483 476 gfx_coord2_add(&wnd->dpos, &dmove, &nwpos); 484 477 gfx_rect_translate(&nwpos, &wnd->rect, &drect); 485 478 486 wnd->orig_pos = pos;479 wnd->orig_pos = *pos; 487 480 wnd->dpos = nwpos; 488 481 … … 500 493 } 501 494 495 /** Start resizing a window by mouse drag. 496 * 497 * @param wnd Window 498 * @param rsztype Resize type (which part of window is being dragged) 499 * @param pos Position where mouse button was pressed 500 */ 501 static void ds_window_start_resize(ds_window_t *wnd, 502 display_wnd_rsztype_t rsztype, gfx_coord2_t *pos) 503 { 504 log_msg(LOG_DEFAULT, LVL_DEBUG, "ds_window_start_resize (%d, %d)", 505 (int) pos->x, (int) pos->y); 506 507 if (wnd->state != dsw_idle) 508 return; 509 510 wnd->orig_pos = *pos; 511 wnd->state = dsw_resizing; 512 wnd->rsztype = rsztype; 513 } 514 502 515 /** Finish resizing a window by mouse drag. 503 516 * 504 517 * @param wnd Window 505 * @param event Button release event 506 */ 507 static void ds_window_finish_resize(ds_window_t *wnd, pos_event_t *event) 508 { 509 gfx_coord2_t pos; 518 * @param pos Position where mouse button was released 519 */ 520 static void ds_window_finish_resize(ds_window_t *wnd, gfx_coord2_t *pos) 521 { 510 522 gfx_coord2_t dresize; 511 523 gfx_rect_t nrect; 512 524 513 525 log_msg(LOG_DEFAULT, LVL_DEBUG, "ds_window_finish_resize (%d, %d)", 514 (int) event->hpos, (int) event->vpos);526 (int) pos->x, (int) pos->y); 515 527 516 528 if (wnd->state != dsw_resizing) … … 519 531 (void) ds_display_paint(wnd->display, NULL); 520 532 521 pos.x = event->hpos; 522 pos.y = event->vpos; 523 gfx_coord2_subtract(&pos, &wnd->orig_pos, &dresize); 533 gfx_coord2_subtract(pos, &wnd->orig_pos, &dresize); 524 534 525 535 /* Compute new rectangle */ … … 533 543 * 534 544 * @param wnd Window 535 * @param event Position update event 536 */ 537 static void ds_window_update_resize(ds_window_t *wnd, pos_event_t *event) 538 { 539 gfx_coord2_t pos; 545 * @param pos Current mouse position 546 */ 547 static void ds_window_update_resize(ds_window_t *wnd, gfx_coord2_t *pos) 548 { 540 549 gfx_coord2_t dresize; 541 550 gfx_rect_t nrect; … … 546 555 547 556 log_msg(LOG_DEFAULT, LVL_DEBUG, "ds_window_update_resize (%d, %d)", 548 (int) event->hpos, (int) event->vpos);557 (int) pos->x, (int) pos->y); 549 558 550 559 if (wnd->state != dsw_resizing) … … 559 568 } 560 569 561 pos.x = event->hpos; 562 pos.y = event->vpos; 563 gfx_coord2_subtract(&pos, &wnd->orig_pos, &dresize); 570 gfx_coord2_subtract(pos, &wnd->orig_pos, &dresize); 564 571 565 572 ds_window_calc_resize(wnd, &dresize, &nrect); … … 623 630 624 631 if (event->type == POS_PRESS && event->btn_num == 2 && inside) 625 ds_window_start_move(wnd, event);632 ds_window_start_move(wnd, &pos); 626 633 627 634 if (event->type == POS_RELEASE) { 628 ds_window_finish_move(wnd, event);629 ds_window_finish_resize(wnd, event);635 ds_window_finish_move(wnd, &pos); 636 ds_window_finish_resize(wnd, &pos); 630 637 } 631 638 632 639 if (event->type == POS_UPDATE) { 633 ds_window_update_move(wnd, event);634 ds_window_update_resize(wnd, event);640 ds_window_update_move(wnd, &pos); 641 ds_window_update_resize(wnd, &pos); 635 642 } 636 643 … … 674 681 void ds_window_move_req(ds_window_t *wnd, gfx_coord2_t *pos) 675 682 { 683 gfx_coord2_t orig_pos; 684 676 685 log_msg(LOG_DEFAULT, LVL_DEBUG, "ds_window_move_req (%d, %d)", 677 686 (int) pos->x, (int) pos->y); 678 687 679 if (wnd->state != dsw_idle) 680 return; 681 682 gfx_coord2_add(&wnd->dpos, pos, &wnd->orig_pos); 683 wnd->state = dsw_moving; 688 gfx_coord2_add(&wnd->dpos, pos, &orig_pos); 689 ds_window_start_move(wnd, &orig_pos); 684 690 } 685 691 … … 705 711 gfx_coord2_t *pos) 706 712 { 713 gfx_coord2_t orig_pos; 714 707 715 log_msg(LOG_DEFAULT, LVL_NOTE, "ds_window_resize_req (%d, %d, %d)", 708 716 (int) rsztype, (int) pos->x, (int) pos->y); 709 717 710 if (wnd->state != dsw_idle) 711 return; 712 713 gfx_coord2_add(&wnd->dpos, pos, &wnd->orig_pos); 714 wnd->state = dsw_resizing; 715 wnd->rsztype = rsztype; 718 gfx_coord2_add(&wnd->dpos, pos, &orig_pos); 719 ds_window_start_resize(wnd, rsztype, &orig_pos); 716 720 } 717 721
Note:
See TracChangeset
for help on using the changeset viewer.