Bug 394016 - Ctrl+PageDown doesn't work multiple times in Classic theme
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/CTabFolder.java b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/CTabFolder.java
index 0907b1b..7d91d1d 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/CTabFolder.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/CTabFolder.java
@@ -760,7 +760,7 @@
 }
 ToolBar getChevron() {
 	if (chevronTb == null) {
-		chevronTb = new ToolBar(this, SWT.FLAT | SWT.NO_FOCUS);
+		chevronTb = new ToolBar(this, SWT.FLAT);
 		initAccessibleChevronTb();
 		addTabControl(chevronTb, SWT.TRAIL, -1, false);
 	}
@@ -2366,7 +2366,7 @@
 	Display display = getDisplay();
 	if (showMax) {
 		if (minMaxTb == null) {
-			minMaxTb = new ToolBar(this, SWT.FLAT | SWT.NO_FOCUS);
+			minMaxTb = new ToolBar(this, SWT.FLAT);
 			initAccessibleMinMaxTb();
 			addTabControl(minMaxTb, SWT.TRAIL, 0, false);
 		}
@@ -2389,7 +2389,7 @@
 	// min button
 	if (showMin) {
 		if (minMaxTb == null) {
-			minMaxTb = new ToolBar(this, SWT.FLAT | SWT.NO_FOCUS);
+			minMaxTb = new ToolBar(this, SWT.FLAT);
 			initAccessibleMinMaxTb();
 			addTabControl(minMaxTb, SWT.TRAIL, 0, false);
 		}
@@ -2481,6 +2481,35 @@
 	controlRects = rects;
 	if (changed || hovering) updateBkImages();
 }
+public boolean setFocus () {
+	checkWidget ();
+	
+	/*
+	* Feature in SWT.  When a new tab item is selected
+	* and the previous tab item had focus, removing focus
+	* from the previous tab item causes fixFocus() to give
+	* focus to the first child, which is usually one of the
+	* toolbars. This is unexpected.
+	* The fix is to try to set focus on the first tab item
+	* if fixFocus() is called.
+	*/
+	Control focusControl = getDisplay().getFocusControl ();
+	boolean fixFocus = isAncestor (focusControl);
+	if (fixFocus) {
+		CTabItem item = getSelection();
+		if (item != null) {
+			if (item.setFocus ()) return true;
+		}
+	}
+	return super.setFocus ();
+}
+/* Copy of isFocusAncestor from Control. */
+boolean isAncestor (Control control) {
+	while (control != null && control != this && !(control instanceof Shell)) {
+		control = control.getParent();
+	}
+	return control == this;
+}
 public void setFont(Font font) {
 	checkWidget();
 	if (font != null && font.equals(getFont())) return;
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/CTabItem.java b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/CTabItem.java
index c3f465e..f8e2405 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/CTabItem.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/CTabItem.java
@@ -325,6 +325,9 @@
 	}
 	this.disabledImage = image;
 }
+boolean setFocus () {
+	return control != null && !control.isDisposed() && control.setFocus ();
+}
 /**
  * Sets the font that the receiver will use to paint textual information
  * for this item to the font specified by the argument, or to the default font