Ghidra: OSX: scrolling only goes down

Created on 6 Mar 2019  路  24Comments  路  Source: NationalSecurityAgency/ghidra

On OSX 10.14.1, when you use the mouse's touch scroll or the touchpad's touch scroll, it will only scroll down regardless of the direction you are scrolling. If mouse scroll direction is set to "Natural" then it's a bit better as upward scrolling works somewhat but it's still buggy because it seems to "resist" the scroll.

Bug

Most helpful comment

Second fixed version that uses floating points, which makes it support flinging/high-speed motions and smooth scroll. Scrolling is now buttery-smooth with my trackpad. Use the other one if this one somehow doesn't work.

diff --git a/src/Docking/docking/widgets/fieldpanel/FieldPanel.java b/src/Docking/docking/widgets/fieldpanel/FieldPanel.java
index 7194951..2d72151 100644
--- a/src/Docking/docking/widgets/fieldpanel/FieldPanel.java
+++ b/src/Docking/docking/widgets/fieldpanel/FieldPanel.java
@@ -1419,8 +1419,10 @@ public class FieldPanel extends JPanel
     public class BigFieldPanelMouseWheelListener implements MouseWheelListener {
         @Override
         public void mouseWheelMoved(MouseWheelEvent e) {
-            int wheelRotation = e.getWheelRotation();
-            int scrollAmount = (wheelRotation < 0) ? -40 : 40;
+            double wheelRotation = e.getPreciseWheelRotation();
+            int scrollAmount = (int)(wheelRotation * 40);
+            if (scrollAmount == 0)
+                return;
             if (hoverHandler.isHoverShowing()) {
                 hoverHandler.scroll(scrollAmount);
             }

Docking.jar.zip

All 24 comments

This is happening on Windows 10 as well, with both scrolling direction configurations.

I'm also getting this issue on Windows 10 on my Surface Pro 3 trackpad.

Can confirm with MBP 2018 trackpad, macOS 10.14.1

One thing of note is that the scrolling behaves correctly on the symbol tree, program trees, and data type manager. Just the asm and decomp views appear to be misbehaving.

+1

Another thing I found out is if you scroll really fast, it will let you scroll up. Not sure how/why the scroll velocity is a differentiator, but that's a possible workaround. Only tested this on Mac trackpad.

Can confirm that is a possible "workaround" on Windows 10 as well.

FIXED!

diff --git a/src/Docking/docking/widgets/fieldpanel/FieldPanel.java b/src/Docking/docking/widgets/fieldpanel/FieldPanel.java
index 7194951..4e097fd 100644
--- a/src/Docking/docking/widgets/fieldpanel/FieldPanel.java
+++ b/src/Docking/docking/widgets/fieldpanel/FieldPanel.java
@@ -1420,6 +1420,8 @@ public class FieldPanel extends JPanel
         @Override
         public void mouseWheelMoved(MouseWheelEvent e) {
             int wheelRotation = e.getWheelRotation();
+            if (wheelRotation == 0)
+                return;
             int scrollAmount = (wheelRotation < 0) ? -40 : 40;
             if (hoverHandler.isHoverShowing()) {
                 hoverHandler.scroll(scrollAmount);

Attached is the fixed Docking.jar - replace Ghidra/Framework/Docking/lib/Docking.jar with this copy. (Compressed again as a .zip so it can be attached).

Tested and working on macOS 10.14.3, Java 11.0.2.

Docking.jar.zip

Second fixed version that uses floating points, which makes it support flinging/high-speed motions and smooth scroll. Scrolling is now buttery-smooth with my trackpad. Use the other one if this one somehow doesn't work.

diff --git a/src/Docking/docking/widgets/fieldpanel/FieldPanel.java b/src/Docking/docking/widgets/fieldpanel/FieldPanel.java
index 7194951..2d72151 100644
--- a/src/Docking/docking/widgets/fieldpanel/FieldPanel.java
+++ b/src/Docking/docking/widgets/fieldpanel/FieldPanel.java
@@ -1419,8 +1419,10 @@ public class FieldPanel extends JPanel
     public class BigFieldPanelMouseWheelListener implements MouseWheelListener {
         @Override
         public void mouseWheelMoved(MouseWheelEvent e) {
-            int wheelRotation = e.getWheelRotation();
-            int scrollAmount = (wheelRotation < 0) ? -40 : 40;
+            double wheelRotation = e.getPreciseWheelRotation();
+            int scrollAmount = (int)(wheelRotation * 40);
+            if (scrollAmount == 0)
+                return;
             if (hoverHandler.isHoverShowing()) {
                 hoverHandler.scroll(scrollAmount);
             }

Docking.jar.zip

Thanks for the fixes; They don't work on my systems for some reason (MacBook Pro 2015 and 2018, latest macOS). Replacing the Docking.jar does not change the behaviour :/

Did you restart Ghidra completely after replacing the file?

@nneonneo how do i build Docking.jar with all the stuff from Docking-src.zip myself?

@OothecaPickle I didn't build the whole .jar, I just found the file that needed patching and replaced it.

Here's my command, assuming the source is in src/Docking and you're in that directory:

javac -cp $(printf "%s:" $(find ../.. -name '*.jar')) docking/widgets/fieldpanel/FieldPanel.java 
jar -uf ../../Ghidra/Framework/Docking/lib/Docking.jar $(find . -name '*.class')

Did you restart Ghidra completely after replacing the file?

Yes

@nneonneo your patch works great for me on my MacBook Air on 10.12.6 and i was able to compile with those commands. thanks! :)

after further testing, it only works some of the time, but still, better than before!

Interesting that the fix doesn鈥檛 work all the time. What sorts of things are you seeing when it doesn鈥檛 work, @OothecaPickle?

@nneonneo if i scroll quickly, scrolling up works fine, but if i scroll slowly it scrolls down.

Those changes work for me (although I clearly was in a different dir when I built the jar and had to change that a bit), scrolling works perfectly for me now regardless of speed.

@6661696c are you using a trackpad or magic mouse?

Trackpad on 2017 MacBook Pro running 10.14.3.

Thanks for the suggested fix...it will be included in the next release!

Second fixed version that uses floating points, which makes it support flinging/high-speed motions and smooth scroll. Scrolling is now _buttery-smooth_ with my trackpad. Use the other one if this one somehow doesn't work.

diff --git a/src/Docking/docking/widgets/fieldpanel/FieldPanel.java b/src/Docking/docking/widgets/fieldpanel/FieldPanel.java
index 7194951..2d72151 100644
--- a/src/Docking/docking/widgets/fieldpanel/FieldPanel.java
+++ b/src/Docking/docking/widgets/fieldpanel/FieldPanel.java
@@ -1419,8 +1419,10 @@ public class FieldPanel extends JPanel
     public class BigFieldPanelMouseWheelListener implements MouseWheelListener {
         @Override
         public void mouseWheelMoved(MouseWheelEvent e) {
-            int wheelRotation = e.getWheelRotation();
-            int scrollAmount = (wheelRotation < 0) ? -40 : 40;
+            double wheelRotation = e.getPreciseWheelRotation();
+            int scrollAmount = (int)(wheelRotation * 40);
+            if (scrollAmount == 0)
+                return;
             if (hoverHandler.isHoverShowing()) {
                 hoverHandler.scroll(scrollAmount);
             }

Docking.jar.zip

This works nicely - thanks for the fix!

Does your sideways scroll work on MacOS? Mine doesn't seem to work properly.

@jiva Looks like it would take quite a bit of effort to make that work, the layout handler doesn't support horizontal scrolling and the java API being used here doesn't understand that touchpad scrolling exists :/

Was this page helpful?
0 / 5 - 0 ratings

Related issues

woachk picture woachk  路  33Comments

0x6d696368 picture 0x6d696368  路  19Comments

0x6d696368 picture 0x6d696368  路  17Comments

Piruzzolo picture Piruzzolo  路  19Comments

astrelsky picture astrelsky  路  15Comments