JRE-981 IM workaround does not work anymore

forward port of 2d7c29b in JetBrains/jdk8u_jdk

(cherry picked from commit f3ccc53e02)
This commit is contained in:
Anton Tarasov
2018-11-06 22:05:12 +03:00
committed by alexey.ushakov@jetbrains.com
parent a89a3b33c7
commit 9beeab2f34

View File

@@ -380,14 +380,6 @@ public class CInputMethod extends InputMethodAdapter {
fAwtFocussedComponentPeer = null;
}
private boolean isValid() {
return fIMContext != null &&
fAwtFocussedComponent != null &&
fAwtFocussedComponentPeer != null &&
fCurrentText != null &&
fCurrentTextAsString != null;
}
/**
* Returns a control object from this input method, or null. A
* control object provides methods that control the behavior of the
@@ -607,7 +599,7 @@ public class CInputMethod extends InputMethodAdapter {
final String[] retString = new String[1];
try {
if (isValid())
if (fIMContext != null)
LWCToolkit.invokeAndWait(new Runnable() {
public void run() { synchronized(retString) {
int location = locationIn;
@@ -660,7 +652,7 @@ public class CInputMethod extends InputMethodAdapter {
final int[] returnValue = new int[2];
try {
if (isValid())
if (fIMContext != null)
LWCToolkit.invokeAndWait(new Runnable() {
public void run() { synchronized(returnValue) {
AttributedCharacterIterator theIterator = fIMContext.getSelectedText(null);
@@ -736,7 +728,7 @@ public class CInputMethod extends InputMethodAdapter {
final int[] rect = new int[4];
try {
if (isValid())
if (fIMContext != null)
LWCToolkit.invokeAndWait(new Runnable() {
public void run() { synchronized(rect) {
int insertOffset = fIMContext.getInsertPositionOffset();
@@ -755,7 +747,7 @@ public class CInputMethod extends InputMethodAdapter {
if (composedTextOffset > 0 && (fAwtFocussedComponent instanceof JTextComponent)) {
Rectangle r2 = fIMContext.getTextLocation(TextHitInfo.beforeOffset(0));
if (r.equals(r2)) {
if (r.equals(r2) && fCurrentTextAsString != null) {
// FIXME: (SAK) If the candidate text wraps over two lines, this calculation pushes the candidate
// window off the right edge of the component.
String inProgressSubstring = fCurrentTextAsString.substring(0, composedTextOffset);
@@ -781,7 +773,7 @@ public class CInputMethod extends InputMethodAdapter {
final int[] insertPositionOffset = new int[1];
try {
if (isValid())
if (fIMContext != null)
LWCToolkit.invokeAndWait(new Runnable() {
public void run() { synchronized(offsetInfo) {
offsetInfo[0] = fIMContext.getLocationOffset(screenX, screenY);