IDEA-144702 Unable to use Windows as a modifier key in keymap (registry key keymap.windows.as.meta=true by default)

This commit is contained in:
Vassiliy.Kudryashov
2016-05-25 16:56:02 +03:00
parent 99fe184928
commit 1f4eb6db3e
2 changed files with 37 additions and 0 deletions
@@ -138,6 +138,7 @@ public class IdeEventQueue extends EventQueue {
private boolean myKeyboardBusy;
private boolean myDispatchingFocusEvent;
private boolean myWinMetaPressed;
private int myInputMethodLock;
@@ -370,6 +371,9 @@ public class IdeEventQueue extends EventQueue {
e = fixNonEnglishKeyboardLayouts(e);
e = mapEvent(e);
if (Registry.is("keymap.windows.as.meta")) {
e = mapMetaState(e);
}
boolean wasInputEvent = myIsInInputEvent;
myIsInInputEvent = e instanceof InputEvent || e instanceof InputMethodEvent || e instanceof WindowEvent || e instanceof ActionEvent;
@@ -530,6 +534,38 @@ public class IdeEventQueue extends EventQueue {
return e;
}
private AWTEvent mapMetaState(AWTEvent e) {
if (myWinMetaPressed) {
Application app = ApplicationManager.getApplication();
if (app == null || !app.isActive()) {
myWinMetaPressed = false;
return e;
}
}
if (e instanceof KeyEvent) {
KeyEvent ke = (KeyEvent)e;
if (ke.getKeyCode() == KeyEvent.VK_WINDOWS) {
if (ke.getID() == KeyEvent.KEY_PRESSED) myWinMetaPressed = true;
if (ke.getID() == KeyEvent.KEY_RELEASED) myWinMetaPressed = false;
return new KeyEvent(ke.getComponent(), ke.getID(), ke.getWhen(), ke.getModifiers(), KeyEvent.VK_META, ke.getKeyChar(),
ke.getKeyLocation());
}
if (myWinMetaPressed) {
return new KeyEvent(ke.getComponent(), ke.getID(), ke.getWhen(), ke.getModifiers() | InputEvent.META_MASK, ke.getKeyCode(),
ke.getKeyChar(), ke.getKeyLocation());
}
}
if (myWinMetaPressed && e instanceof MouseEvent && ((MouseEvent)e).getButton() != 0) {
MouseEvent me = (MouseEvent)e;
return new MouseEvent(me.getComponent(), me.getID(), me.getWhen(), me.getModifiers() | InputEvent.META_MASK, me.getX(), me.getY(),
me.getClickCount(), me.isPopupTrigger(), me.getButton());
}
return e;
}
public void _dispatchEvent(@NotNull AWTEvent e, boolean typeAheadFlushing) {
if (e.getID() == MouseEvent.MOUSE_DRAGGED) {
DnDManagerImpl dndManager = (DnDManagerImpl)DnDManager.getInstance();
@@ -280,6 +280,7 @@ find.search.in.project.files=true
structureView.coalesceTime=500
keymap.show.alias.actions=false
keymap.windows.as.meta=true
frameworks.download.libraries.server.url=http://pluginsrepo-test:8080
caches.indexerThreadsCount=-1
navBar.updateMergeTime=100