RFR: 8289115: Touch events is not dispatched after upgrade to JAVAFX17+
Markus Mack
mmack at openjdk.org
Tue Jun 4 16:28:47 UTC 2024
On Tue, 21 May 2024 14:25:51 GMT, Michael Strauß <mstrauss at openjdk.org> wrote:
> This PR fixes a bug ([JDK-8289115](https://bugs.openjdk.org/browse/JDK-8289115)) that was introduced with #394, which changed the following line in the `NotifyTouchInput` function (ViewContainer.cpp):
>
> - const bool isDirect = true;
> + const bool isDirect = IsTouchEvent();
>
>
> `IsTouchEvent` is a small utility function that uses the Windows SDK function `GetMessageExtraInfo` to distinguish between mouse events and pen events as described in this article: https://learn.microsoft.com/en-us/windows/win32/tablet/system-events-and-mouse-messages
>
> I think that using this function to distinguish between touchscreen events and pen events is erroneous. The linked article states:
> _"When your application receives a **mouse message** (such as WM_LBUTTONDOWN) [...]"_
>
> But we are not receiving a mouse message in `NotifyTouchInput`, we are receiving a `WM_TOUCH` message.
> I couldn't find any information on whether this API usage is also supported for `WM_TOUCH` messages, but my testing shows that that's probably not the case (I tested this with a XPS 15 touchscreen laptop, where `GetMessageExtraInfo` returns 0 for `WM_TOUCH` messages).
>
> My suggestion is to check the `TOUCHEVENTF_PEN` flag of the `TOUCHINPUT` structure instead:
>
> const bool isDirect = (ti->dwFlags & TOUCHEVENTF_PEN) == 0;
I attempted to test this with the sample app in [JDK-8249737](https://bugs.openjdk.org/browse/JDK-8249737) and [Microsoft.Windows.Simulator](https://stackoverflow.com/questions/40274660/windows-10-how-do-i-test-touch-events-without-a-touchscreen)
using the simulator's "Basic touch mode".
The "Too many touch points reported" exception seems to be thrown consistently with
`const bool isDirect = true;` (original before #394)
and `const bool isDirect = (ti->dwFlags & TOUCHEVENTF_PEN) == 0;` (this PR)
I didn't see the exception with `const bool isDirect = IsTouchEvent();` (#394)
and `const bool isDirect = false` (which is probably what IsTouchEvent() returns here).
Not sure what this simulator actually sends, but someone more knowledgeable might want to have a look at what's happening.
-------------
PR Comment: https://git.openjdk.org/jfx/pull/1459#issuecomment-2147933056
More information about the openjfx-dev
mailing list