src/macosx/classes/sun/lwawt/LWWindowPeer.java

Print this page




 652             (targetPeer != null) ? targetPeer.getWindowPeerOrSelf() : null;
 653 
 654         if (id == MouseEvent.MOUSE_EXITED) {
 655             // Sometimes we may get MOUSE_EXITED after lastMouseEventPeer is switched
 656             // to a peer from another window. So we must first check if this peer is
 657             // the same as lastWindowPeer
 658             if (lastWindowPeer == this) {
 659                 if (isEnabled()) {
 660                     Point lp = lastMouseEventPeer.windowToLocal(x, y,
 661                                                                 lastWindowPeer);
 662                     postEvent(new MouseEvent(lastMouseEventPeer.getTarget(),
 663                                              MouseEvent.MOUSE_EXITED, when,
 664                                              modifiers, lp.x, lp.y, screenX,
 665                                              screenY, clickCount, popupTrigger,
 666                                              button));
 667                 }
 668                 lastMouseEventPeer = null;
 669             }
 670         } else {
 671             if (targetPeer != lastMouseEventPeer) {


 672                 // lastMouseEventPeer may be null if mouse was out of Java windows
 673                 if (lastMouseEventPeer != null && lastMouseEventPeer.isEnabled()) {
 674                     // Sometimes, MOUSE_EXITED is not sent by delegate (or is sent a bit
 675                     // later), in which case lastWindowPeer is another window
 676                     if (lastWindowPeer != this) {
 677                         Point oldp = lastMouseEventPeer.windowToLocal(x, y, lastWindowPeer);
 678                         // Additionally translate from this to lastWindowPeer coordinates
 679                         Rectangle lr = lastWindowPeer.getBounds();
 680                         oldp.x += r.x - lr.x;
 681                         oldp.y += r.y - lr.y;
 682                         postEvent(new MouseEvent(lastMouseEventPeer.getTarget(),
 683                                                  MouseEvent.MOUSE_EXITED,
 684                                                  when, modifiers,
 685                                                  oldp.x, oldp.y, screenX, screenY,
 686                                                  clickCount, popupTrigger, button));
 687                     } else {
 688                         Point oldp = lastMouseEventPeer.windowToLocal(x, y, this);
 689                         postEvent(new MouseEvent(lastMouseEventPeer.getTarget(),
 690                                                  MouseEvent.MOUSE_EXITED,
 691                                                  when, modifiers,
 692                                                  oldp.x, oldp.y, screenX, screenY,
 693                                                  clickCount, popupTrigger, button));
 694                     }
 695                 }
 696                 lastMouseEventPeer = targetPeer;
 697                 if (targetPeer != null && targetPeer.isEnabled() && id != MouseEvent.MOUSE_ENTERED) {
 698                     Point newp = targetPeer.windowToLocal(x, y, curWindowPeer);
 699                     postEvent(new MouseEvent(targetPeer.getTarget(),
 700                                              MouseEvent.MOUSE_ENTERED,
 701                                              when, modifiers,
 702                                              newp.x, newp.y, screenX, screenY,
 703                                              clickCount, popupTrigger, button));
 704                 }
 705             }


 706             // TODO: fill "bdata" member of AWTEvent
 707 
 708             int eventButtonMask = (button > 0)? MouseEvent.getMaskForButton(button) : 0;
 709             int otherButtonsPressed = modifiers & ~eventButtonMask;
 710 
 711             // For pressed/dragged/released events OS X treats other
 712             // mouse buttons as if they were BUTTON2, so we do the same
 713             int targetIdx = (button > 3) ? MouseEvent.BUTTON2 - 1 : button - 1;
 714 
 715             // MOUSE_ENTERED/EXITED are generated for the components strictly under
 716             // mouse even when dragging. That's why we first update lastMouseEventPeer
 717             // based on initial targetPeer value and only then recalculate targetPeer
 718             // for MOUSE_DRAGGED/RELEASED events
 719             if (id == MouseEvent.MOUSE_PRESSED) {
 720 
 721                 // Ungrab only if this window is not an owned window of the grabbing one.
 722                 if (!isGrabbing() && grabbingWindow != null &&
 723                     grabbingWindow != getOwnerFrameDialog(this))
 724                 {
 725                     grabbingWindow.ungrab();




 652             (targetPeer != null) ? targetPeer.getWindowPeerOrSelf() : null;
 653 
 654         if (id == MouseEvent.MOUSE_EXITED) {
 655             // Sometimes we may get MOUSE_EXITED after lastMouseEventPeer is switched
 656             // to a peer from another window. So we must first check if this peer is
 657             // the same as lastWindowPeer
 658             if (lastWindowPeer == this) {
 659                 if (isEnabled()) {
 660                     Point lp = lastMouseEventPeer.windowToLocal(x, y,
 661                                                                 lastWindowPeer);
 662                     postEvent(new MouseEvent(lastMouseEventPeer.getTarget(),
 663                                              MouseEvent.MOUSE_EXITED, when,
 664                                              modifiers, lp.x, lp.y, screenX,
 665                                              screenY, clickCount, popupTrigger,
 666                                              button));
 667                 }
 668                 lastMouseEventPeer = null;
 669             }
 670         } else {
 671             if (targetPeer != lastMouseEventPeer) {
 672                 
 673                 if (id != MouseEvent.MOUSE_DRAGGED || lastMouseEventPeer == null) {
 674                     // lastMouseEventPeer may be null if mouse was out of Java windows
 675                     if (lastMouseEventPeer != null && lastMouseEventPeer.isEnabled()) {
 676                         // Sometimes, MOUSE_EXITED is not sent by delegate (or is sent a bit
 677                         // later), in which case lastWindowPeer is another window
 678                         if (lastWindowPeer != this) {
 679                             Point oldp = lastMouseEventPeer.windowToLocal(x, y, lastWindowPeer);
 680                             // Additionally translate from this to lastWindowPeer coordinates
 681                             Rectangle lr = lastWindowPeer.getBounds();
 682                             oldp.x += r.x - lr.x;
 683                             oldp.y += r.y - lr.y;
 684                             postEvent(new MouseEvent(lastMouseEventPeer.getTarget(),
 685                                                      MouseEvent.MOUSE_EXITED,
 686                                                      when, modifiers,
 687                                                      oldp.x, oldp.y, screenX, screenY,
 688                                                      clickCount, popupTrigger, button));
 689                         } else {
 690                             Point oldp = lastMouseEventPeer.windowToLocal(x, y, this);
 691                             postEvent(new MouseEvent(lastMouseEventPeer.getTarget(),
 692                                                      MouseEvent.MOUSE_EXITED,
 693                                                      when, modifiers,
 694                                                      oldp.x, oldp.y, screenX, screenY,
 695                                                      clickCount, popupTrigger, button));
 696                         }
 697                     }

 698                     if (targetPeer != null && targetPeer.isEnabled() && id != MouseEvent.MOUSE_ENTERED) {
 699                         Point newp = targetPeer.windowToLocal(x, y, curWindowPeer);
 700                         postEvent(new MouseEvent(targetPeer.getTarget(),
 701                                                  MouseEvent.MOUSE_ENTERED,
 702                                                  when, modifiers,
 703                                                  newp.x, newp.y, screenX, screenY,
 704                                                  clickCount, popupTrigger, button));
 705                     }
 706                 }
 707                 lastMouseEventPeer = targetPeer;
 708             }
 709             // TODO: fill "bdata" member of AWTEvent
 710 
 711             int eventButtonMask = (button > 0)? MouseEvent.getMaskForButton(button) : 0;
 712             int otherButtonsPressed = modifiers & ~eventButtonMask;
 713 
 714             // For pressed/dragged/released events OS X treats other
 715             // mouse buttons as if they were BUTTON2, so we do the same
 716             int targetIdx = (button > 3) ? MouseEvent.BUTTON2 - 1 : button - 1;
 717 
 718             // MOUSE_ENTERED/EXITED are generated for the components strictly under
 719             // mouse even when dragging. That's why we first update lastMouseEventPeer
 720             // based on initial targetPeer value and only then recalculate targetPeer
 721             // for MOUSE_DRAGGED/RELEASED events
 722             if (id == MouseEvent.MOUSE_PRESSED) {
 723 
 724                 // Ungrab only if this window is not an owned window of the grabbing one.
 725                 if (!isGrabbing() && grabbingWindow != null &&
 726                     grabbingWindow != getOwnerFrameDialog(this))
 727                 {
 728                     grabbingWindow.ungrab();