RFR: 8282703: Axis is not cached in the LinuxTouchTransform class

Alexander Scherbatiy alexsch at openjdk.java.net
Sat Mar 5 15:59:24 UTC 2022


An axis is not cached in the LinuxTouchTransform class.

To reproduce the issue I added `System.out.printf("initTransform: axis: %d, index: %d%n", axis, index);` log to the LinuxTouchTransform.initTransform() method:
https://github.com/openjdk/jfx/blob/5112be957be70dd6521e6fb6ee64e669c148729c/modules/javafx.graphics/src/main/java/com/sun/glass/ui/monocle/LinuxTouchTransform.java#L117
run the [JFXButtonExample](https://bugs.openjdk.java.net/secure/attachment/98181/JFXButtonExample.java) sample and tapped the touch screen on a Raspberry Pi with Touchscreen.

The result was

initTransform: axis: 47, index: 0
initTransform: axis: 57, index: 0
initTransform: axis: 53, index: 0
initTransform: axis: 54, index: 0
initTransform: axis: 0, index: 0
initTransform: axis: 1, index: 0
initTransform: axis: 53, index: 0
initTransform: axis: 54, index: 0
initTransform: axis: 0, index: 0
initTransform: axis: 1, index: 0
initTransform: axis: 53, index: 0
initTransform: axis: 54, index: 0
initTransform: axis: 0, index: 0
initTransform: axis: 1, index: 0

The initTransform() is called several times for axis 0,1,47,53,54 and index is always set to zero.

The straight forward fix is to store the given axis in the axes array: "axes[index] = axis". This is the first commit for the current fix.
Using this fix the output with printf from initTransform() method looks like:

initTransform: axis: 47, index: 0
initTransform: axis: 57, index: 1
initTransform: axis: 53, index: 2
initTransform: axis: 54, index: 4
initTransform: axis: 1, index: 5

Now all axes are printed only once and the index value is different for each axes.

However, the minimum/maximum values are retrieved and cached for ABS_X/Y and ABS_MT_POSITION_X/Y axes after the fist tap on the screen.
The second commit improves this moving the ABS_X/Y and ABS_MT_POSITION_X/Y axes initialization into the LinuxTouchTransform constructor.

Now the touch logs look like:

// LinuxTouchTransform constructor
// device: /dev/input/mouse0
initTransform: axis: 0, index: 0
initTransform: axis: 1, index: 1
initTransform: axis: 53, index: 2
initTransform: axis: 54, index: 3

// LinuxTouchTransform constructor
// device: /dev/input/event2
initTransform: axis: 0, index: 0
initTransform: axis: 1, index: 1
initTransform: axis: 53, index: 2
initTransform: axis: 54, index: 3

// the first tap
initTransform: axis: 57, index: 4
initTransform: axis: 47, index: 5


The ABS_X/Y and ABS_MT_POSITION_X/Y axes and corresponding minimum/maximum values are initialized in the constructor. The other axes which stores only default values in translates and scalars arrays are initialized during touch events.

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

Commit messages:
 - Preinitialize ABS_X/Y and ABS_MT_POSITION_X/Y transforms in LinuxTouchTransform class
 - 8282703: Axis is not cached in the LinuxTouchTransform class

Changes: https://git.openjdk.java.net/jfx/pull/747/files
 Webrev: https://webrevs.openjdk.java.net/?repo=jfx&pr=747&range=00
  Issue: https://bugs.openjdk.java.net/browse/JDK-8282703
  Stats: 31 lines in 1 file changed: 23 ins; 8 del; 0 mod
  Patch: https://git.openjdk.java.net/jfx/pull/747.diff
  Fetch: git fetch https://git.openjdk.java.net/jfx pull/747/head:pull/747

PR: https://git.openjdk.java.net/jfx/pull/747


More information about the openjfx-dev mailing list