dolda2000 / hafen-client

Haven & Hearth client
Other
35 stars 185 forks source link

Fix for minimap zoom on highres mousewheel #19

Closed AlexanderPolyakov closed 10 months ago

AlexanderPolyakov commented 10 months ago

getWheelRotation() produces mousewheel messages with 0 'clicks' on high resolution mouse wheels, like MacBook touchpad. In this case minimap has an incorrect behaviour, as this partial clicks will make minimap view zoom-in, producing a jittering behaviour. As zoomlevel and scale are both integers, this is the minimal fix to the described issue.

Alternative solutions which can be considered:

dolda2000 commented 10 months ago

That's interesting. I've long wanted to support partial "rotation" for touchpads, but somehow the existence of getPreciseWheelRotation() has managed to elude me, so I didn't think it was possible to detect them in Java. Now that I know that, supporting them fully is what I'd like to do, but unfortunately Java doesn't seem to support receiving precise rotation values on Linux, so I can't test it.

Until I can test it and thus implement it, I'll go with a simpler solution, however I prefer ignoring mousewheel events when rotation is 0 for now. I've pushed that fix, so I'll close this pull request without merging it.

Thanks for the report!

AlexanderPolyakov commented 10 months ago

Thanks for the fix! I would argue that both changes can coincide: not passing 0 click scrolls protects downstream, while change in the minimap code produces intended logic in any scenario as intent is clearly shown in the code. What Linux distro do you have? I don't see precise output on a virtual Debian 12 I'm running either, but maybe that's an issue with a virtual machine on my side...

dolda2000 commented 10 months ago

I would argue that both changes can coincide.

Technically, you are right, but I'd argue that it's a reasonable expectation that mousewheel never gets called with a zero rotation, in which case I'm fine with the current code in the minimap.

What Linux distro do you have? I don't see precise output on a virtual Debian 12 I'm running either, but maybe that's an issue with a virtual machine on my side...

I'm using Debian Testing, but the problem isn't that the hardware or system doesn't support high-resolution scrolling. In fact, they do, and programs using GTK properly do scroll finely. The problem is that high-resolution scrolling is only available on X11 using the XInput extension, which Java doesn't use, instead just relying on X11 core input. I'm considering writing a patch for OpenJDK, but I'm not sure yet just how badly I want to implement the whole XInput extension.