Bug 543747 - [Win32] JVM crash after connecting Windows Remote Desktop

Remove per-shell IMM context creation and propagation to work around
Windows bug.

Remove obsolete workaround for Bug 14656 (IME window doesn't close
on shell deactivation).

Shell.setImeInputMode effect becomes global, instead of per-shell.

Change-Id: I8a4bbb9f7f3b247bc37e7b86444d12050ff3767b
Signed-off-by: Niraj Modi <niraj.modi@in.ibm.com>
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Control.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Control.java
index e4e50d9..b319836 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Control.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Control.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2000, 2017 IBM Corporation and others.
+ * Copyright (c) 2000, 2020 IBM Corporation and others.
  * All rights reserved. This program and the accompanying materials
  * are made available under the terms of the Eclipse Public License v1.0
  * which accompanies this distribution, and is available at
@@ -720,12 +720,6 @@
 	if ((bits & OS.WS_CHILD) != 0) {
 		OS.SetWindowLongPtr (handle, OS.GWLP_ID, handle);
 	}
-	if (OS.IsDBLocale && hwndParent != 0) {
-		long /*int*/ hIMC = OS.ImmGetContext (hwndParent);
-		OS.ImmAssociateContext (handle, hIMC);
-		OS.ImmReleaseContext (hwndParent, hIMC);
-	}
-
 }
 
 void checkGesture () {
@@ -2543,9 +2537,6 @@
 @Override
 void releaseWidget () {
 	super.releaseWidget ();
-	if (OS.IsDBLocale) {
-		OS.ImmAssociateContext (handle, 0);
-	}
 	if (toolTipText != null) {
 		setToolTipText (getShell (), null);
 	}
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 6bcc71c..e1c7160 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
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2000, 2016 IBM Corporation and others.
+ * Copyright (c) 2000, 2020 IBM Corporation and others.
  * All rights reserved. This program and the accompanying materials
  * are made available under the terms of the Eclipse Public License v1.0
  * which accompanies this distribution, and is available at
@@ -120,7 +120,7 @@
 public class Shell extends Decorations {
 	Menu activeMenu;
 	ToolTip [] toolTips;
-	long /*int*/ hIMC, hwndMDIClient, lpstrTip, toolTipHandle, balloonTipHandle, menuItemToolTipHandle;
+	long /*int*/ hwndMDIClient, lpstrTip, toolTipHandle, balloonTipHandle, menuItemToolTipHandle;
 	int minWidth = SWT.DEFAULT, minHeight = SWT.DEFAULT;
 	long /*int*/ [] brushes;
 	boolean showWithParent, fullScreen, wasMaximized, modified, center;
@@ -622,10 +622,6 @@
 		int flags = OS.SWP_DRAWFRAME | OS.SWP_NOMOVE | OS.SWP_NOSIZE | OS.SWP_NOZORDER | OS.SWP_NOACTIVATE;
 		OS.SetWindowPos (handle, 0, 0, 0, 0, 0, flags);
 	}
-	if (OS.IsDBLocale) {
-		hIMC = OS.ImmCreateContext ();
-		if (hIMC != 0) OS.ImmAssociateContext (handle, hIMC);
-	}
 }
 
 void createMenuItemToolTipHandle() {
@@ -1363,9 +1359,6 @@
 	}
 	lpstrTip = 0;
 	toolTipHandle = balloonTipHandle = menuItemToolTipHandle = 0;
-	if (OS.IsDBLocale) {
-		if (hIMC != 0) OS.ImmDestroyContext (hIMC);
-	}
 	lastActive = null;
 	toolTitle = balloonTitle = null;
 }
@@ -2183,18 +2176,6 @@
 
 @Override
 LRESULT WM_ACTIVATE (long /*int*/ wParam, long /*int*/ lParam) {
-	/*
-	* Bug in Windows XP.  When a Shell is deactivated, the
-	* IME composition window does not go away. This causes
-	* repaint issues.  The fix is to commit the composition
-	* string.
-	*/
-	if (OS.LOWORD (wParam) == 0 && OS.IsDBLocale && hIMC != 0) {
-		if (OS.ImmGetOpenStatus (hIMC)) {
-			OS.ImmNotifyIME (hIMC, OS.NI_COMPOSITIONSTR, OS.CPS_COMPLETE, 0);
-		}
-	}
-
 	/* Process WM_ACTIVATE */
 	LRESULT result = super.WM_ACTIVATE (wParam, lParam);
 	if (OS.LOWORD (wParam) == 0) {
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Spinner.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Spinner.java
index 8dac399..ce2dd8d 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Spinner.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Spinner.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2000, 2012 IBM Corporation and others.
+ * Copyright (c) 2000, 2020 IBM Corporation and others.
  * All rights reserved. This program and the accompanying materials
  * are made available under the terms of the Eclipse Public License v1.0
  * which accompanies this distribution, and is available at
@@ -12,9 +12,9 @@
 
 
 import org.eclipse.swt.*;
-import org.eclipse.swt.internal.win32.*;
-import org.eclipse.swt.graphics.*;
 import org.eclipse.swt.events.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.internal.win32.*;
 
 /**
  * Instances of this class are selectable user interface
@@ -184,12 +184,6 @@
 	int flags = OS.SWP_NOSIZE | OS.SWP_NOMOVE | OS.SWP_NOACTIVATE;
 	OS.SetWindowPos (hwndText, hwndUpDown, 0, 0, 0, 0, flags);
 	OS.SetWindowLongPtr (hwndUpDown, OS.GWLP_ID, hwndUpDown);
-	if (OS.IsDBLocale) {
-		long /*int*/ hIMC = OS.ImmGetContext (handle);
-		OS.ImmAssociateContext (hwndText, hIMC);
-		OS.ImmAssociateContext (hwndUpDown, hIMC);
-		OS.ImmReleaseContext (handle, hIMC);
-	}
 	OS.SendMessage (hwndUpDown, OS.UDM_SETRANGE32, 0, 100);
 	OS.SendMessage (hwndUpDown, OS.UDM_SETPOS32, 0, 0);
 	pageIncrement = 10;
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Tree.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Tree.java
index eac9e36..b3a51f4 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Tree.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Tree.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2000, 2017 IBM Corporation and others.
+ * Copyright (c) 2000, 2020 IBM Corporation and others.
  * All rights reserved. This program and the accompanying materials
  * are made available under the terms of the Eclipse Public License v1.0
  * which accompanies this distribution, and is available at
@@ -2263,12 +2263,6 @@
 		null);
 	if (hwndHeader == 0) error (SWT.ERROR_NO_HANDLES);
 	OS.SetWindowLongPtr (hwndHeader, OS.GWLP_ID, hwndHeader);
-	if (OS.IsDBLocale) {
-		long /*int*/ hIMC = OS.ImmGetContext (handle);
-		OS.ImmAssociateContext (hwndParent, hIMC);
-		OS.ImmAssociateContext (hwndHeader, hIMC);
-		OS.ImmReleaseContext (handle, hIMC);
-	}
 	//This code is intentionally commented
 //	if (!OS.IsPPC) {
 //		if ((style & SWT.BORDER) != 0) {