Changeset 35cffea in mainline for uspace/srv/hid/display/window.c
- Timestamp:
- 2022-05-19T08:02:31Z (3 years ago)
- Branches:
- master, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- ad698f4
- Parents:
- fd05ea6
- git-author:
- Jiri Svoboda <jiri@…> (2022-05-18 17:02:12)
- git-committer:
- Jiri Svoboda <jiri@…> (2022-05-19 08:02:31)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/hid/display/window.c
rfd05ea6 r35cffea 1 1 /* 2 * Copyright (c) 202 1Jiri Svoboda2 * Copyright (c) 2022 Jiri Svoboda 3 3 * All rights reserved. 4 4 * … … 580 580 * @param wnd Window 581 581 * @param event Position event 582 * 583 * @return EOK on success or an error code 582 584 */ 583 585 errno_t ds_window_post_pos_event(ds_window_t *wnd, pos_event_t *event) … … 597 599 inside = gfx_pix_inside_rect(&pos, &drect); 598 600 599 if (event->type == POS_PRESS && event->btn_num == 2 && inside) { 601 if (event->type == POS_PRESS && event->btn_num == 2 && inside && 602 (wnd->flags & wndf_maximized) == 0) { 600 603 ds_window_start_move(wnd, &pos); 601 604 return EOK; … … 637 640 * 638 641 * @param wnd Window 642 * @return EOK on success or an error code 639 643 */ 640 644 errno_t ds_window_post_focus_event(ds_window_t *wnd) … … 648 652 * 649 653 * @param wnd Window 654 * @return EOK on success or an error code 650 655 */ 651 656 errno_t ds_window_post_unfocus_event(ds_window_t *wnd) … … 691 696 { 692 697 *dpos = wnd->dpos; 698 } 699 700 /** Get maximized window rectangle. 701 * 702 * @param wnd Window 703 */ 704 void ds_window_get_max_rect(ds_window_t *wnd, gfx_rect_t *rect) 705 { 706 *rect = wnd->display->rect; 693 707 } 694 708 … … 716 730 * 717 731 * @param wnd Window 732 * @return EOK on success or an error code 718 733 */ 719 734 errno_t ds_window_resize(ds_window_t *wnd, gfx_coord2_t *offs, … … 770 785 } 771 786 787 /** Maximize window. 788 * 789 * @param wnd Window 790 * @return EOK on success or an error code 791 */ 792 errno_t ds_window_maximize(ds_window_t *wnd) 793 { 794 gfx_coord2_t old_dpos; 795 gfx_rect_t old_rect; 796 gfx_coord2_t offs; 797 gfx_rect_t max_rect; 798 gfx_rect_t nrect; 799 errno_t rc; 800 801 /* If already maximized, do nothing and return success. */ 802 if ((wnd->flags & wndf_maximized) != 0) 803 return EOK; 804 805 /* Remember the old window rectangle and display position */ 806 old_rect = wnd->rect; 807 old_dpos = wnd->dpos; 808 809 ds_window_get_max_rect(wnd, &max_rect); 810 811 /* Keep window contents on the same position on the screen */ 812 offs.x = max_rect.p0.x - wnd->dpos.x; 813 offs.y = max_rect.p0.y - wnd->dpos.y; 814 815 /* Maximized window's coordinates will start at 0,0 */ 816 gfx_rect_rtranslate(&max_rect.p0, &max_rect, &nrect); 817 818 rc = ds_window_resize(wnd, &offs, &nrect); 819 if (rc != EOK) 820 return rc; 821 822 /* Set window flags, remember normal rectangle */ 823 wnd->flags |= wndf_maximized; 824 wnd->normal_rect = old_rect; 825 wnd->normal_dpos = old_dpos; 826 827 return EOK; 828 } 829 830 /** Unmaximize window. 831 * 832 * @param wnd Window 833 * @return EOK on success or an error code 834 */ 835 errno_t ds_window_unmaximize(ds_window_t *wnd) 836 { 837 gfx_coord2_t offs; 838 errno_t rc; 839 840 /* If not maximized, do nothing and return success. */ 841 if ((wnd->flags & wndf_maximized) == 0) 842 return EOK; 843 844 /* Keep window contents on the same position on the screen */ 845 offs.x = wnd->normal_dpos.x - wnd->dpos.x; 846 offs.y = wnd->normal_dpos.y - wnd->dpos.y; 847 848 rc = ds_window_resize(wnd, &offs, &wnd->normal_rect); 849 if (rc != EOK) 850 return rc; 851 852 /* Set window flags, remember normal rectangle */ 853 wnd->flags &= ~wndf_maximized; 854 855 return EOK; 856 } 857 772 858 /** Compute new window rectangle after resize operation. 773 859 *
Note:
See TracChangeset
for help on using the changeset viewer.