From dd740ecb1dc8383a3c3a39d68684b87b1da51611 Mon Sep 17 00:00:00 2001 From: Roman Shevchenko Date: Fri, 5 Jul 2013 15:35:50 +0200 Subject: [PATCH] Cleanup (method extracted; dead code dropped) --- .../src/com/intellij/ide/IdeEventQueue.java | 46 +++++++------------ 1 file changed, 17 insertions(+), 29 deletions(-) diff --git a/platform/platform-impl/src/com/intellij/ide/IdeEventQueue.java b/platform/platform-impl/src/com/intellij/ide/IdeEventQueue.java index ce9f67b30cca..8004e5e6b71d 100644 --- a/platform/platform-impl/src/com/intellij/ide/IdeEventQueue.java +++ b/platform/platform-impl/src/com/intellij/ide/IdeEventQueue.java @@ -52,7 +52,6 @@ import java.awt.*; import java.awt.event.*; import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; -import java.lang.reflect.Field; import java.lang.reflect.Method; import java.util.*; import java.util.List; @@ -322,20 +321,8 @@ public class IdeEventQueue extends EventQueue { @Override public void dispatchEvent(AWTEvent e) { - if (SystemInfo.isXWindow && e instanceof MouseEvent && ((MouseEvent)e).getButton() > 3) { - MouseEvent src = (MouseEvent)e; - if (src.getButton() < 6) {//Convert these events(buttons 4&5 in are produced by touchpad, they must be converted to horizontal scrolling events - e = new MouseWheelEvent(src.getComponent(), src.getID(), src.getWhen(), - src.getModifiers() | InputEvent.SHIFT_DOWN_MASK, src.getX(), src.getY(), - 0, false, MouseWheelEvent.WHEEL_UNIT_SCROLL, src.getClickCount(), src.getButton() == 4 ? -1 : 1); - } - else { - //Here we "shift" events with buttons 6 and 7 to similar events with buttons 4 and 5 - //See java.awt.InputEvent#BUTTON_DOWN_MASK, 1<<14 is 4th physical button, 1<<15 is 5th. - e = new MouseEvent(src.getComponent(), src.getID(), src.getWhen(), src.getModifiers() | (1 << 8 + src.getButton()), - src.getX(), src.getY(), 1, src.isPopupTrigger(), src.getButton() - 2); - } - } + e = mapEvent(e); + boolean wasInputEvent = myIsInInputEvent; myIsInInputEvent = e instanceof InputEvent || e instanceof InputMethodEvent || e instanceof WindowEvent || e instanceof ActionEvent; AWTEvent oldEvent = myCurrentEvent; @@ -363,25 +350,26 @@ public class IdeEventQueue extends EventQueue { } } - @SuppressWarnings({"ALL"}) - private static String toDebugString(final AWTEvent e) { - if (e instanceof InvocationEvent) { - try { - final Field f = InvocationEvent.class.getDeclaredField("runnable"); - f.setAccessible(true); - Object runnable = f.get(e); - - return "Invoke Later[" + runnable.toString() + "]"; + private static AWTEvent mapEvent(AWTEvent e) { + if (SystemInfo.isXWindow && e instanceof MouseEvent && ((MouseEvent)e).getButton() > 3) { + MouseEvent src = (MouseEvent)e; + if (src.getButton() < 6) { + // Convert these events(buttons 4&5 in are produced by touchpad, they must be converted to horizontal scrolling events + e = new MouseWheelEvent(src.getComponent(), src.getID(), src.getWhen(), + src.getModifiers() | InputEvent.SHIFT_DOWN_MASK, src.getX(), src.getY(), + 0, false, MouseWheelEvent.WHEEL_UNIT_SCROLL, src.getClickCount(), src.getButton() == 4 ? -1 : 1); } - catch (NoSuchFieldException e1) { - } - catch (IllegalAccessException e1) { + else { + // Here we "shift" events with buttons 6 and 7 to similar events with buttons 4 and 5 + // See java.awt.InputEvent#BUTTON_DOWN_MASK, 1<<14 is 4th physical button, 1<<15 is 5th. + //noinspection MagicConstant + e = new MouseEvent(src.getComponent(), src.getID(), src.getWhen(), src.getModifiers() | (1 << 8 + src.getButton()), + src.getX(), src.getY(), 1, src.isPopupTrigger(), src.getButton() - 2); } } - return e.toString(); + return e; } - public void _dispatchEvent(@NotNull AWTEvent e, boolean typeAheadFlushing) { if (e.getID() == MouseEvent.MOUSE_DRAGGED) { DnDManagerImpl dndManager = (DnDManagerImpl)DnDManager.getInstance();