JDK-6317481 : REG:Pressing the mouse, dragging and releasing it outside the button triggers ActionEvent, XAWT
  • Type: Bug
  • Component: client-libs
  • Sub-Component: java.awt
  • Affected Version: 6
  • Priority: P2
  • Status: Closed
  • Resolution: Fixed
  • OS: solaris_10
  • CPU: sparc
  • Submitted: 2005-08-30
  • Updated: 2011-01-19
  • Resolved: 2005-09-17
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 6
6 b53Fixed
Related Reports
Relates :  
Relates :  
Description
I have a frame with a button. I am pressing the mouse (left button) inside the button, dragging the mouse outside the component and releasing it outside the component. I am surprised to see button trigger action event in this case. Button should not trigger action event when the mouse is released outside the component.  It works fine when the mouse is released outside the frame but action event is triggered when the mouse is released within the frame but outside the component. 

This is a regression introduced in mustang-b47 and not reproducible on b46. This is reproducible only on XToolkit. I reproduced it on SolarisSparc10-JDS.

I have attached a sample test. Execute the sample test. You would see a frame and a button. Press the mouse inside the button, drag it and release it outside the component (but within the frame). If you see an action event message on the console, the bug is reproduced.
Similar behavior is seen for other components also. For Button, TextArea and List, when I press the mouse inside the component and drag it outside the frame, I am getting MouseExited event and when I bring back the mouse into the frame (not into the component) I am getting MouseEntered event. I am sure this will be reproducible for other components also since this does not look like a regression introduced at the component level. This is a basic feature and must be fixed at the earliest.

Comments
EVALUATION There are two problems: 1) press mouse on button, drag outside button, release -> incorrect ActionEvent (reg 47) 2) press mouse on button, drag outside button, the following events will be triggered: - MOUSE_EXITED on button - MOUSE_ENTERED on button (reg 47, should be dispatched to the top-level) This are the regressions related to the realSync implementation. Some events are a grabbed events, it means that this events should be dispatched to the grabbed components, otherwise this events will be dispatched to the top-level. At first, it was implemented that the LeaveNotify/EnterNotify events aren't grabbed events. But for realSync it's important to dispatched this events to the grabbed window if the grabbed window is the top-level. But this change was done not only for top-level. See the suggested fix: now the mentioned events are grabbed if the grabbed window is the top-level, else it aren't grabbed. The first problem is the consequence of this issue since the ActionEvent triggering is based on the MouseEntered/MouseExited processing.
02-09-2005

SUGGESTED FIX *** /net/aquila/export/dc158259/Mustang//webrev/src/solaris/classes/sun/awt/X11/XBaseWindow.java- 2005-09-02 17:13:37.000000000 +0400 --- /net/aquila/export/dc158259/Mustang//webrev/src/solaris/classes/sun/awt/X11/XBaseWindow.java 2005-09-02 17:13:37.000000000 +0400 *************** *** 1035,1052 **** return buttonState == 0; } ! static boolean isGrabbedEvent(IXAnyEvent ev) { switch (ev.get_type()) { case ButtonPress: case ButtonRelease: case MotionNotify: case KeyPress: case KeyRelease: case LeaveNotify: case EnterNotify: ! return true; default: ! return false; } } /** --- 1035,1055 ---- return buttonState == 0; } ! static boolean isGrabbedEvent(IXAnyEvent ev, XBaseWindow target) { switch (ev.get_type()) { case ButtonPress: case ButtonRelease: case MotionNotify: case KeyPress: case KeyRelease: + return true; case LeaveNotify: case EnterNotify: ! // We shouldn't dispatch this events to the grabbed components (see 6317481) ! // But this logic is important if the grabbed component is top-level (see realSync) ! return (target instanceof XWindowPeer); default: ! return false; } } /** *************** *** 1055,1061 **** */ static void dispatchToWindow(IXAnyEvent ev) { XBaseWindow target = XAwtState.getGrabWindow(); ! if (target == null || !isGrabbedEvent(ev)) { target = XToolkit.windowToXWindow(ev.get_window()); } if (target != null && target.checkInitialised()) { --- 1058,1064 ---- */ static void dispatchToWindow(IXAnyEvent ev) { XBaseWindow target = XAwtState.getGrabWindow(); ! if (target == null || !isGrabbedEvent(ev, target)) { target = XToolkit.windowToXWindow(ev.get_window()); } if (target != null && target.checkInitialised()) {
02-09-2005