Code Monkey home page Code Monkey logo

Comments (2)

magreenblatt avatar magreenblatt commented on July 18, 2024

Scroll direction is usually an OS configuration option. I'm not sure how that is read/represented in Java.

from java-cef.

1fxe avatar 1fxe commented on July 18, 2024

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;
}

from java-cef.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.