Skip to content
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

Open
wants to merge 13 commits into
base: master
Choose a base branch
from

Conversation

lindexi
Copy link
Contributor

@lindexi lindexi commented Jul 27, 2024

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

@@ -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
Copy link
Member

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?

Copy link
Member

@kekekeks kekekeks Jul 27, 2024

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?

Copy link
Contributor Author

@lindexi lindexi Jul 27, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kekekeks

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?

See https://learn.microsoft.com/en-us/windows/windows-app-sdk/api/winrt/microsoft.ui.input.pointerpointproperties.contactrect?view=windows-app-sdk-1.5

And we can get this info from WM_Pointer.

Copy link
Contributor Author

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

Copy link
Contributor Author

@lindexi lindexi Aug 24, 2024

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.

@kekekeks
Copy link
Member

lindexi added a commit to lindexi/lindexi_gd that referenced this pull request Jul 27, 2024
/// <inheritdoc cref="PointerPointProperties.ContactRect" />
public Rect ContactRect
{
get => _contactRect ?? new Rect(Position, new Size());
Copy link
Member

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

Copy link
Contributor Author

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.

@lindexi
Copy link
Contributor Author

lindexi commented Aug 24, 2024

Thanks #16705

I can call the _platform.Screens.ScreenFromPoint.

@avaloniaui-bot
Copy link

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

@lindexi lindexi changed the title feat: Support ContactRect in X11 platform feat: Support ContactRect in X11 and Windows platform Aug 24, 2024
@avaloniaui-bot
Copy link

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

@avaloniaui-bot
Copy link

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

@avaloniaui-bot
Copy link

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

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.

None yet

4 participants