From 36c5872e6c876e3e8dbe041681a29e82cc3b1edb Mon Sep 17 00:00:00 2001 From: Denis Fokin Date: Mon, 5 Mar 2018 20:02:52 +0300 Subject: [PATCH] Switch double modifier shortcuts to AWT event time To resolve IDEA-187234 we need to use the same logic in typeahead implementation and the ModifierKeyDoubleClickHandler state machine --- .../impl/ModifierKeyDoubleClickHandler.java | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/platform/platform-impl/src/com/intellij/openapi/keymap/impl/ModifierKeyDoubleClickHandler.java b/platform/platform-impl/src/com/intellij/openapi/keymap/impl/ModifierKeyDoubleClickHandler.java index 0cf0ad95f9c7..7be943a95bb0 100644 --- a/platform/platform-impl/src/com/intellij/openapi/keymap/impl/ModifierKeyDoubleClickHandler.java +++ b/platform/platform-impl/src/com/intellij/openapi/keymap/impl/ModifierKeyDoubleClickHandler.java @@ -11,7 +11,6 @@ import com.intellij.openapi.actionSystem.ex.AnActionListener; import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.components.ApplicationComponent; import com.intellij.openapi.diagnostic.Logger; -import com.intellij.openapi.util.Clock; import com.intellij.openapi.util.Couple; import com.intellij.openapi.util.Disposer; import com.intellij.openapi.util.SystemInfo; @@ -155,12 +154,12 @@ public class ModifierKeyDoubleClickHandler implements Disposable, ApplicationCom resetState(); return false; } - if (myActionKeyCode == -1 && ourOtherKeyWasPressed.get() && Clock.getTime() - ourLastTimePressed.get() < 100) { + if (myActionKeyCode == -1 && ourOtherKeyWasPressed.get() && keyEvent.getWhen() - ourLastTimePressed.get() < 100) { resetState(); return false; } ourOtherKeyWasPressed.set(false); - if (ourPressed.first.get() && Clock.getTime() - ourLastTimePressed.get() > 500) { + if (ourPressed.first.get() && keyEvent.getWhen() - ourLastTimePressed.get() > 500) { resetState(); } handleModifier((KeyEvent)event); @@ -174,7 +173,7 @@ public class ModifierKeyDoubleClickHandler implements Disposable, ApplicationCom } return false; } else { - ourLastTimePressed.set(Clock.getTime()); + ourLastTimePressed.set(keyEvent.getWhen()); ourOtherKeyWasPressed.set(true); if (keyCode == KeyEvent.VK_ESCAPE || keyCode == KeyEvent.VK_TAB) { ourLastTimePressed.set(0); @@ -196,7 +195,7 @@ public class ModifierKeyDoubleClickHandler implements Disposable, ApplicationCom } private void handleModifier(KeyEvent event) { - if (ourPressed.first.get() && Clock.getTime() - ourLastTimePressed.get() > 300) { + if (ourPressed.first.get() && event.getWhen() - ourLastTimePressed.get() > 300) { resetState(); return; } @@ -205,19 +204,19 @@ public class ModifierKeyDoubleClickHandler implements Disposable, ApplicationCom if (!ourPressed.first.get()) { resetState(); ourPressed.first.set(true); - ourLastTimePressed.set(Clock.getTime()); + ourLastTimePressed.set(event.getWhen()); return; } else { if (ourPressed.first.get() && ourReleased.first.get()) { ourPressed.second.set(true); - ourLastTimePressed.set(Clock.getTime()); + ourLastTimePressed.set(event.getWhen()); return; } } } else if (event.getID() == KeyEvent.KEY_RELEASED) { if (ourPressed.first.get() && !ourReleased.first.get()) { ourReleased.first.set(true); - ourLastTimePressed.set(Clock.getTime()); + ourLastTimePressed.set(event.getWhen()); return; } else if (ourPressed.first.get() && ourReleased.first.get() && ourPressed.second.get()) { resetState();