Skip to content

Use the himetric location instead of the pixel location. #16850

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Oct 14, 2024

Conversation

walterlv
Copy link
Contributor

What does the pull request do?

This PR uses the ptHimetricLocation in the POINTER_INFO struct instead of the ptPixelLocation which makes the touch pointer more accurate.

As a result, if we draw all the touch points line-by-line, the path will be more smooth and accurate. See the following image for the comparison:

The Comparison of the drawn path

The following is a sample output of the touch points with the ptPixelLocation and ptHimetricLocation:

Pixel=2770, 1189 Himetric=2770.320129847705, 1189.298228010676
Pixel=2768, 1185 Himetric=2767.756328348931, 1185.3536954907588
Pixel=2765, 1181 Himetric=2765.1483233760405, 1181.23577692601
Pixel=2762, 1178 Himetric=2762.4519114549157, 1177.507976962132
Pixel=2760, 1174 Himetric=2759.5344821632075, 1173.780176998254
Pixel=2757, 1170 Himetric=2756.6170528714993, 1170.2257630792078
Pixel=2754, 1167 Himetric=2753.655420105674, 1166.6713491601613
Pixel=2751, 1163 Himetric=2750.605380391615, 1163.2036282635308
Pixel=2747, 1160 Himetric=2747.4669337293226, 1159.9092934117316
Pixel=2744, 1157 Himetric=2744.416894015264, 1156.6583050711404

What is the current behavior?

  1. The touch point use the ptPixelLocation which is an integer value.
  2. The PointToClient method only receives PixelPoint parameter which loses the decimal part of the touch point.

What is the updated/expected behavior with this PR?

  1. The touch point uses the ptHimetricLocation which is a float value.
  2. The PointToClient method receives Point parameter which keeps the decimal part of the touch point. I've written a new overload for the existed one.

How was the solution implemented (if it's not obvious)?

Checklist

Breaking changes

I think there is no breaking changes.

Obsoletions / Deprecations

Fixed issues

@avaloniaui-bot
Copy link

You can test this PR using the following package version. 11.2.999-cibuild0051564-alpha. (feed url: https://nuget-feed-all.avaloniaui.net/v3/index.json) [PRBUILDID]

@maxkatz6 maxkatz6 enabled auto-merge October 9, 2024 10:03
@MrJul MrJul disabled auto-merge October 10, 2024 09:57
@MrJul
Copy link
Member

MrJul commented Oct 10, 2024

@walterlv There are some conflicts that must be resolved (edit: and your branch is write-protected).

@walterlv walterlv force-pushed the t/walterlv/himetric-location branch from a2dee88 to 295f0c8 Compare October 12, 2024 23:01
@walterlv
Copy link
Contributor Author

@MrJul Confliction Resolved 😉

@avaloniaui-bot
Copy link

You can test this PR using the following package version. 11.3.999-cibuild0052621-alpha. (feed url: https://nuget-feed-all.avaloniaui.net/v3/index.json) [PRBUILDID]

@maxkatz6 maxkatz6 added this pull request to the merge queue Oct 13, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Oct 13, 2024
@MrJul MrJul added this pull request to the merge queue Oct 14, 2024
Merged via the queue into AvaloniaUI:master with commit 0bd90d8 Oct 14, 2024
11 checks passed
@lindexi lindexi deleted the t/walterlv/himetric-location branch October 19, 2024 02:31
walterlv added a commit to dotnet-campus/Avalonia that referenced this pull request Nov 27, 2024
…16850)

* Add an overload with more precise point transformation.

* Use the himetric location instead of the pixel location.

* The pen also use the himetric location.

* Similar codes.

* Use the raw location instead of the predicted one.
See: https://learn.microsoft.com/en-us/windows/win32/api/winuser/ns-winuser-pointer_info

* Fix wrong multi-screen location

* Add lost win32 api.

(cherry picked from commit 0bd90d8)
walterlv added a commit to dotnet-campus/Avalonia that referenced this pull request Feb 6, 2025
…16850)

* Add an overload with more precise point transformation.

* Use the himetric location instead of the pixel location.

* The pen also use the himetric location.

* Similar codes.

* Use the raw location instead of the predicted one.
See: https://learn.microsoft.com/en-us/windows/win32/api/winuser/ns-winuser-pointer_info

* Fix wrong multi-screen location

* Add lost win32 api.

(cherry picked from commit 0bd90d8)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants