Bug 376011 - [accessibility] Eclipse 4.2 tab traversal needs refining
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/OS.java b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/OS.java
index 4d7e967..b2f8cdd 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/OS.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/OS.java
@@ -2076,6 +2076,7 @@
 	public static final int VT_LPWSTR = 31;
 	public static final short VARIANT_TRUE = -1;
 	public static final short VARIANT_FALSE = 0;
+	public static final short WA_CLICKACTIVE = 2;
 	public static final String WC_HEADER = "SysHeader32"; //$NON-NLS-1$
 	public static final String WC_LINK = "SysLink"; //$NON-NLS-1$
 	public static final String WC_LISTVIEW = "SysListView32"; //$NON-NLS-1$
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Decorations.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Decorations.java
index 14e1ac5..60fdbe6 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Decorations.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Decorations.java
@@ -1650,7 +1650,8 @@
 			return LRESULT.ZERO;
 		}
 	}
-	if (OS.LOWORD (wParam) != 0) {
+	int loWord = OS.LOWORD (wParam);
+	if (loWord != 0) {
 		/*
 		* When the high word of wParam is non-zero, the activation
 		* state of the window is being changed while the window is
@@ -1661,7 +1662,9 @@
 		Control control = display.findControl (lParam);
 		if (control == null || control instanceof Shell) {
 			if (this instanceof Shell) {
-				sendEvent (SWT.Activate);
+				Event event = new Event ();
+				event.detail = loWord == OS.WA_CLICKACTIVE ? SWT.MouseDown : SWT.None;
+				sendEvent (SWT.Activate, event);
 				if (isDisposed ()) return LRESULT.ZERO;
 			}
 		}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Shell.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Shell.java
index 976fab4..c0532c7 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Shell.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Shell.java
@@ -1413,6 +1413,10 @@
 }
 
 void setActiveControl (Control control) {
+	setActiveControl (control, SWT.None);
+}
+
+void setActiveControl (Control control, int type) {
 	if (control != null && control.isDisposed ()) control = null;
 	if (lastActive != null && lastActive.isDisposed ()) lastActive = null;
 	if (lastActive == control) return;
@@ -1444,7 +1448,9 @@
 	}
 	for (int i=activate.length-1; i>=index; --i) {
 		if (!activate [i].isDisposed ()) {
-			activate [i].sendEvent (SWT.Activate);
+			Event event = new Event ();
+			event.detail = type;
+			activate [i].sendEvent (SWT.Activate, event);
 		}
 	}
 }
@@ -2325,7 +2331,7 @@
 	}
 	
 	long /*int*/ code = callWindowProc (handle, OS.WM_MOUSEACTIVATE, wParam, lParam);
-	setActiveControl (control);
+	setActiveControl (control, SWT.MouseDown);
 	return new LRESULT (code);
 }