RFR: 8294426: Two fingers tap generates wrong mouse modifiers on M2 MacBooks

Nikita Provotorov duke at openjdk.org
Fri Sep 30 22:30:23 UTC 2022


On Fri, 30 Sep 2022 21:38:50 GMT, Nikita Provotorov <duke at openjdk.org> wrote:

>> src/java.desktop/macosx/classes/sun/lwawt/macosx/CPlatformResponder.java line 83:
>> 
>>> 81:         int jmodifiers = NSEvent.nsToJavaModifiers(modifierFlags);
>>> 82:         if ((jeventType == MouseEvent.MOUSE_PRESSED) && (jbuttonNumber > MouseEvent.NOBUTTON)) {
>>> 83:             // 8294426: NSEvent.nsToJavaModifiers returns 0 on M2 MacBooks if the event is generated
>> 
>> You say it returns 0, so you expect to only need to do that if jmodifiers is 0, yet you don't check that.
>> Why not ?
>> 
>> No way to test this on an M2 so being sure it doesn't regress something is all I can offer here.
>
> Actually I mean that it returns 0 if you're tapping without holding any modifiers e.g. keyboard modifiers.
> But if you're tapping holding a keyboard modifier it will probably return only this keyboard modifier without `InputEvent.BUTTON3_DOWN_MASK`. I didn't test this case but I would expect it that looking at the implementation of the `NSEvent.nsToJavaModifiers`.

I don't have an M2 device to check, but I think (judging to the code) if we add `jmodifiers == 0` check here then users making a tap holding the Control will receive the mouse events with `modifiers` == `CTRL_DOWN_MASK | BUTTON3_MASK | CTRL_MASK`, i.e. without modern `BUTTON3_DOWN_MASK` which is at least unusual and inconvenient.

-------------

PR: https://git.openjdk.org/jdk/pull/10429



More information about the client-libs-dev mailing list