don't cheat with statistics

This commit is contained in:
Konstantin Bulenkov
2011-04-08 14:58:26 +04:00
parent 189a2d6b3e
commit 98ffa87fd2
2 changed files with 13 additions and 2 deletions
@@ -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;
@@ -47,6 +47,7 @@ public final class IdeMouseEventDispatcher {
private final PresentationFactory myPresentationFactory = new PresentationFactory();
private final ArrayList<AnAction> myActions = new ArrayList<AnAction>(1);
private final Map<Container, Integer> myRootPane2BlockedId = new HashMap<Container, Integer>();
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