From 6c4e08a8a83a0173c3ce92d02a5b25ae45dc07c9 Mon Sep 17 00:00:00 2001 From: Sergey Simonchik Date: Mon, 22 Mar 2021 13:50:55 +0300 Subject: [PATCH] terminal: simplify scrolling - now default TerminalPanel.handleMouseWheelEvent implementation works (IDEA-264105) GitOrigin-RevId: f5acd70f31c5cf8b411a3ebfa3ce9f95281c69ad --- .../intellij/terminal/JBTerminalPanel.java | 51 ------------------- 1 file changed, 51 deletions(-) diff --git a/platform/platform-impl/src/com/intellij/terminal/JBTerminalPanel.java b/platform/platform-impl/src/com/intellij/terminal/JBTerminalPanel.java index 82c93b1e2885..9c439750c580 100644 --- a/platform/platform-impl/src/com/intellij/terminal/JBTerminalPanel.java +++ b/platform/platform-impl/src/com/intellij/terminal/JBTerminalPanel.java @@ -20,9 +20,6 @@ import com.intellij.openapi.project.Project; import com.intellij.openapi.util.Disposer; import com.intellij.openapi.util.registry.Registry; import com.intellij.openapi.wm.ToolWindow; -import com.intellij.ui.components.JBScrollBar; -import com.intellij.ui.scale.JBUIScale; -import com.intellij.ui.scroll.TouchScrollUtil; import com.intellij.util.JBHiDPIScaledImage; import com.intellij.util.ui.ImageUtil; import com.intellij.util.ui.JBUI; @@ -132,54 +129,6 @@ public class JBTerminalPanel extends TerminalPanel implements FocusListener, Dis return JBUI.emptySize(); } - @Override - protected void handleMouseWheelEvent(@NotNull MouseWheelEvent event, @NotNull JScrollBar scrollBar) { - // TODO replace with standard JBScrollPane in 2021.2 and remove this method! - if (event.isShiftDown() || event.getUnitsToScroll() == 0) return; - if (isNiceScrollingSupported(event)) { - MouseWheelEvent e = event; - if (Registry.is("idea.true.smooth.scrolling.pixel.perfect", true)) { - // Terminal's scrollBar.getModel() operates with lines, not pixel. So we need to covert back to units - // according to com.intellij.ui.components.JBScrollBar.getPreciseDelta implementation. - e = copyEventWithScaledRotation(event, JBUIScale.scale(10)); - } - boolean handled = ((JBScrollBar)scrollBar).handleMouseWheelEvent(e); - if (!handled && LOG.isDebugEnabled()) { - LOG.debug("Mouse wheel event not handled"); - } - } - else { - super.handleMouseWheelEvent(event, scrollBar); - } - } - - private static boolean isNiceScrollingSupported(@NotNull MouseWheelEvent event) { - if (!isSupportedScrollType(event)) return false; - UISettings settings = UISettings.getInstanceOrNull(); - return settings != null && settings.getSmoothScrolling(); - } - - private static boolean isSupportedScrollType(MouseWheelEvent e) { - return e.getScrollType() == MouseWheelEvent.WHEEL_UNIT_SCROLL || TouchScrollUtil.isUpdate(e); - } - - private @NotNull MouseWheelEvent copyEventWithScaledRotation(@NotNull MouseWheelEvent e, int rotationScaleFactor) { - return new MouseWheelEvent(this, - e.getID(), - e.getWhen(), - e.getModifiers(), - e.getX(), - e.getY(), - e.getXOnScreen(), - e.getYOnScreen(), - e.getClickCount(), - e.isPopupTrigger(), - e.getScrollType(), - e.getScrollAmount(), - e.getWheelRotation() / rotationScaleFactor, - e.getPreciseWheelRotation() / rotationScaleFactor); - } - private boolean skipKeyEvent(@NotNull KeyEvent e) { return skipAction(e, myActionsToSkip); }