On Sat, 5 Mar 2022 13:58:54 GMT, Alexander Scherbatiy <alex...@openjdk.org> 
wrote:

> 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.

The fix looks OK to me. Since it is in Monocle, maybe @johanvos can review it?

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

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

Reply via email to