770 byte[] bdata) 771 { 772 // TODO: fill "bdata" member of AWTEvent 773 Rectangle r = getBounds(); 774 // findPeerAt() expects parent coordinates 775 LWComponentPeer targetPeer = findPeerAt(r.x + x, r.y + y); 776 LWWindowPeer lastWindowPeer = 777 (lastMouseEventPeer != null) ? lastMouseEventPeer.getWindowPeerOrSelf() : null; 778 LWWindowPeer curWindowPeer = 779 (targetPeer != null) ? targetPeer.getWindowPeerOrSelf() : null; 780 781 if (id == MouseEvent.MOUSE_EXITED) { 782 // Sometimes we may get MOUSE_EXITED after lastMouseEventPeer is switched 783 // to a peer from another window. So we must first check if this peer is 784 // the same as lastWindowPeer 785 if (lastWindowPeer == this) { 786 if (isEnabled()) { 787 Point lp = lastMouseEventPeer.windowToLocal(x, y, 788 lastWindowPeer); 789 Component target = lastMouseEventPeer.getTarget(); 790 postMouseEnteredExitedEvent(target, id, when, modifiers, lp, 791 screenX, screenY, clickCount, popupTrigger, button); 792 } 793 lastMouseEventPeer = null; 794 } 795 } else { 796 if (targetPeer != lastMouseEventPeer) { 797 // lastMouseEventPeer may be null if mouse was out of Java windows 798 if (lastMouseEventPeer != null && lastMouseEventPeer.isEnabled()) { 799 // Sometimes, MOUSE_EXITED is not sent by delegate (or is sent a bit 800 // later), in which case lastWindowPeer is another window 801 if (lastWindowPeer != this) { 802 Point oldp = lastMouseEventPeer.windowToLocal(x, y, lastWindowPeer); 803 // Additionally translate from this to lastWindowPeer coordinates 804 Rectangle lr = lastWindowPeer.getBounds(); 805 oldp.x += r.x - lr.x; 806 oldp.y += r.y - lr.y; 807 Component target = lastMouseEventPeer.getTarget(); 808 postMouseEnteredExitedEvent(target, id, when, modifiers, oldp, 809 screenX, screenY, clickCount, popupTrigger, button); 810 } else { 811 Point oldp = lastMouseEventPeer.windowToLocal(x, y, this); 812 Component target = lastMouseEventPeer.getTarget(); 813 postMouseEnteredExitedEvent(target, id, when, modifiers, oldp, 814 screenX, screenY, clickCount, popupTrigger, button); 815 } 816 } 817 lastMouseEventPeer = targetPeer; 818 if (targetPeer != null && targetPeer.isEnabled() && id != MouseEvent.MOUSE_ENTERED) { 819 Point newp = targetPeer.windowToLocal(x, y, curWindowPeer); 820 Component target = targetPeer.getTarget(); 821 postMouseEnteredExitedEvent(target, id, when, modifiers, newp, 822 screenX, screenY, clickCount, popupTrigger, button); 823 } 824 } 825 // TODO: fill "bdata" member of AWTEvent 826 827 int eventButtonMask = (button > 0)? MouseEvent.getMaskForButton(button) : 0; 828 int otherButtonsPressed = modifiers & ~eventButtonMask; 829 830 // For pressed/dragged/released events OS X treats other 831 // mouse buttons as if they were BUTTON2, so we do the same 832 int targetIdx = (button > 3) ? MouseEvent.BUTTON2 - 1 : button - 1; 833 834 // MOUSE_ENTERED/EXITED are generated for the components strictly under 835 // mouse even when dragging. That's why we first update lastMouseEventPeer 836 // based on initial targetPeer value and only then recalculate targetPeer 837 // for MOUSE_DRAGGED/RELEASED events 838 if (id == MouseEvent.MOUSE_PRESSED) { 839 840 // Ungrab only if this window is not an owned window of the grabbing one. 841 if (!isGrabbing() && grabbingWindow != null && | 770 byte[] bdata) 771 { 772 // TODO: fill "bdata" member of AWTEvent 773 Rectangle r = getBounds(); 774 // findPeerAt() expects parent coordinates 775 LWComponentPeer targetPeer = findPeerAt(r.x + x, r.y + y); 776 LWWindowPeer lastWindowPeer = 777 (lastMouseEventPeer != null) ? lastMouseEventPeer.getWindowPeerOrSelf() : null; 778 LWWindowPeer curWindowPeer = 779 (targetPeer != null) ? targetPeer.getWindowPeerOrSelf() : null; 780 781 if (id == MouseEvent.MOUSE_EXITED) { 782 // Sometimes we may get MOUSE_EXITED after lastMouseEventPeer is switched 783 // to a peer from another window. So we must first check if this peer is 784 // the same as lastWindowPeer 785 if (lastWindowPeer == this) { 786 if (isEnabled()) { 787 Point lp = lastMouseEventPeer.windowToLocal(x, y, 788 lastWindowPeer); 789 Component target = lastMouseEventPeer.getTarget(); 790 postMouseEnteredExitedEvent(target, MouseEvent.MOUSE_EXITED, 791 when, modifiers, lp, 792 screenX, screenY, clickCount, popupTrigger, button); 793 } 794 lastMouseEventPeer = null; 795 } 796 } else { 797 if (targetPeer != lastMouseEventPeer) { 798 // lastMouseEventPeer may be null if mouse was out of Java windows 799 if (lastMouseEventPeer != null && lastMouseEventPeer.isEnabled()) { 800 // Sometimes, MOUSE_EXITED is not sent by delegate (or is sent a bit 801 // later), in which case lastWindowPeer is another window 802 if (lastWindowPeer != this) { 803 Point oldp = lastMouseEventPeer.windowToLocal(x, y, lastWindowPeer); 804 // Additionally translate from this to lastWindowPeer coordinates 805 Rectangle lr = lastWindowPeer.getBounds(); 806 oldp.x += r.x - lr.x; 807 oldp.y += r.y - lr.y; 808 Component target = lastMouseEventPeer.getTarget(); 809 postMouseEnteredExitedEvent(target, MouseEvent.MOUSE_EXITED, 810 when, modifiers, oldp, 811 screenX, screenY, clickCount, popupTrigger, button); 812 } else { 813 Point oldp = lastMouseEventPeer.windowToLocal(x, y, this); 814 Component target = lastMouseEventPeer.getTarget(); 815 postMouseEnteredExitedEvent(target, MouseEvent.MOUSE_EXITED, 816 when, modifiers, oldp, 817 screenX, screenY, clickCount, popupTrigger, button); 818 } 819 } 820 lastMouseEventPeer = targetPeer; 821 if (targetPeer != null && targetPeer.isEnabled() && id != MouseEvent.MOUSE_ENTERED) { 822 Point newp = targetPeer.windowToLocal(x, y, curWindowPeer); 823 Component target = targetPeer.getTarget(); 824 postMouseEnteredExitedEvent(target, MouseEvent.MOUSE_ENTERED, 825 when, modifiers, newp, 826 screenX, screenY, clickCount, popupTrigger, button); 827 } 828 } 829 // TODO: fill "bdata" member of AWTEvent 830 831 int eventButtonMask = (button > 0)? MouseEvent.getMaskForButton(button) : 0; 832 int otherButtonsPressed = modifiers & ~eventButtonMask; 833 834 // For pressed/dragged/released events OS X treats other 835 // mouse buttons as if they were BUTTON2, so we do the same 836 int targetIdx = (button > 3) ? MouseEvent.BUTTON2 - 1 : button - 1; 837 838 // MOUSE_ENTERED/EXITED are generated for the components strictly under 839 // mouse even when dragging. That's why we first update lastMouseEventPeer 840 // based on initial targetPeer value and only then recalculate targetPeer 841 // for MOUSE_DRAGGED/RELEASED events 842 if (id == MouseEvent.MOUSE_PRESSED) { 843 844 // Ungrab only if this window is not an owned window of the grabbing one. 845 if (!isGrabbing() && grabbingWindow != null && |