Changes in uspace/srv/hid/display/window.c [2e0a2e7:0d00e53] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/hid/display/window.c
r2e0a2e7 r0d00e53 1 1 /* 2 * Copyright (c) 20 19Jiri Svoboda2 * Copyright (c) 2024 Jiri Svoboda 3 3 * All rights reserved. 4 4 * … … 44 44 #include <memgfx/memgc.h> 45 45 #include <stdlib.h> 46 #include <str.h> 47 #include <wndmgt.h> 46 48 #include "client.h" 47 49 #include "display.h" 48 50 #include "seat.h" 49 51 #include "window.h" 50 51 static void ds_window_update_cb(void *, gfx_rect_t *); 52 #include "wmclient.h" 53 54 static void ds_window_invalidate_cb(void *, gfx_rect_t *); 55 static void ds_window_update_cb(void *); 52 56 static void ds_window_get_preview_rect(ds_window_t *, gfx_rect_t *); 57 58 static mem_gc_cb_t ds_window_mem_gc_cb = { 59 .invalidate = ds_window_invalidate_cb, 60 .update = ds_window_update_cb 61 }; 53 62 54 63 /** Create window. … … 58 67 * @param client Client owning the window 59 68 * @param params Window parameters 60 * @param r gc Place to store pointer to new GC.69 * @param rwnd Place to store pointer to new window. 61 70 * 62 71 * @return EOK on success or an error code 63 72 */ 64 73 errno_t ds_window_create(ds_client_t *client, display_wnd_params_t *params, 65 ds_window_t **r gc)74 ds_window_t **rwnd) 66 75 { 67 76 ds_window_t *wnd = NULL; 77 ds_seat_t *seat; 68 78 gfx_context_t *dgc; 69 79 gfx_coord2_t dims; … … 78 88 } 79 89 90 /* Caption */ 91 wnd->caption = str_dup(params->caption); 92 if (wnd->caption == NULL) { 93 rc = ENOMEM; 94 goto error; 95 } 96 97 wnd->flags = params->flags; 98 80 99 ds_client_add_window(client, wnd); 81 100 ds_display_add_window(client->display, wnd); … … 83 102 gfx_bitmap_params_init(&bparams); 84 103 bparams.rect = params->rect; 104 105 /* Allocate window bitmap */ 85 106 86 107 dgc = ds_display_get_gc(wnd->display); … … 106 127 } 107 128 108 rc = mem_gc_create(¶ms->rect, &alloc, ds_window_update_cb,129 rc = mem_gc_create(¶ms->rect, &alloc, &ds_window_mem_gc_cb, 109 130 (void *)wnd, &wnd->mgc); 110 131 if (rc != EOK) … … 115 136 wnd->gc = mem_gc_get_ctx(wnd->mgc); 116 137 wnd->cursor = wnd->display->cursor[dcurs_arrow]; 117 *rgc = wnd; 138 139 if ((params->flags & wndf_setpos) != 0) { 140 /* Specific window position */ 141 wnd->dpos = params->pos; 142 } else { 143 /* Automatic window placement */ 144 wnd->dpos.x = ((wnd->id - 1) & 1) * 400; 145 wnd->dpos.y = ((wnd->id - 1) & 2) / 2 * 300; 146 } 147 148 /* Determine which seat should own the window */ 149 if (params->idev_id != 0) 150 seat = ds_display_seat_by_idev(wnd->display, params->idev_id); 151 else 152 seat = ds_display_default_seat(wnd->display); 153 154 /* Is this a popup window? */ 155 if ((params->flags & wndf_popup) != 0) { 156 ds_seat_set_popup(seat, wnd); 157 } else { 158 if ((params->flags & wndf_nofocus) == 0) 159 ds_seat_set_focus(seat, wnd); 160 } 161 162 /* Is this window a panel? */ 163 if ((params->flags & wndf_avoid) != 0) 164 ds_display_update_max_rect(wnd->display); 165 166 (void) ds_display_paint(wnd->display, NULL); 167 168 *rwnd = wnd; 118 169 return EOK; 119 170 error: 120 171 if (wnd != NULL) { 172 ds_client_remove_window(wnd); 173 ds_display_remove_window(wnd); 174 if (wnd->mgc != NULL) 175 mem_gc_delete(wnd->mgc); 121 176 if (wnd->bitmap != NULL) 122 177 gfx_bitmap_destroy(wnd->bitmap); 178 if (wnd->caption != NULL) 179 free(wnd->caption); 123 180 free(wnd); 124 181 } … … 136 193 137 194 disp = wnd->display; 195 196 ds_window_unfocus(wnd); 138 197 139 198 ds_client_remove_window(wnd); 140 199 ds_display_remove_window(wnd); 141 200 201 if ((wnd->flags & wndf_avoid) != 0) 202 ds_display_update_max_rect(disp); 203 142 204 mem_gc_delete(wnd->mgc); 143 205 … … 145 207 gfx_bitmap_destroy(wnd->bitmap); 146 208 209 free(wnd->caption); 147 210 free(wnd); 148 211 … … 156 219 void ds_window_bring_to_top(ds_window_t *wnd) 157 220 { 158 ds_display_t *disp = wnd->display; 159 160 ds_display_remove_window(wnd); 161 ds_display_add_window(disp, wnd); 221 ds_display_window_to_top(wnd); 162 222 (void) ds_display_paint(wnd->display, NULL); 163 223 } … … 171 231 { 172 232 return wnd->gc; 233 } 234 235 /** Determine if window is visible. 236 * 237 * @param wnd Window 238 * @return @c true iff window is visible 239 */ 240 bool ds_window_is_visible(ds_window_t *wnd) 241 { 242 return (wnd->flags & wndf_minimized) == 0; 173 243 } 174 244 … … 185 255 gfx_rect_t crect; 186 256 187 log_msg(LOG_DEFAULT, LVL_DEBUG, "ds_window_paint"); 257 log_msg(LOG_DEFAULT, LVL_DEBUG2, "ds_window_paint"); 258 259 /* Skip painting the window if not visible */ 260 if (!ds_window_is_visible(wnd)) 261 return EOK; 188 262 189 263 if (rect != NULL) { … … 330 404 bool newr; 331 405 332 log_msg(LOG_DEFAULT, LVL_DEBUG , "ds_window_repaint_preview");406 log_msg(LOG_DEFAULT, LVL_DEBUG2, "ds_window_repaint_preview"); 333 407 334 408 /* … … 374 448 * @param wnd Window 375 449 * @param pos Position where mouse button was pressed 376 */ 377 static void ds_window_start_move(ds_window_t *wnd, gfx_coord2_t *pos) 450 * @param pos_id Positioning device ID 451 */ 452 static void ds_window_start_move(ds_window_t *wnd, gfx_coord2_t *pos, 453 sysarg_t pos_id) 378 454 { 379 455 log_msg(LOG_DEFAULT, LVL_DEBUG, "ds_window_start_move (%d, %d)", … … 384 460 385 461 wnd->orig_pos = *pos; 462 wnd->orig_pos_id = pos_id; 386 463 wnd->state = dsw_moving; 387 464 wnd->preview_pos = wnd->dpos; … … 413 490 wnd->dpos = nwpos; 414 491 wnd->state = dsw_idle; 492 wnd->orig_pos_id = 0; 415 493 416 494 (void) ds_display_paint(wnd->display, NULL); … … 428 506 gfx_rect_t old_rect; 429 507 430 log_msg(LOG_DEFAULT, LVL_DEBUG , "ds_window_update_move (%d, %d)",508 log_msg(LOG_DEFAULT, LVL_DEBUG2, "ds_window_update_move (%d, %d)", 431 509 (int) pos->x, (int) pos->y); 432 510 … … 447 525 * @param rsztype Resize type (which part of window is being dragged) 448 526 * @param pos Position where mouse button was pressed 527 * @param pos_id Positioning device ID 449 528 */ 450 529 static void ds_window_start_resize(ds_window_t *wnd, 451 display_wnd_rsztype_t rsztype, gfx_coord2_t *pos )530 display_wnd_rsztype_t rsztype, gfx_coord2_t *pos, sysarg_t pos_id) 452 531 { 453 532 ds_seat_t *seat; … … 460 539 return; 461 540 541 /* Determine which seat started the resize */ 542 seat = ds_display_seat_by_idev(wnd->display, pos_id); 543 if (seat == NULL) 544 return; 545 462 546 wnd->orig_pos = *pos; 547 wnd->orig_pos_id = pos_id; 463 548 wnd->state = dsw_resizing; 464 549 wnd->rsztype = rsztype; 465 550 wnd->preview_rect = wnd->rect; 466 551 467 // XXX Need client to tell us which seat started the resize!468 seat = ds_display_first_seat(wnd->display);469 552 ctype = display_cursor_from_wrsz(rsztype); 470 553 ds_seat_set_wm_cursor(seat, wnd->display->cursor[ctype]); … … 496 579 ds_client_post_resize_event(wnd->client, wnd, &nrect); 497 580 498 // XXX Need to know which seat started the resize! 499 seat = ds_display_first_seat(wnd->display); 500 ds_seat_set_wm_cursor(seat, NULL); 581 /* Determine which seat started the resize */ 582 seat = ds_display_seat_by_idev(wnd->display, wnd->orig_pos_id); 583 if (seat != NULL) 584 ds_seat_set_wm_cursor(seat, NULL); 585 586 wnd->orig_pos_id = 0; 501 587 502 588 (void) ds_display_paint(wnd->display, NULL); … … 514 600 gfx_rect_t old_rect; 515 601 516 log_msg(LOG_DEFAULT, LVL_DEBUG , "ds_window_update_resize (%d, %d)",602 log_msg(LOG_DEFAULT, LVL_DEBUG2, "ds_window_update_resize (%d, %d)", 517 603 (int) pos->x, (int) pos->y); 518 604 … … 553 639 * @param wnd Window 554 640 * @param event Position event 641 * 642 * @return EOK on success or an error code 555 643 */ 556 644 errno_t ds_window_post_pos_event(ds_window_t *wnd, pos_event_t *event) … … 558 646 pos_event_t tevent; 559 647 gfx_coord2_t pos; 648 sysarg_t pos_id; 560 649 gfx_rect_t drect; 561 650 bool inside; 562 651 563 log_msg(LOG_DEFAULT, LVL_DEBUG ,652 log_msg(LOG_DEFAULT, LVL_DEBUG2, 564 653 "ds_window_post_pos_event type=%d pos=%d,%d", event->type, 565 654 (int) event->hpos, (int) event->vpos); … … 567 656 pos.x = event->hpos; 568 657 pos.y = event->vpos; 658 pos_id = event->pos_id; 569 659 gfx_rect_translate(&wnd->dpos, &wnd->rect, &drect); 570 660 inside = gfx_pix_inside_rect(&pos, &drect); 571 661 572 if (event->type == POS_PRESS && event->btn_num == 2 && inside) { 573 ds_window_start_move(wnd, &pos); 662 if (event->type == POS_PRESS && event->btn_num == 2 && inside && 663 (wnd->flags & wndf_maximized) == 0) { 664 ds_window_start_move(wnd, &pos, pos_id); 574 665 return EOK; 575 666 } 576 667 577 668 if (event->type == POS_RELEASE) { 578 if (wnd->state == dsw_moving) { 669 /* Finish move/resize if they were started by the same seat */ 670 if (wnd->state == dsw_moving && 671 ds_window_orig_seat(wnd, pos_id)) { 579 672 ds_window_finish_move(wnd, &pos); 580 673 return EOK; 581 674 } 582 675 583 if (wnd->state == dsw_resizing) { 676 if (wnd->state == dsw_resizing && 677 ds_window_orig_seat(wnd, pos_id)) { 584 678 ds_window_finish_resize(wnd, &pos); 585 679 return EOK; … … 588 682 589 683 if (event->type == POS_UPDATE) { 590 if (wnd->state == dsw_moving) { 684 /* Update move/resize if they were started by the same seat */ 685 if (wnd->state == dsw_moving && 686 ds_window_orig_seat(wnd, pos_id)) { 591 687 ds_window_update_move(wnd, &pos); 592 688 return EOK; 593 689 } 594 690 595 if (wnd->state == dsw_resizing) { 691 if (wnd->state == dsw_resizing && 692 ds_window_orig_seat(wnd, pos_id)) { 596 693 ds_window_update_resize(wnd, &pos); 597 694 return EOK; … … 610 707 * 611 708 * @param wnd Window 709 * @return EOK on success or an error code 612 710 */ 613 711 errno_t ds_window_post_focus_event(ds_window_t *wnd) 614 712 { 713 display_wnd_focus_ev_t efocus; 714 errno_t rc; 715 ds_wmclient_t *wmclient; 716 615 717 log_msg(LOG_DEFAULT, LVL_DEBUG, "ds_window_post_focus_event"); 616 718 617 return ds_client_post_focus_event(wnd->client, wnd); 719 /* Increase focus counter */ 720 ++wnd->nfocus; 721 efocus.nfocus = wnd->nfocus; 722 723 rc = ds_client_post_focus_event(wnd->client, wnd, &efocus); 724 if (rc != EOK) 725 return rc; 726 727 /* Notify window managers about window information change */ 728 wmclient = ds_display_first_wmclient(wnd->display); 729 while (wmclient != NULL) { 730 ds_wmclient_post_wnd_changed_event(wmclient, wnd->id); 731 wmclient = ds_display_next_wmclient(wmclient); 732 } 733 734 return EOK; 618 735 } 619 736 … … 621 738 * 622 739 * @param wnd Window 740 * @return EOK on success or an error code 623 741 */ 624 742 errno_t ds_window_post_unfocus_event(ds_window_t *wnd) 625 743 { 744 display_wnd_unfocus_ev_t eunfocus; 745 errno_t rc; 746 ds_wmclient_t *wmclient; 747 626 748 log_msg(LOG_DEFAULT, LVL_DEBUG, "ds_window_post_unfocus_event"); 627 749 628 return ds_client_post_unfocus_event(wnd->client, wnd); 750 /* Decrease focus counter */ 751 --wnd->nfocus; 752 eunfocus.nfocus = wnd->nfocus; 753 754 rc = ds_client_post_unfocus_event(wnd->client, wnd, &eunfocus); 755 if (rc != EOK) 756 return rc; 757 758 /* Notify window managers about window information change */ 759 wmclient = ds_display_first_wmclient(wnd->display); 760 while (wmclient != NULL) { 761 ds_wmclient_post_wnd_changed_event(wmclient, wnd->id); 762 wmclient = ds_display_next_wmclient(wmclient); 763 } 764 765 return EOK; 629 766 } 630 767 … … 634 771 * @param pos Position where the pointer was when the move started 635 772 * relative to the window 773 * @param pos_id Positioning device ID 636 774 * @param event Button press event 637 775 */ 638 void ds_window_move_req(ds_window_t *wnd, gfx_coord2_t *pos )776 void ds_window_move_req(ds_window_t *wnd, gfx_coord2_t *pos, sysarg_t pos_id) 639 777 { 640 778 gfx_coord2_t orig_pos; … … 644 782 645 783 gfx_coord2_add(&wnd->dpos, pos, &orig_pos); 646 ds_window_start_move(wnd, &orig_pos );784 ds_window_start_move(wnd, &orig_pos, pos_id); 647 785 } 648 786 … … 655 793 wnd->dpos = *dpos; 656 794 (void) ds_display_paint(wnd->display, NULL); 795 } 796 797 /** Get window position. 798 * 799 * @param wnd Window 800 */ 801 void ds_window_get_pos(ds_window_t *wnd, gfx_coord2_t *dpos) 802 { 803 *dpos = wnd->dpos; 804 } 805 806 /** Get maximized window rectangle. 807 * 808 * @param wnd Window 809 */ 810 void ds_window_get_max_rect(ds_window_t *wnd, gfx_rect_t *rect) 811 { 812 *rect = wnd->display->max_rect; 657 813 } 658 814 … … 663 819 * @param pos Position where the pointer was when the resize started 664 820 * relative to the window 821 * @param pos_id Positioning device ID 665 822 * @param event Button press event 666 823 */ 667 824 void ds_window_resize_req(ds_window_t *wnd, display_wnd_rsztype_t rsztype, 668 gfx_coord2_t *pos )825 gfx_coord2_t *pos, sysarg_t pos_id) 669 826 { 670 827 gfx_coord2_t orig_pos; 671 828 672 log_msg(LOG_DEFAULT, LVL_DEBUG, "ds_window_resize_req (%d, %d, %d )",673 (int) rsztype, (int) pos->x, (int) pos->y);829 log_msg(LOG_DEFAULT, LVL_DEBUG, "ds_window_resize_req (%d, %d, %d, %d)", 830 (int)rsztype, (int)pos->x, (int)pos->y, (int)pos_id); 674 831 675 832 gfx_coord2_add(&wnd->dpos, pos, &orig_pos); 676 ds_window_start_resize(wnd, rsztype, &orig_pos );833 ds_window_start_resize(wnd, rsztype, &orig_pos, pos_id); 677 834 } 678 835 … … 680 837 * 681 838 * @param wnd Window 839 * @return EOK on success or an error code 682 840 */ 683 841 errno_t ds_window_resize(ds_window_t *wnd, gfx_coord2_t *offs, … … 730 888 wnd->rect = *nrect; 731 889 890 if ((wnd->flags & wndf_avoid) != 0) 891 ds_display_update_max_rect(wnd->display); 892 732 893 (void) ds_display_paint(wnd->display, NULL); 894 return EOK; 895 } 896 897 /** Minimize window. 898 * 899 * @param wnd Window 900 * @return EOK on success or an error code 901 */ 902 errno_t ds_window_minimize(ds_window_t *wnd) 903 { 904 /* If already minimized, do nothing and return success. */ 905 if ((wnd->flags & wndf_minimized) != 0) 906 return EOK; 907 908 ds_window_unfocus(wnd); 909 910 wnd->flags |= wndf_minimized; 911 (void) ds_display_paint(wnd->display, NULL); 912 return EOK; 913 } 914 915 /** Unminimize window. 916 * 917 * @param wnd Window 918 * @return EOK on success or an error code 919 */ 920 errno_t ds_window_unminimize(ds_window_t *wnd) 921 { 922 /* If not minimized, do nothing and return success. */ 923 if ((wnd->flags & wndf_minimized) == 0) 924 return EOK; 925 926 wnd->flags &= ~wndf_minimized; 927 (void) ds_display_paint(wnd->display, NULL); 928 return EOK; 929 } 930 931 /** Maximize window. 932 * 933 * @param wnd Window 934 * @return EOK on success or an error code 935 */ 936 errno_t ds_window_maximize(ds_window_t *wnd) 937 { 938 gfx_coord2_t old_dpos; 939 gfx_rect_t old_rect; 940 gfx_coord2_t offs; 941 gfx_rect_t max_rect; 942 gfx_rect_t nrect; 943 errno_t rc; 944 945 /* If already maximized, do nothing and return success. */ 946 if ((wnd->flags & wndf_maximized) != 0) 947 return EOK; 948 949 /* Remember the old window rectangle and display position */ 950 old_rect = wnd->rect; 951 old_dpos = wnd->dpos; 952 953 ds_window_get_max_rect(wnd, &max_rect); 954 955 /* Keep window contents on the same position on the screen */ 956 offs.x = max_rect.p0.x - wnd->dpos.x; 957 offs.y = max_rect.p0.y - wnd->dpos.y; 958 959 /* Maximized window's coordinates will start at 0,0 */ 960 gfx_rect_rtranslate(&max_rect.p0, &max_rect, &nrect); 961 962 rc = ds_window_resize(wnd, &offs, &nrect); 963 if (rc != EOK) 964 return rc; 965 966 /* Set window flags, remember normal rectangle */ 967 wnd->flags |= wndf_maximized; 968 wnd->normal_rect = old_rect; 969 wnd->normal_dpos = old_dpos; 970 971 return EOK; 972 } 973 974 /** Unmaximize window. 975 * 976 * @param wnd Window 977 * @return EOK on success or an error code 978 */ 979 errno_t ds_window_unmaximize(ds_window_t *wnd) 980 { 981 gfx_coord2_t offs; 982 errno_t rc; 983 984 /* If not maximized, do nothing and return success. */ 985 if ((wnd->flags & wndf_maximized) == 0) 986 return EOK; 987 988 /* Keep window contents on the same position on the screen */ 989 offs.x = wnd->normal_dpos.x - wnd->dpos.x; 990 offs.y = wnd->normal_dpos.y - wnd->dpos.y; 991 992 rc = ds_window_resize(wnd, &offs, &wnd->normal_rect); 993 if (rc != EOK) 994 return rc; 995 996 /* Clear maximized flag */ 997 wnd->flags &= ~wndf_maximized; 998 733 999 return EOK; 734 1000 } … … 776 1042 * 777 1043 * @param wnd Window 1044 * @param cursor New cursor 778 1045 * @return EOK on success, EINVAL if @a cursor is invalid 779 1046 */ … … 789 1056 } 790 1057 791 /** Window memory GC update callback. 792 * 793 * This is called by the window's memory GC when a rectangle us updated. 794 */ 795 static void ds_window_update_cb(void *arg, gfx_rect_t *rect) 1058 /** Set window caption. 1059 * 1060 * @param wnd Window 1061 * @param caption New caption 1062 * 1063 * @return EOK on success, EINVAL if @a cursor is invalid 1064 */ 1065 errno_t ds_window_set_caption(ds_window_t *wnd, const char *caption) 1066 { 1067 char *dcaption; 1068 ds_wmclient_t *wmclient; 1069 1070 dcaption = str_dup(caption); 1071 if (dcaption == NULL) 1072 return ENOMEM; 1073 1074 free(wnd->caption); 1075 wnd->caption = dcaption; 1076 1077 /* Notify window managers about window information change */ 1078 wmclient = ds_display_first_wmclient(wnd->display); 1079 while (wmclient != NULL) { 1080 ds_wmclient_post_wnd_changed_event(wmclient, wnd->id); 1081 wmclient = ds_display_next_wmclient(wmclient); 1082 } 1083 1084 return EOK; 1085 } 1086 1087 /** Find alternate window with the allowed flags. 1088 * 1089 * An alternate window is a *different* window that is preferably previous 1090 * in the display order and only has the @a allowed flags. 1091 * 1092 * @param wnd Window 1093 * @param allowed_flags Bitmask of flags that the window is allowed to have 1094 * 1095 * @return Alternate window matching the criteria or @c NULL if there is none 1096 */ 1097 ds_window_t *ds_window_find_prev(ds_window_t *wnd, 1098 display_wnd_flags_t allowed_flags) 1099 { 1100 ds_window_t *nwnd; 1101 1102 /* Try preceding windows in display order */ 1103 nwnd = ds_display_next_window(wnd); 1104 while (nwnd != NULL && (nwnd->flags & ~allowed_flags) != 0) { 1105 nwnd = ds_display_next_window(nwnd); 1106 } 1107 1108 /* Do we already have a matching window? */ 1109 if (nwnd != NULL && (nwnd->flags & ~allowed_flags) == 0) { 1110 return nwnd; 1111 } 1112 1113 /* Try succeeding windows in display order */ 1114 nwnd = ds_display_first_window(wnd->display); 1115 while (nwnd != NULL && nwnd != wnd && 1116 (nwnd->flags & ~allowed_flags) != 0) { 1117 nwnd = ds_display_next_window(nwnd); 1118 } 1119 1120 if (nwnd == wnd) 1121 return NULL; 1122 1123 return nwnd; 1124 } 1125 1126 /** Find alternate window with the allowed flags. 1127 * 1128 * An alternate window is a *different* window that is preferably previous 1129 * in the display order and only has the @a allowed flags. 1130 * 1131 * @param wnd Window 1132 * @param allowed_flags Bitmask of flags that the window is allowed to have 1133 * 1134 * @return Alternate window matching the criteria or @c NULL if there is none 1135 */ 1136 ds_window_t *ds_window_find_next(ds_window_t *wnd, 1137 display_wnd_flags_t allowed_flags) 1138 { 1139 ds_window_t *nwnd; 1140 1141 /* Try preceding windows in display order */ 1142 nwnd = ds_display_prev_window(wnd); 1143 while (nwnd != NULL && (nwnd->flags & ~allowed_flags) != 0) { 1144 nwnd = ds_display_prev_window(nwnd); 1145 } 1146 1147 /* Do we already have a matching window? */ 1148 if (nwnd != NULL && (nwnd->flags & ~allowed_flags) == 0) { 1149 return nwnd; 1150 } 1151 1152 /* Try succeeding windows in display order */ 1153 nwnd = ds_display_last_window(wnd->display); 1154 while (nwnd != NULL && nwnd != wnd && 1155 (nwnd->flags & ~allowed_flags) != 0) { 1156 nwnd = ds_display_prev_window(nwnd); 1157 } 1158 1159 if (nwnd == wnd) 1160 return NULL; 1161 1162 return nwnd; 1163 } 1164 1165 /** Remove focus from window. 1166 * 1167 * Used to switch focus to another window when closing or minimizing window. 1168 * 1169 * @param wnd Window 1170 */ 1171 void ds_window_unfocus(ds_window_t *wnd) 1172 { 1173 ds_seat_t *seat; 1174 1175 /* Make sure window is no longer focused in any seat */ 1176 seat = ds_display_first_seat(wnd->display); 1177 while (seat != NULL) { 1178 ds_seat_unfocus_wnd(seat, wnd); 1179 seat = ds_display_next_seat(seat); 1180 } 1181 } 1182 1183 /** Determine if input device belongs to the same seat as the original device. 1184 * 1185 * Compare the seat ownning @a idev_id with the seat owning @a wnd->orig_pos_id 1186 * (the device that started the window move or resize). 1187 * 1188 * This is used to make sure that, when two seats focus the same window, 1189 * only devices owned by the seat that started the resize or move can 1190 * affect it. Otherwise moving the other pointer(s) would disrupt the 1191 * resize or move operation. 1192 * 1193 * @param wnd Window (that is currently being resized or moved) 1194 * @param idev_id Input device ID 1195 * @return @c true iff idev_id is owned by the same seat as the input 1196 * device that started the resize or move 1197 */ 1198 bool ds_window_orig_seat(ds_window_t *wnd, sysarg_t idev_id) 1199 { 1200 ds_seat_t *orig_seat; 1201 ds_seat_t *seat; 1202 1203 /* Window must be in state such that wnd->orig_pos_id is valid */ 1204 assert(wnd->state == dsw_moving || wnd->state == dsw_resizing); 1205 1206 orig_seat = ds_display_seat_by_idev(wnd->display, wnd->orig_pos_id); 1207 seat = ds_display_seat_by_idev(wnd->display, idev_id); 1208 1209 return seat == orig_seat; 1210 } 1211 1212 /** Window memory GC invalidate callback. 1213 * 1214 * This is called by the window's memory GC when a rectangle is modified. 1215 */ 1216 static void ds_window_invalidate_cb(void *arg, gfx_rect_t *rect) 796 1217 { 797 1218 ds_window_t *wnd = (ds_window_t *)arg; … … 806 1227 } 807 1228 1229 /** Window memory GC update callback. 1230 * 1231 * This is called by the window's memory GC when it is to be updated. 1232 */ 1233 static void ds_window_update_cb(void *arg) 1234 { 1235 ds_window_t *wnd = (ds_window_t *)arg; 1236 1237 (void) wnd; 1238 } 1239 808 1240 /** @} 809 1241 */
Note:
See TracChangeset
for help on using the changeset viewer.