Changeset 29a5a99 in mainline
- Timestamp:
- 2022-12-04T10:42:48Z (2 years ago)
- Branches:
- master, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 14b4577
- Parents:
- 795c6f7
- Location:
- uspace
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/taskbar/taskbar.c
r795c6f7 r29a5a99 140 140 params.flags |= ui_wndf_system; 141 141 142 /* Make maximized windows avoid taskbar */ 143 params.flags |= ui_wndf_avoid; 144 142 145 params.rect.p0.x = 0; 143 146 params.rect.p0.y = 0; -
uspace/lib/display/include/types/display/wndparams.h
r795c6f7 r29a5a99 49 49 wndf_maximized = 0x8, 50 50 /** Special system window */ 51 wndf_system = 0x10 51 wndf_system = 0x10, 52 /** Maximized windows should avoid this window */ 53 wndf_avoid = 0x20 52 54 } display_wnd_flags_t; 53 55 -
uspace/lib/ui/include/types/ui/window.h
r795c6f7 r29a5a99 70 70 ui_wndf_topmost = 0x2, 71 71 /** Special system window */ 72 ui_wndf_system = 0x4 72 ui_wndf_system = 0x4, 73 /** Maximized windows should avoid this window */ 74 ui_wndf_avoid = 0x8 73 75 } ui_wnd_flags_t; 74 76 -
uspace/lib/ui/src/window.c
r795c6f7 r29a5a99 232 232 if ((params->flags & ui_wndf_system) != 0) 233 233 dparams.flags |= wndf_system; 234 if ((params->flags & ui_wndf_avoid) != 0) 235 dparams.flags |= wndf_avoid; 234 236 235 237 if (ui->display != NULL) { -
uspace/srv/hid/display/display.c
r795c6f7 r29a5a99 665 665 } 666 666 667 ds_display_update_max_rect(disp); 668 667 669 return EOK; 668 670 error: … … 739 741 } 740 742 743 /** Update display maximize rectangle. 744 * 745 * Recalculate the maximize rectangle (the rectangle used for maximized 746 * windows). 747 * 748 * @param display Display 749 */ 750 void ds_display_update_max_rect(ds_display_t *display) 751 { 752 ds_window_t *wnd; 753 gfx_rect_t max_rect; 754 gfx_rect_t drect; 755 756 /* Start with the entire display */ 757 max_rect = display->rect; 758 759 wnd = ds_display_first_window(display); 760 while (wnd != NULL) { 761 /* Should maximized windows avoid this window? */ 762 if ((wnd->flags & wndf_avoid) != 0) { 763 /* Window bounding rectangle on display */ 764 gfx_rect_translate(&wnd->dpos, &wnd->rect, &drect); 765 766 /* Crop maximized rectangle */ 767 ds_display_crop_max_rect(&drect, &max_rect); 768 } 769 770 wnd = ds_display_next_window(wnd); 771 } 772 773 /* Update the maximize rectangle */ 774 display->max_rect = max_rect; 775 } 776 777 /** Crop maximize rectangle. 778 * 779 * Use the avoid rectangle @a arect to crop off maximization rectangle 780 * @a mrect. If @a arect covers the top, bottom, left or right part 781 * of @a mrect, it will be cropped off. Otherwise there will be 782 * no effect. 783 * 784 * @param arect Avoid rectangle 785 * @param mrect Maximize rectangle to be modified 786 */ 787 void ds_display_crop_max_rect(gfx_rect_t *arect, gfx_rect_t *mrect) 788 { 789 if (arect->p0.x == mrect->p0.x && arect->p0.y == mrect->p0.y && 790 arect->p1.x == mrect->p1.x) { 791 /* Cropp off top part */ 792 mrect->p0.y = arect->p1.y; 793 } else if (arect->p0.x == mrect->p0.x && arect->p1.x == mrect->p1.x && 794 arect->p1.y == mrect->p1.y) { 795 /* Cropp off bottom part */ 796 mrect->p1.y = arect->p0.y; 797 } else if (arect->p0.x == mrect->p0.x && arect->p0.y == mrect->p0.y && 798 arect->p1.y == mrect->p1.y) { 799 /* Cropp off left part */ 800 mrect->p0.x = arect->p1.x; 801 } else if (arect->p0.y == mrect->p0.y && arect->p1.x == mrect->p1.x && 802 arect->p1.y == mrect->p1.y) { 803 /* Cropp off right part */ 804 mrect->p1.x = arect->p0.x; 805 } 806 } 807 741 808 /** Get unbuffered GC. 742 809 * -
uspace/srv/hid/display/display.h
r795c6f7 r29a5a99 88 88 extern void ds_display_add_cursor(ds_display_t *, ds_cursor_t *); 89 89 extern void ds_display_remove_cursor(ds_cursor_t *); 90 extern void ds_display_update_max_rect(ds_display_t *); 91 extern void ds_display_crop_max_rect(gfx_rect_t *, gfx_rect_t *); 90 92 extern gfx_context_t *ds_display_get_gc(ds_display_t *); 91 93 extern errno_t ds_display_paint_bg(ds_display_t *, gfx_rect_t *); -
uspace/srv/hid/display/test/display.c
r795c6f7 r29a5a99 601 601 } 602 602 603 /** ds_display_update_max_rect() updates maximization rectangle */ 604 PCUT_TEST(display_update_max_rect) 605 { 606 ds_display_t *disp; 607 ds_seat_t *seat; 608 ds_client_t *client; 609 ds_window_t *wnd; 610 display_wnd_params_t params; 611 errno_t rc; 612 613 rc = ds_display_create(NULL, df_none, &disp); 614 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 615 616 rc = ds_seat_create(disp, &seat); 617 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 618 619 rc = ds_client_create(disp, NULL, NULL, &client); 620 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 621 622 /* 623 * We need to set display dimensions Here we do it directly 624 * instead of adding a display device. 625 */ 626 disp->rect.p0.x = 0; 627 disp->rect.p0.y = 0; 628 disp->rect.p1.x = 500; 629 disp->rect.p1.y = 500; 630 631 /* Set maximize rectangle as well */ 632 disp->max_rect = disp->rect; 633 634 /* A panel-like window at the bottom */ 635 display_wnd_params_init(¶ms); 636 params.flags |= wndf_setpos; 637 params.pos.x = 0; 638 params.pos.y = 450; 639 params.rect.p0.x = 0; 640 params.rect.p0.y = 0; 641 params.rect.p1.x = 500; 642 params.rect.p1.y = 50; 643 644 rc = ds_window_create(client, ¶ms, &wnd); 645 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 646 647 /* 648 * At this point the maximize rect should be unaltered because 649 * the avoid flag has not been set. 650 */ 651 PCUT_ASSERT_INT_EQUALS(0, disp->max_rect.p0.x); 652 PCUT_ASSERT_INT_EQUALS(0, disp->max_rect.p0.y); 653 PCUT_ASSERT_INT_EQUALS(500, disp->max_rect.p1.x); 654 PCUT_ASSERT_INT_EQUALS(500, disp->max_rect.p1.y); 655 656 wnd->flags |= wndf_avoid; 657 658 /* Update maximize rectangle */ 659 ds_display_update_max_rect(disp); 660 661 /* Verify maximize rectangle */ 662 PCUT_ASSERT_INT_EQUALS(0, disp->max_rect.p0.x); 663 PCUT_ASSERT_INT_EQUALS(0, disp->max_rect.p0.y); 664 PCUT_ASSERT_INT_EQUALS(500, disp->max_rect.p1.x); 665 PCUT_ASSERT_INT_EQUALS(450, disp->max_rect.p1.y); 666 667 ds_window_destroy(wnd); 668 ds_client_destroy(client); 669 ds_seat_destroy(seat); 670 ds_display_destroy(disp); 671 } 672 673 /** Cropping maximization rectangle from the top */ 674 PCUT_TEST(display_crop_max_rect_top) 675 { 676 gfx_rect_t arect; 677 gfx_rect_t mrect; 678 679 arect.p0.x = 10; 680 arect.p0.y = 20; 681 arect.p1.x = 30; 682 arect.p1.y = 5; 683 684 mrect.p0.x = 10; 685 mrect.p0.y = 20; 686 mrect.p1.x = 30; 687 mrect.p1.y = 40; 688 689 ds_display_crop_max_rect(&arect, &mrect); 690 691 PCUT_ASSERT_INT_EQUALS(10, mrect.p0.x); 692 PCUT_ASSERT_INT_EQUALS(5, mrect.p0.y); 693 PCUT_ASSERT_INT_EQUALS(30, mrect.p1.x); 694 PCUT_ASSERT_INT_EQUALS(40, mrect.p1.y); 695 } 696 697 /** Cropping maximization rectangle from the bottom */ 698 PCUT_TEST(display_crop_max_rect_bottom) 699 { 700 gfx_rect_t arect; 701 gfx_rect_t mrect; 702 703 arect.p0.x = 10; 704 arect.p0.y = 35; 705 arect.p1.x = 30; 706 arect.p1.y = 40; 707 708 mrect.p0.x = 10; 709 mrect.p0.y = 20; 710 mrect.p1.x = 30; 711 mrect.p1.y = 40; 712 713 ds_display_crop_max_rect(&arect, &mrect); 714 715 PCUT_ASSERT_INT_EQUALS(10, mrect.p0.x); 716 PCUT_ASSERT_INT_EQUALS(20, mrect.p0.y); 717 PCUT_ASSERT_INT_EQUALS(30, mrect.p1.x); 718 PCUT_ASSERT_INT_EQUALS(35, mrect.p1.y); 719 } 720 721 /** Cropping maximization rectangle from the left */ 722 PCUT_TEST(display_crop_max_rect_left) 723 { 724 gfx_rect_t arect; 725 gfx_rect_t mrect; 726 727 arect.p0.x = 10; 728 arect.p0.y = 20; 729 arect.p1.x = 15; 730 arect.p1.y = 40; 731 732 mrect.p0.x = 10; 733 mrect.p0.y = 20; 734 mrect.p1.x = 30; 735 mrect.p1.y = 40; 736 737 ds_display_crop_max_rect(&arect, &mrect); 738 739 PCUT_ASSERT_INT_EQUALS(15, mrect.p0.x); 740 PCUT_ASSERT_INT_EQUALS(20, mrect.p0.y); 741 PCUT_ASSERT_INT_EQUALS(30, mrect.p1.x); 742 PCUT_ASSERT_INT_EQUALS(40, mrect.p1.y); 743 } 744 745 /** Cropping maximization rectangle from the right */ 746 PCUT_TEST(display_crop_max_rect_right) 747 { 748 gfx_rect_t arect; 749 gfx_rect_t mrect; 750 751 arect.p0.x = 25; 752 arect.p0.y = 20; 753 arect.p1.x = 30; 754 arect.p1.y = 40; 755 756 mrect.p0.x = 10; 757 mrect.p0.y = 20; 758 mrect.p1.x = 30; 759 mrect.p1.y = 40; 760 761 ds_display_crop_max_rect(&arect, &mrect); 762 763 PCUT_ASSERT_INT_EQUALS(10, mrect.p0.x); 764 PCUT_ASSERT_INT_EQUALS(20, mrect.p0.y); 765 PCUT_ASSERT_INT_EQUALS(25, mrect.p1.x); 766 PCUT_ASSERT_INT_EQUALS(40, mrect.p1.y); 767 } 768 603 769 PCUT_EXPORT(display); -
uspace/srv/hid/display/types/display/display.h
r795c6f7 r29a5a99 1 1 /* 2 * Copyright (c) 20 19Jiri Svoboda2 * Copyright (c) 2022 Jiri Svoboda 3 3 * All rights reserved. 4 4 * … … 97 97 gfx_rect_t rect; 98 98 99 /** Maximize rectangle */ 100 gfx_rect_t max_rect; 101 99 102 /** Backbuffer bitmap or @c NULL if not double-buffering */ 100 103 gfx_bitmap_t *backbuf; -
uspace/srv/hid/display/window.c
r795c6f7 r29a5a99 150 150 ds_seat_set_focus(seat, wnd); 151 151 152 if ((params->flags & wndf_avoid) != 0) 153 ds_display_update_max_rect(wnd->display); 154 152 155 (void) ds_display_paint(wnd->display, NULL); 153 156 … … 183 186 ds_display_remove_window(wnd); 184 187 188 if ((wnd->flags & wndf_avoid) != 0) 189 ds_display_update_max_rect(disp); 190 185 191 mem_gc_delete(wnd->mgc); 186 192 … … 718 724 void ds_window_get_max_rect(ds_window_t *wnd, gfx_rect_t *rect) 719 725 { 720 *rect = wnd->display-> rect;726 *rect = wnd->display->max_rect; 721 727 } 722 728 … … 795 801 wnd->rect = *nrect; 796 802 803 if ((wnd->flags & wndf_avoid) != 0) 804 ds_display_update_max_rect(wnd->display); 805 797 806 (void) ds_display_paint(wnd->display, NULL); 798 807 return EOK;
Note:
See TracChangeset
for help on using the changeset viewer.