Tapping on a button and next tapping on another place on the screen leads that 
the button is pressed twice on a Raspberry Pi with Touchscreen.

For example, run the 
[JFXButtonExample](https://bugs.openjdk.java.net/secure/attachment/98181/JFXButtonExample.java)
 
app and first tap on the button in the left bottom side of the screen and 
second tap on the center of the screen.

This is a log of the state from 
LinuxStatefulMultiTouchProcessor.processEvents() method when 
`System.out.printf("state: %s%n", state);` code is added before the line:
https://github.com/openjdk/jfx/blob/2e8a4a5e97bb88a5807ae5fe075b98e1d54a4ca0/modules/javafx.graphics/src/main/java/com/sun/glass/ui/monocle/LinuxStatefulMultiTouchProcessor.java#L140

state: TouchState[1,TouchState.Point[id=91,x=257,y=419]]
state: TouchState[1,TouchState.Point[id=91,x=257,y=420]]
state: TouchState[0]
Hello World!
state: 
TouchState[2,TouchState.Point[id=91,x=257,y=419],TouchState.Point[id=92,x=410,y=265]]
state: 
TouchState[2,TouchState.Point[id=91,x=257,y=419],TouchState.Point[id=92,x=409,y=267]]
state: 
TouchState[2,TouchState.Point[id=91,x=257,y=419],TouchState.Point[id=92,x=408,y=286]]
state: TouchState[0]
Hello World!

The TouchState contains only button coordinates (x=257,y=419) for the first tap 
on the button.
The TouchState contains both the button coordinates  (x=257,y=419) and 
coordinates of the center of screen (x=408,y=286) for the second tap on the 
center of the screen.

This happens because when LinuxStatefulMultiTouchProcessor.processEvents() 
pushes the state with current touches to the pipeline the LookaheadTouchFilter  
saves the current state and copies the previous saved state to the current 
state.
https://github.com/openjdk/jfx/blob/2e8a4a5e97bb88a5807ae5fe075b98e1d54a4ca0/modules/javafx.graphics/src/main/java/com/sun/glass/ui/monocle/LookaheadTouchFilter.java#L74

That leads that the already deleted touch state (which contains the button 
coordinate) is restored. 

The proposed solution is to put the copy of the touch state to the pipeline .

Printing the touch state after the fix shows the log:

state: TouchState[1,TouchState.Point[id=65,x=267,y=423]]
state: TouchState[1,TouchState.Point[id=65,x=269,y=425]]
state: TouchState[0]
Hello World!
state: TouchState[1,TouchState.Point[id=66,x=414,y=243]]
state: TouchState[1,TouchState.Point[id=66,x=414,y=238]]
state: TouchState[0]

The TouchState does not contains the button coordinates for the second tap.

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

Commit messages:
 - 8282702: Button is pressed one more time on Raspberry Pi with Touchscreen

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

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

Reply via email to