less expensive native calls to hide cursor during typing on Mac for IDEA-233084

GitOrigin-RevId: 58e5cba1073f040f9bc7c96ae06aa2175f08cfcd
This commit is contained in:
Peter Gromov
2020-03-20 18:47:31 +00:00
committed by intellij-monorepo-bot
parent 2540e9cc23
commit 136459d1f0
2 changed files with 9 additions and 13 deletions
@@ -5,8 +5,6 @@ import com.intellij.ide.ui.AntialiasingType;
import com.intellij.ide.ui.UISettings;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.editor.impl.EditorImpl;
import com.intellij.openapi.util.SystemInfo;
import com.intellij.util.ui.MacUIUtil;
import com.intellij.util.ui.UIUtil;
import java.awt.*;
@@ -32,10 +30,7 @@ public class EditorUIUtil {
}
public static void hideCursorInEditor(Editor editor) {
if (SystemInfo.isMac) {
MacUIUtil.hideCursor();
}
else if (editor instanceof EditorImpl) {
if (editor instanceof EditorImpl) {
((EditorImpl)editor).hideCursor();
}
}
@@ -139,8 +139,9 @@ public final class IdeKeyEventDispatcher implements Disposable {
return false;
}
int id = e.getID();
if (myIgnoreNextKeyTypedEvent) {
if (KeyEvent.KEY_TYPED == e.getID()) return true;
if (KeyEvent.KEY_TYPED == id) return true;
myIgnoreNextKeyTypedEvent = false;
}
@@ -150,18 +151,18 @@ public final class IdeKeyEventDispatcher implements Disposable {
// http://www.jetbrains.net/jira/browse/IDEADEV-12372
if (e.getKeyCode() == KeyEvent.VK_CONTROL) {
if (e.getID() == KeyEvent.KEY_PRESSED) {
if (id == KeyEvent.KEY_PRESSED) {
myLeftCtrlPressed = e.getKeyLocation() == KeyEvent.KEY_LOCATION_LEFT;
}
else if (e.getID() == KeyEvent.KEY_RELEASED) {
else if (id == KeyEvent.KEY_RELEASED) {
myLeftCtrlPressed = false;
}
}
else if (e.getKeyCode() == KeyEvent.VK_ALT) {
if (e.getID() == KeyEvent.KEY_PRESSED) {
if (id == KeyEvent.KEY_PRESSED) {
myRightAltPressed = e.getKeyLocation() == KeyEvent.KEY_LOCATION_RIGHT;
}
else if (e.getID() == KeyEvent.KEY_RELEASED) {
else if (id == KeyEvent.KEY_RELEASED) {
myRightAltPressed = false;
}
}
@@ -172,10 +173,10 @@ public final class IdeKeyEventDispatcher implements Disposable {
// shortcuts should not work in shortcut setup fields
if (focusOwner instanceof ShortcutTextField) {
// remove AltGr modifier to show a shortcut without AltGr in Settings
if (JAVA11_ON_WINDOWS && KeyEvent.KEY_PRESSED == e.getID()) removeAltGraph(e);
if (JAVA11_ON_WINDOWS && KeyEvent.KEY_PRESSED == id) removeAltGraph(e);
return false;
}
if (focusOwner instanceof JTextComponent && ((JTextComponent)focusOwner).isEditable()) {
if (id == KeyEvent.KEY_PRESSED && focusOwner instanceof JTextComponent && ((JTextComponent)focusOwner).isEditable()) {
if (e.getKeyChar() != KeyEvent.CHAR_UNDEFINED && e.getKeyCode() != KeyEvent.VK_ESCAPE) {
MacUIUtil.hideCursor();
}