Open ionull opened 1 year ago
Scroll direction is usually an OS configuration option. I'm not sure how that is read/represented in Java.
I have a proposal for a somewhat hacky solution
This is the code in X11Window
class responsible for making the mouse event.
if (xev.get_type() == XConstants.ButtonPress) {
MouseWheelEvent mwe = new MouseWheelEvent((Component)getEventSource(),MouseEvent.MOUSE_WHEEL, jWhen,
modifiers,
x, y,
xbe.get_x_root(),
xbe.get_y_root(),
1,false,MouseWheelEvent.WHEEL_UNIT_SCROLL,
3,button==4 ? -1 : 1);
postEventToEventQueue(mwe);
}
So when scrolling down normally the button passed is 5 and delta is positive, X11Window
does keep track of lastButton
so in the native code we could fetch that and just reverse this behavior on linux
Made a POC that works, its just working in the case for natural scrolling, we would have to do the opposite of getWheelRotation() to calculate the delta properly
jclass xWindow = env->FindClass("sun/awt/X11/XWindow");
jfieldID lastButtonId = env->GetStaticFieldID(xWindow, "lastButton", "J");
jlong button = env->GetStaticLongField(xWindow, lastButtonId);
// Would check against getWheelRotation
if (button == 5L) {
delta = -3;
} else {
delta = 3;
}
Describe the bug Scroll direction is reversed on Linux when OSR is enabled.
To Reproduce Steps to reproduce the behavior:
Expected behavior Scroll as system side.
Versions (please complete the following information):