diff options
Diffstat (limited to 'platform/platform-impl/src/com/intellij/openapi/keymap/impl/IdeKeyEventDispatcher.java')
-rw-r--r-- | platform/platform-impl/src/com/intellij/openapi/keymap/impl/IdeKeyEventDispatcher.java | 37 |
1 files changed, 36 insertions, 1 deletions
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 34be36b69435..9a566e9915ef 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 @@ -314,6 +314,30 @@ public final class IdeKeyEventDispatcher implements Disposable { } } + private static KeyStroke getKeyStrokeWithoutCtrlModifier(KeyStroke originalKeyStroke){ + int modifier=originalKeyStroke.getModifiers()&~InputEvent.CTRL_MASK&~InputEvent.CTRL_DOWN_MASK; + try { + Method[] methods=AWTKeyStroke.class.getDeclaredMethods(); + Method getCachedStrokeMethod=null; + for (Method method : methods) { + if (GET_CACHED_STROKE_METHOD_NAME.equals(method.getName())) { + getCachedStrokeMethod = method; + getCachedStrokeMethod.setAccessible(true); + break; + } + } + if(getCachedStrokeMethod==null){ + throw new IllegalStateException("not found method with name getCachedStrokeMethod"); + } + Object[] getCachedStrokeMethodArgs= + {originalKeyStroke.getKeyChar(), originalKeyStroke.getKeyCode(), modifier, originalKeyStroke.isOnKeyRelease()}; + return (KeyStroke)getCachedStrokeMethod.invoke(originalKeyStroke, getCachedStrokeMethodArgs); + } + catch(Exception exc){ + throw new IllegalStateException(exc.getMessage()); + } + } + private boolean inSecondStrokeInProgressState() { KeyEvent e = myContext.getInputEvent(); @@ -396,6 +420,15 @@ public final class IdeKeyEventDispatcher implements Disposable { KeyStroke originalKeyStroke=KeyStroke.getKeyStrokeForEvent(e); KeyStroke keyStroke=getKeyStrokeWithoutMouseModifiers(originalKeyStroke); + + + if (Registry.is("fix.jdk7.alt.shortcuts") && SystemInfo.isMac && SystemInfo.isOracleJvm && (keyStroke.getModifiers() & InputEvent.ALT_MASK) == InputEvent.ALT_MASK) + { + if (KeymapManager.getInstance().getActiveKeymap().getActionIds(new KeyboardShortcut(keyStroke, null)).length == 0) { + keyStroke = getKeyStrokeWithoutCtrlModifier(keyStroke); + } + } + if (myKeyGestureProcessor.processInitState()) { return true; } @@ -601,7 +634,9 @@ public final class IdeKeyEventDispatcher implements Disposable { processor.onUpdatePassed(e, action, actionEvent); - ((DataManagerImpl.MyDataContext)myContext.getDataContext()).setEventCount(IdeEventQueue.getInstance().getEventCount(), this); + if (myContext.getDataContext() instanceof DataManagerImpl.MyDataContext) { // this is not true for test data contexts + ((DataManagerImpl.MyDataContext)myContext.getDataContext()).setEventCount(IdeEventQueue.getInstance().getEventCount(), this); + } actionManager.fireBeforeActionPerformed(action, actionEvent.getDataContext(), actionEvent); Component component = PlatformDataKeys.CONTEXT_COMPONENT.getData(actionEvent.getDataContext()); if (component != null && !component.isShowing()) { |