(eventPtr, winPtr)
| 738 | * |
| 739 | * Side effects: |
| 740 | * None. |
| 741 | * |
| 742 | *---------------------------------------------------------------------- |
| 743 | */ |
| 744 | |
| 745 | static void |
| 746 | ChangeEventWindow(eventPtr, winPtr) |
| 747 | register XEvent *eventPtr; /* Event to retarget. Must have |
| 748 | * type ButtonPress, ButtonRelease, KeyPress, |
| 749 | * KeyRelease, MotionNotify, EnterNotify, |
| 750 | * or LeaveNotify. */ |
| 751 | TkWindow *winPtr; /* New target window for event. */ |
| 752 | { |
| 753 | int x, y, sameScreen, bd; |
| 754 | register TkWindow *childPtr; |
| 755 | |
| 756 | eventPtr->xmotion.window = Tk_WindowId(winPtr); |
| 757 | if (eventPtr->xmotion.root == |
| 758 | RootWindow(winPtr->display, winPtr->screenNum)) { |
| 759 | Tk_GetRootCoords((Tk_Window) winPtr, &x, &y); |
| 760 | eventPtr->xmotion.x = eventPtr->xmotion.x_root - x; |
| 761 | eventPtr->xmotion.y = eventPtr->xmotion.y_root - y; |
| 762 | eventPtr->xmotion.subwindow = None; |
| 763 | for (childPtr = winPtr->childList; childPtr != NULL; |
| 764 | childPtr = childPtr->nextPtr) { |
| 765 | if (childPtr->flags & TK_TOP_LEVEL) { |
| 766 | continue; |
| 767 | } |
| 768 | x = eventPtr->xmotion.x - childPtr->changes.x; |
| 769 | y = eventPtr->xmotion.y - childPtr->changes.y; |
| 770 | bd = childPtr->changes.border_width; |
| 771 | if ((x >= -bd) && (y >= -bd) |
| 772 | && (x < (childPtr->changes.width + bd)) |
| 773 | && (y < (childPtr->changes.width + bd))) { |
| 774 | eventPtr->xmotion.subwindow = childPtr->window; |
| 775 | } |
| 776 | } |
| 777 | sameScreen = 1; |
| 778 | } else { |
| 779 | eventPtr->xmotion.x = 0; |
| 780 | eventPtr->xmotion.y = 0; |
| 781 | eventPtr->xmotion.subwindow = None; |
| 782 | sameScreen = 0; |
| 783 | } |
| 784 | if (eventPtr->type == MotionNotify) { |
| 785 | eventPtr->xmotion.same_screen = sameScreen; |
| 786 | } else { |
| 787 | eventPtr->xbutton.same_screen = sameScreen; |
no test coverage detected