Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 312371

Summary: [Widgets] [SWT/Carbon]SWT.MouseExit event being generated when it should not be.
Product: [Eclipse Project] Platform Reporter: alf <lihedl>
Component: SWTAssignee: Silenio Quarti <Silenio_Quarti>
Status: RESOLVED FIXED QA Contact: Silenio Quarti <Silenio_Quarti>
Severity: normal    
Priority: P3 CC: eclipse.felipe, linyunz, lshanmug, raji
Version: 3.5.2Flags: eclipse.felipe: review+
Target Milestone: 3.6.1   
Hardware: PC   
OS: Mac OS X - Carbon (unsup.)   
Whiteboard:
Attachments:
Description Flags
example source code
none
patch for 3.5.2 and HEAD (after 3.6 ships) none

Description alf CLA 2010-05-11 02:00:08 EDT
Build Identifier: 20090920-1017

MouseExit event is being thrown on the first drag attempt when it should not be.
In general, a MouseExit event will issue when you drag mouce outside out the widget and mouse left key up. But in this case, on the first drag, MouseExit event issue before your mouse left key up.
This bug is tested in swt-carbon 3.5.2. And in swt-cocoa 3.5.2, this bug disappear.

Reproducible: Always

Steps to Reproduce:
1.Run source code. A shell will display.
2.Click down mouse left key inside the blue area, and holding down, darg the mouse outside of the blue area. In this process, mouce left key still hold down.
3.Notice "exit" printed to stdout, showing that a MouseExit event was thrown when it should not be.
Comment 1 alf CLA 2010-05-11 02:03:43 EDT
Created attachment 167865 [details]
example source code
Comment 2 alf CLA 2010-05-11 02:05:21 EDT
source code:
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.GC;
import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Canvas;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;


public class DragSametiemTest {
	public static void main (String [] args) {
		Display display = new Display ();
		Shell shell = new Shell(display);
		shell=new Shell(display, SWT.SHELL_TRIM);
		GridLayout gl = new GridLayout(1, false);
		gl.marginHeight=0;
		gl.marginWidth=0;
		shell.setLayout(gl);
		
		
		Composite _chatAreaCmp = new Composite(shell, SWT.NONE);
		_chatAreaCmp.setLayoutData(new GridData(GridData.FILL_BOTH));
		_chatAreaCmp.setLayout(gl);
		
		Text browser = new Text(_chatAreaCmp, SWT.NONE);
		
		browser.setText("top text");
		browser.setLayoutData(new GridData(GridData.FILL_BOTH));

		MyComp _chatAreaView = new MyComp(_chatAreaCmp, SWT.DOWN);
		_chatAreaView.setLayout(gl);
		_chatAreaView.setLayoutData(new GridData(GridData.FILL_BOTH));
		
		
		shell.setSize(250, 300);
		shell.layout();
		shell.open();
		while (!shell.isDisposed ()) {
			if (!display.readAndDispatch ()) display.sleep ();
		}
		display.dispose ();
	}
	static class MyComp extends Composite {

		public MyComp(Composite parent, int style) {
			super(parent, style);
			
			Canvas canvas = new Canvas(this, style);
	        Listener listener = new Listener() {
	            public void handleEvent(Event event) {
	                switch (event.type) {
		                case SWT.Paint:
		    		        GC gc = event.gc;
		    		        Rectangle rect = getClientArea();
		    		        gc.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_BLUE));
		    		        gc.fillRectangle(rect.x, rect.y, rect.width, rect.height);
		                	break;
		                case SWT.MouseExit:
		    		    	System.out.println("exit"); break;
	                }
	            }
	        };
	        canvas.setLayoutData(new GridData(GridData.FILL_BOTH));
	        
	        int[] events = new int[] {SWT.Paint,SWT.KeyDown, SWT.MouseExit };
	        for (int i = 0; i < events.length; i++) {
	        	canvas.addListener(events[i], listener);
	        }
		}
	}
}
Comment 3 Lakshmi P Shanmugam CLA 2010-05-11 11:22:51 EDT
Happens only with the first drag.
Comment 4 Silenio Quarti CLA 2010-05-26 17:01:23 EDT
Created attachment 170102 [details]
patch for 3.5.2 and HEAD (after 3.6 ships)
Comment 5 Raji Akella CLA 2010-05-26 18:11:50 EDT
Thanks
Comment 6 Raji Akella CLA 2010-08-05 19:29:46 EDT
Silenio, will this be included in 3.6.1? (we are moving XPD up to 3.6.1 shortly)
Comment 7 Silenio Quarti CLA 2010-08-06 12:09:36 EDT
Fix has been released to HEAD.

Felipe, please review for 3.6.1.
Comment 8 Silenio Quarti CLA 2010-08-06 14:50:03 EDT
Fix released to R3_6_maintenance and HEAD