-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
feat: Support ContactRect in X11 and Windows platform #16498
base: master
Are you sure you want to change the base?
Conversation
@@ -155,17 160,18 @@ public PointerPointProperties(RawInputModifiers modifiers, PointerUpdateKind kin | |||
} | |||
|
|||
public PointerPointProperties(RawInputModifiers modifiers, PointerUpdateKind kind, | |||
float twist, float pressure, float xTilt, float yTilt | |||
float twist, float pressure, float xTilt, float yTilt, Rect contactRect |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we need to extend the API? Can't relevant XI2 properties be converted to existing ones? How other platforms expose the same information? How browsers are handling that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How is the same info exposed by UWP?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we need to extend the API?
As a touch application, the touch area is an indispensable parameter.
Can't relevant XI2 properties be converted to existing ones?
Sorry, I can not find any existing ones can be converted to.
How other platforms expose the same information?
It can be implemented in Windows platform, see https://learn.microsoft.com/en-us/windows-hardware/design/component-guidelines/touchscreen-required-hid-top-level-collections
How is the same info exposed by UWP?
And we can get this info from WM_Pointer.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, we can get the touch size in wpf by StylusPointProperties.Width
and StylusPointProperties.Height
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How other platforms expose the same information? How browsers are handling that?
I support the windows platform now. And I test my demo, and I find the behavior of Avalonia is same as WinUI and UWP.
Also, according to https://learn.microsoft.com/en-us/windows/windows-app-sdk/api/winrt/microsoft.ui.input.pointerpointproperties.contactrect?view=windows-app-sdk-1.5 the contact rect is supposed to be reported in DIPs |
8fd3083
to
d050f20
Compare
/// <inheritdoc cref="PointerPointProperties.ContactRect" /> | ||
public Rect ContactRect | ||
{ | ||
get => _contactRect ?? new Rect(Position, new Size()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it should be new Size(1,1) by default I believe
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@maxkatz6 Sorry, I do not think so. I think the size should be zero here as the WinUI do.
Thanks #16705 I can call the |
You can test this PR using the following package version. |
You can test this PR using the following package version. |
You can test this PR using the following package version. |
You can test this PR using the following package version. |
What does the pull request do?
Adding the touch size support, which know as ContactRect in X11 and Windows platform.
What is the current behavior?
Miss the touch size feature.
What is the updated/expected behavior with this PR?
We can get the touch size from X11 and Windows.
I test the Avalonia Windows version by my two demo, the TouchSizeAvalonia demo and the WinUI demo.
I use the same physics for touch, and I can get the same result from TouchSizeAvalonia demo and the WinUI demo. That means this PR can have the same implementation as WinUI. Here's a video I recorded on my phone:
7685EE57C31474648644D744B87A8AE0.mp4
How was the solution implemented (if it's not obvious)?
Checklist
Breaking changes
Add the ContactRect property to PointerPointProperties and changed the argument list in the constructor of PointerPointProperties.
Obsoletions / Deprecations
Fixed issues
Reference: #1477