Bug 435799 - [GTK3] Display#getActiveShell() is null while context menu
is shown

Change-Id: I9e77cb0ac809d6a9900c56cb565e0b5de3d08bf2
Signed-off-by: Arun Thondapu <arunkumar.thondapu@in.ibm.com>
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Menu.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Menu.java
index 177b676..caeace7 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Menu.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Menu.java
@@ -646,7 +646,10 @@
 @Override
 long /*int*/ gtk_hide (long /*int*/ widget) {
 	if ((style & SWT.POP_UP) != 0) {
-		if (display.activeShell != null) display.activeShell = getShell ();
+		if (display.activeShell != null) {
+			display.activeShell = getShell ();
+			display.activeShell.ignoreFocusOut = false;
+		}
 	}
 	sendEvent (SWT.Hide);
 	if (OS.ubuntu_menu_proxy_get() != 0) {
@@ -662,7 +665,10 @@
 @Override
 long /*int*/ gtk_show (long /*int*/ widget) {
 	if ((style & SWT.POP_UP) != 0) {
-		if (display.activeShell != null) display.activeShell = getShell ();
+		if (display.activeShell != null) {
+			display.activeShell = getShell ();
+			display.activeShell.ignoreFocusOut = true;
+		}
 		return 0;
 	} 
 	sendEvent (SWT.Show);
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Shell.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Shell.java
index d4acc11..bca5915 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Shell.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Shell.java
@@ -124,6 +124,7 @@
 	int minWidth, minHeight;
 	Control lastActive;
 	ToolTip [] toolTips;
+	boolean ignoreFocusOut;
 
 	static final int MAXIMUM_TRIM = 128;
 	static final int BORDER = 3;
@@ -1354,7 +1355,7 @@
 	Display display = this.display;
 	sendEvent (SWT.Deactivate);
 	setActiveControl (null);
-	if (display.activeShell == this) {
+	if (display.activeShell == this && !ignoreFocusOut) {
 		display.activeShell = null;
 		display.activePending = false;
 	}