From 136459d1f0ba88f7ae1ad409c3250de0ca16f5b8 Mon Sep 17 00:00:00 2001 From: Peter Gromov Date: Fri, 20 Mar 2020 19:31:22 +0100 Subject: [PATCH] less expensive native calls to hide cursor during typing on Mac for IDEA-233084 GitOrigin-RevId: 58e5cba1073f040f9bc7c96ae06aa2175f08cfcd --- .../openapi/editor/ex/util/EditorUIUtil.java | 7 +------ .../keymap/impl/IdeKeyEventDispatcher.java | 15 ++++++++------- 2 files changed, 9 insertions(+), 13 deletions(-) diff --git a/platform/platform-impl/src/com/intellij/openapi/editor/ex/util/EditorUIUtil.java b/platform/platform-impl/src/com/intellij/openapi/editor/ex/util/EditorUIUtil.java index 70946a741385..7014831ad0bb 100644 --- a/platform/platform-impl/src/com/intellij/openapi/editor/ex/util/EditorUIUtil.java +++ b/platform/platform-impl/src/com/intellij/openapi/editor/ex/util/EditorUIUtil.java @@ -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(); } } diff --git a/platform/platform-impl/src/com/intellij/openapi/keymap/impl/IdeKeyEventDispatcher.java b/platform/platform-impl/src/com/intellij/openapi/keymap/impl/IdeKeyEventDispatcher.java index 40acc1cab612..7a26ed04ccf6 100644 --- a/platform/platform-impl/src/com/intellij/openapi/keymap/impl/IdeKeyEventDispatcher.java +++ b/platform/platform-impl/src/com/intellij/openapi/keymap/impl/IdeKeyEventDispatcher.java @@ -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(); }