NationalSecurityAgency / ghidra

Ghidra is a software reverse engineering (SRE) framework
https://www.nsa.gov/ghidra
Apache License 2.0
51.44k stars 5.86k forks source link

Jumping to different places when scrolling horizontally using touchpad #7024

Open ockamey opened 3 weeks ago

ockamey commented 3 weeks ago

I noticed that when I'm scrolling horizontally using touchpad (swiping two fingers to the left or right), the screen is jumping so quickly as you can see on the video. Do you know if it's a feature or a bug? Or how can I disable it? I'm using Ghidra 11.1.2 on Ubuntu 24.04 with Gnome.

https://github.com/user-attachments/assets/9536cc12-3168-4738-ba2d-ef45c3dedf2b

ryanmkurtz commented 3 weeks ago

Can you try switching themes to Nimbus to see if it changes the behavior?

ockamey commented 3 weeks ago

Thank you for the response! Unfortunately it's exactly the same. I've attached the video (of a slightly smaller executable).

https://github.com/user-attachments/assets/3af6c5c9-fc76-462a-ad9a-f9a585633d6f

octagons commented 2 weeks ago

I am also affected by this issue. It seems like the mouse scroll senstivity is too high and moving your fingers slightly left or right as you might naturally do when scrolling up or down triggers a forward/backward navigation to the next code segment. If it matters, I'm using a Apple Magic Trackpad over Bluetooth.

Ghidra 11.1.2 PUBLIC build OpenJDK 22.0.2 Manjaro Linux, KDE Plasma, Wayland

dragonmacher commented 2 weeks ago

There is a tool option to disable horizontal mouse scrolling. It can be found under the Code Browser's Edit -> Tool Options, under Options -> Listing Fields -> Mouse -> Horizontal Scrolling.

I am curious to see if turning this off has any effect on this particular issue.

octagons commented 2 weeks ago

@dragonmacher - Just disabled that option and tested but it had no visible effect on the behavior. Notably, horizontal scrolling also doesn't "work" in the sense that it does not scroll the view of a frame whose contents exceed the width of the frame's window whether or not this option is enabled - but it's not clear if this is related I don't want to muddy the issue.

Looking at it more closely, the horizontal scrolling action on the touchpad causes the focus to jump between the navigation history - the same functionality as hitting alt + left or alt + right on the keyboard.

My system has gesture recognition (similar to a tablet); e.g. a 2-finger swipe in many applications also navigates backwards, a 3-finger swipe moves between virtual desktops, etc. I looked for a few minutes, but cannot find a way to disable the gesture recognition to test whether the behavior persists. If it would help, I can try to test it later when I have more time. @ockamey - Do you also have this gesture recognition feature for your touchpad?

dragonmacher commented 2 weeks ago

@octagons Thanks for the update. Based on this and other gesture input devices I've seen, I do believe the side scrolling is being interpreted as navigation action presses.

For a normal mouse, users should be able to Shift-Mouse Wheel to perform horizontal scrolling. Does that work for you if you hold shift while performing the vertical scroll gesture?

octagons commented 2 weeks ago

For a normal mouse, users should be able to Shift-Mouse Wheel to perform horizontal scrolling. Does that work for you if you hold shift while performing the vertical scroll gesture?

Yes, I can confirm that the Shift + mouse wheel input performs the horizontal scrolling of the frame's contents as you described.

dragonmacher commented 2 weeks ago

Thanks! I'm guessing that this may have been 'broken' when we added support for mouse button navigation by assigning mouse button bindings to the history navigation actions. I think you both can fix this issue by clearing the mouse bindings in the options for the actions in the image below:"

image

If you decided to try this, let us know if it works.

ockamey commented 2 weeks ago

@dragonmacher thank you for the response! Unfortunately, the checkbox "Enter Mouse Binding" by default was unchecked on my machine in both previous, and next actions.

octagons commented 2 weeks ago

