From 98ffa87fd20877b39d8e8988b091d0118aa2d025 Mon Sep 17 00:00:00 2001 From: Konstantin Bulenkov Date: Fri, 8 Apr 2011 14:43:39 +0400 Subject: [PATCH] don't cheat with statistics --- .../src/com/intellij/ide/IdeEventQueue.java | 3 +++ .../openapi/keymap/impl/IdeMouseEventDispatcher.java | 12 ++++++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/platform/platform-impl/src/com/intellij/ide/IdeEventQueue.java b/platform/platform-impl/src/com/intellij/ide/IdeEventQueue.java index f222cd4772cd..8c5f4f3a1449 100644 --- a/platform/platform-impl/src/com/intellij/ide/IdeEventQueue.java +++ b/platform/platform-impl/src/com/intellij/ide/IdeEventQueue.java @@ -434,6 +434,9 @@ public class IdeEventQueue extends EventQueue { if (e instanceof KeyEvent) { myKeyboardBusy = e.getID() != KeyEvent.KEY_RELEASED || ((KeyEvent)e).getModifiers() != 0; + if (e.getID() == KeyEvent.KEY_RELEASED && ((KeyEvent)e).getKeyCode() == KeyEvent.VK_SHIFT) { + myMouseEventDispatcher.resetHorScrollingTracker(); + } } if (!typeaheadFlushing && typeAheadDispatchToFocusManager(e)) return; diff --git a/platform/platform-impl/src/com/intellij/openapi/keymap/impl/IdeMouseEventDispatcher.java b/platform/platform-impl/src/com/intellij/openapi/keymap/impl/IdeMouseEventDispatcher.java index 8626acdb780c..2d9d3f65a19d 100644 --- a/platform/platform-impl/src/com/intellij/openapi/keymap/impl/IdeMouseEventDispatcher.java +++ b/platform/platform-impl/src/com/intellij/openapi/keymap/impl/IdeMouseEventDispatcher.java @@ -47,6 +47,7 @@ public final class IdeMouseEventDispatcher { private final PresentationFactory myPresentationFactory = new PresentationFactory(); private final ArrayList myActions = new ArrayList(1); private final Map myRootPane2BlockedId = new HashMap(); + private int myLastHorScrolledComponentHash = 0; public IdeMouseEventDispatcher() { } @@ -187,16 +188,23 @@ public final class IdeMouseEventDispatcher { return false; } - private static boolean doHorizontalScrolling(Component c, MouseWheelEvent me) { - FeatureUsageTracker.getInstance().triggerFeatureUsed("ui.horizontal.scrolling"); + private boolean doHorizontalScrolling(Component c, MouseWheelEvent me) { final JScrollBar scrollBar = findHorizontalScrollBar(c); if (scrollBar != null) { + if (scrollBar.hashCode() != myLastHorScrolledComponentHash) { + FeatureUsageTracker.getInstance().triggerFeatureUsed("ui.horizontal.scrolling"); + myLastHorScrolledComponentHash = scrollBar.hashCode(); + } scrollBar.setValue(scrollBar.getValue() + getScrollAmount(c, me, scrollBar)); return true; } return false; } + public void resetHorScrollingTracker() { + myLastHorScrolledComponentHash = 0; + } + private static int getScrollAmount(Component c, MouseWheelEvent me, JScrollBar scrollBar) { final int ratio = Registry.is("ide.smart.horizontal.scrolling") ? Math.max((int)Math.pow(c.getWidth() / scrollBar.getWidth() , 2), 10) : 10; // do annoying scrolling faster if smart scrolling is on