@dragonmacher - I tested this fix but unfortunately the behavior persists. To clarify: I filtered the Key Bindings list with the keywords 'location in history' as shown in your screenshot, and for both the 'Next' and 'Previous' options, I selected the input dialog, checked the 'Enter Mouse Binding' box, then hit backspace to clear it. This removed the '(Button4)' and '(Button5)' shortcut listed next to their respective navigation key bindings.

I'll admit I haven't spent any time digging for an answer on my own, but are you aware of any debugging functionality in Ghidra or for Wayland that might show the inputs being sent from the touchpad? My gut tells me that this is related to some constant in the UI/Input library where the threshold for a horizontal scroll input is too small. It may also be an unintended consequence of UI scaling wherein the distance one's fingers need to move in a horizontal scrolling gesture for it to be registered is a reasonable percentage of a 1920x1080 resolution, but the same distance is a much smaller percentage at 2K/4K resolutions. I would add that I did modify the scaling in support/launch.properties to make the UI readable.

dragonmacher commented 2 weeks ago

It sounds like there may be multiple issues happening.

@octagons Once the mouse bindings were cleared, did you still see the navigation history actions firing? I'm assuming that issue went away, but there may an issue with processing mouse scrolling events at high scale.

but are you aware of any debugging functionality in Ghidra or for Wayland that might show the inputs being sent from the touchpad?

This exists in the codebase, but is not something you can use from the UI. If you are setup to make and test changes to our source, then I can show you where you can make a change to get this type of info.

dragonmacher commented 2 weeks ago

@dragonmacher thank you for the response! Unfortunately, the checkbox "Enter Mouse Binding" by default was unchecked on my machine in both previous, and next actions.

@ockamey The checkbox is not selected by default. The actions do have a keybinding applied, even though the box is not checked. To clear the binding, you would first check the box and then clear the keybinding. @octagons tried this and said it did not help, so this may not fix this issue for you.

octagons commented 2 weeks ago

This exists in the codebase, but is not something you can use from the UI. If you are setup to make and test changes to our source, then I can show you where you can make a change to get this type of info.

Sure, I'll setup a dev environment tonight/tomorrow. I should be able to replicate my work environment pretty closely on my personal machine.

dragonmacher commented 2 weeks ago

If you end up doing this, you can change this class:

class DockingWindowsContextSensitiveHelpListener {

    private static DockingWindowsContextSensitiveHelpListener instance;

    private DockingWindowsContextSensitiveHelpListener() {
        Toolkit toolkit = Toolkit.getDefaultToolkit();
        AWTEventListener listener = new AWTEventListener() {            
            public void eventDispatched( AWTEvent event ) {
                DockingWindowManager.setMouseOverObject( event.getSource() );
            }
        }; 
        toolkit.addAWTEventListener( listener, AWTEvent.MOUSE_MOTION_EVENT_MASK );
    }

    static synchronized void install() {
        if ( instance == null ) {
            instance = new DockingWindowsContextSensitiveHelpListener();
        }
    }
}

You should be able to add a line to do this:

toolkit.addAWTEventListener( listener, AWTEvent.MOUSE_MOTION_WHEEL_MASK );

This is a class we use to listen to all mouse movement events. After adding this code to be notified of mouse wheel events, you should be able to print out each event to see what Java is giving to you as you are using your various gestures.

ockamey commented 2 weeks ago

@dragonmacher thank you for the response! Unfortunately, the checkbox "Enter Mouse Binding" by default was unchecked on my machine in both previous, and next actions.

@ockamey The checkbox is not selected by default. The actions do have a keybinding applied, even though the box is not checked. To clear the binding, you would first check the box and then clear the keybinding. @octagons tried this and said it did not help, so this may not fix this issue for you.

You're right, it didn't help. But also I noticed that if I check one of the checkboxes, the another one is automatically checked as well. Also after checking them, I closed the exit window and opened it again, and then the checkboxes are still not checked.